Commit Graph

511 Commits

Author SHA1 Message Date
Jonas Kulla 295e0e5b15 Tilemap: Rewrite to only process and render visible region
Previously, on creation, we would parse the entire map data,
translating it into and uploading vertices once, then rendering
the entire map on every draw (to keep the draw calls minimal).
This worked great for smaller and medium sized maps, but starting
with larger maps (200x200+) it doesn't scale as the GPUs vertex
processing/culling is overwhelmed by the amount of data each frame.

This rewrite instead changes the strategy to only processing and
uploading a small subregion of the map (the currently visible part)
and regenerating all buffers if this subregion changes. The amount
of data transferred is small enough that it can be done every frame
without causing lag.

The changes also have the convenient side effect that we no longer
require 32 bit indices in mkxp, easing the road to possible GLES2
support in the future.
2014-07-11 02:00:30 +02:00
Jonas Kulla 300e61c64b TileAtlas: Fix broken atlas generation
The stuff committed in 56226c40c6
was actually completely broken.. oops.
2014-07-10 21:48:33 +02:00
Jonas Kulla c0f25548bd CMakeLists.txt: Add new file "tilemap.vert" 2014-07-09 17:11:05 +02:00
Jonas Kulla 6bbdf7e183 Bitmap#blt: Clamp source rect to source bitmap bounds
RGSS allows the source rectangle in both `blt` and
`stretch_blt` to lie outside the source bitmap bounds
(treating the missing data as (0, 0, 0, 0)) and to be
inverted (in which case the blitted image is also inverted).

This commit only hanldes a corner case that
arises in the game "Last Scenario"; emulating the full
RGSS behavior is however desirable.
2014-07-09 03:06:43 +02:00
Jonas Kulla 527a372bd3 Window: Fix contents not being drawn if no windowskin is set 2014-07-09 02:47:32 +02:00
Jonas Kulla 56226c40c6 Tilemap: Use vertex shader based autotile animation strategy
Previously, we would just stuff the entire tilemap vertex data
four times into the buffers, with only the autotile vertices
offset according to the animation frame. This meant we could
prepare the buffers once, and then just bind a different offset
for each animation frame without any shader changes, but it also
lead to a huge amount of data being duplicated (and blowing up
the buffer sizes).

The new method only requires one buffer, and instead animates by
recognizing vertices belonging to autotiles in a custom vertex
shader, which offsets them on the fly according to the animation
index.

With giant tilemaps, this method would turn out to be a little
less efficient, but considering the Tilemap is planned to be
rewritten to only hold the range of tiles visible on the screen
in its buffers, the on the fly offsetting will become neglient,
while at the same time the amount of data we have to send to the
GPU everytime the tilemap is updated is greatly reduced; so a
net win in the end.
2014-07-06 19:44:19 +02:00
Jonas Kulla 033d46a293 Window: Use bilinear filtering for drawing controls
See #44
2014-07-03 14:32:03 +02:00
Jonas Kulla 4a0084801e Graphics: Respect non-default initial window size 2014-07-03 02:48:28 +02:00
Jonas Kulla 843a7bf571 gl-fun.h: Fix KHR_debug function signatures 2014-06-24 23:56:13 +02:00
Jonas Kulla 902a5e8c76 README: Clarify SDL_sound version 2014-06-21 17:01:05 +02:00
Jonas Kulla a4615fb8cc Add copyright notice to gl-fun.{cpp,h} 2014-06-15 07:52:26 +02:00
Jonas Kulla 6808b9a6dd SoundEmitter: Optimize source allocation strategy
Before, we would blindly rotate through the sources (like a
revolver through its chambers), which worked great if one
assumed all sounds to be relatively short and therefore oldest
use == most likely to be free, but breaks if there is one long
sound playing, which would be stopped and overtaken if we rotated
back to it even though there might be other free sources available.

Instead, keep an ascending priority list of sources with last
used == highest priorty that is iterated through for the first
free one, and only if none is found overtake the one with lowest
priority. This also ensures we're always able to play 'SE_SOURCES'
sounds at once independently of their length.

Fixes #37.
2014-06-15 06:26:34 +02:00
Jonas Kulla 282d547ad4 Remove Perftimer classes
Performance can still be crudely measured by turning off
the framelimit and observing the FPS count. For everything
else, there's always callgrind / apitrace.
2014-06-13 19:01:15 +02:00
Jonas Kulla 6c481e5eb8 Eliminate GLEW dependency
GL entrypoint resolution is now done manually. This has a couple
immediate benefits, such as not having to retrieve hundreds of
functions pointers that we'll never use. It's also nice to have
an exact overview of all the entrypoints used by mkxp.

This change allows mkxp to run fine with core contexts, not sure
how relevant that is going to be in the future.

What's noteworthy is that  _all_ entrypoints, even the ones core
in 1.1 and guaranteed to be in every libGL, are resolved
dynamically.
This has the added benefit of not having to link directly against
libGL anymore, which also cleans up the output of `ldd` quite
a bit (SDL2 loads most system deps dynamically at runtime).

GL headers are still required at build time.
2014-06-13 18:46:45 +02:00
Jonas Kulla 640b01e518 Graphics: Fix double calculation being a fixed point division 2014-06-12 14:31:29 +02:00
Jonas Kulla 3ac8f1e8aa Actually, don't disable that on Windows 2014-06-12 12:54:10 +02:00
Jonas Kulla aed7ba6672 Graphics: Check for nanosleep errors, disable on Windows (for now) 2014-06-12 10:40:17 +02:00
Jonas Kulla 06b218d5d7 Don't rely on non-standard typedef (thanks @ntzrmtthihu777) 2014-06-08 06:59:35 +02:00
Jonas Kulla 013437074b gitignore: Add codeblocks files 2014-06-08 06:55:37 +02:00
Jonas Kulla 2cc2ebca31 GLState: Get rid of GL_TEXTURE_2D enable/disable
This bit was deprecated/removed in core GL.

There was only one place where this was used (flash tiles
in Tilemap), and since the full shader rewrite, it was
effectively a no-op anyway (flash shader doesn't sample texture).
2014-05-30 23:13:58 +02:00
Jonas Kulla 7b1f599dd6 mkxp.pro: Add 'BOOST_LIB_SUFFIX'
Boost being boost.
2014-05-30 23:13:58 +02:00
Jonas Kulla 5ba40369cc Don't unnecessarily expose internal constant 2014-05-30 23:13:58 +02:00
Jonas Kulla ad63c962c6 Merge pull request #32 from cremno/use-rb_funcall2-instead-of-rb_funcallv
use `rb_funcall2` instead of `rb_funcallv`
2014-05-25 13:28:31 +02:00
cremno e6a116f43f use `rb_funcall2` instead of `rb_funcallv`
In 2.1 `rb_funcall2`  was renamed to `rb_funcallv` and
a macro for backward compatibility was added.
2014-05-25 12:57:04 +02:00
Jonas Kulla 0ef68a2eb7 Audio: Remove unused float helper code
Let's us get rid of 'alext.h' include,
which doesn't exist on OSX.
2014-05-24 18:26:04 +02:00
Jonas Kulla ce0fee0641 Spacing 2014-05-24 18:24:51 +02:00
Jonas Kulla 70279f0fdc mkxp.pro: Remove stray linker parameter 2014-05-24 18:24:10 +02:00
Jonas Kulla ea20154978 Spacing 2014-05-22 05:49:06 +02:00
Jonas Kulla 66fe932a8e Remove useless code 2014-05-21 18:11:31 +02:00
Jonas Kulla 2d30301aef DebugWriter: Add std::vector print handler 2014-05-21 18:10:46 +02:00
Jonas Kulla 32bb18d93f Spacing 2014-05-21 18:10:14 +02:00
Jonas Kulla d09f4a1bae Typo 2014-05-21 18:08:31 +02:00
Jonas Kulla e74f889bc5 Quad: Don't discard VBO on each update
This never yielded any traceable performance gains.
I also apparently forgot to unbind the buffer after
updating.
2014-05-16 21:39:26 +02:00
Jonas Kulla 8dd7c1b48c Spacing/spelling 2014-05-07 17:52:11 +02:00
Jonas Kulla 72fc659a4c MRI-Binding: Don't refine Kernel#caller in RGSS3 2014-05-07 03:19:06 +02:00
Jonas Kulla 1bdcfa7b04 MRI-Binding: Adjust 'Kernel#caller' output to match RMXP 2014-05-06 12:13:12 +02:00
Jonas Kulla c6a3c5aa59 Graphics: Setting 'fixedFramerate' to -1 disables frame limit
Can be useful for benchmarking
2014-05-05 09:21:20 +02:00
Jonas Kulla 627ff66e7a mkxp.pro: Add 'EMBED' files to 'OTHER_FILES'
So they show up in the project tree in QtCreator.
2014-05-03 04:07:07 +02:00
Jonas Kulla 80b2768e73 Fix "unused variable" warning 2014-05-03 04:05:11 +02:00
Jonas Kulla 58d86039d5 Merge branch 'dev' 2014-04-17 08:19:24 +02:00
Jonas Kulla 4cb1c10c3a Minor declaration fix 2014-04-16 20:54:29 +02:00
Jonas Kulla 4e346cac27 Merge pull request #25 from cremno/mri-improve-error-printing
MRI: improve error printing
2014-04-16 20:22:58 +02:00
cremno bd6764450f fix comment style 2014-04-16 20:05:15 +02:00
Jonas Kulla f11cc182df Remove screenshot functionality
It was only meant for debugging and brought with it
unneeded platform dependant issues.
2014-04-16 13:48:45 +02:00
Jonas Kulla 1ef6e04520 Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.

Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.

Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add

fontSub=Arial>Open Sans

to the configuration file. Multiple such rules can be specified.

In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-16 13:37:22 +02:00
Jonas Kulla 31626c9acc Spacing 2014-04-16 13:06:16 +02:00
Jonas Kulla 51c5ca1410 Graphics: Taint entire Bitmap in #snap_to_bitmap 2014-04-15 19:05:36 +02:00
Jonas Kulla f25d2db63c MRI-Binding: Add RGSS3 '__FILE__' variant 2014-04-15 11:54:22 +02:00
Jonas Kulla 711060db8f Spacing / minor fixes 2014-04-14 09:39:23 +02:00
cremno 4ca9e82a14 MRI: improve error printing
`Debug()` is CRuby-style and `showMsg` is RGSS-style.
The `Debug()` output is safe, `showMsg` might be fragile.
2014-04-14 00:07:51 +02:00