Commit Graph

394 Commits

Author SHA1 Message Date
Jonas Kulla bdd60291a7 Bitmap: Fix vertical gradient direction 2014-08-16 06:04:02 +02:00
Jonas Kulla 8d375b5cac Graphics: Execute one frame reset at construction
Fixes RGSS3 title screen transition looking skipped
2014-08-16 06:04:02 +02:00
Jonas Kulla 150c280c1e Graphics: Default framerate in RGSS2 is 60 2014-08-16 06:04:02 +02:00
Jonas Kulla 7a655528e4 Viewport: Add zero arg constructor (RGSS3) and bind in MRI 2014-08-16 06:03:48 +02:00
Jonas Kulla 5bc6f6f32c Etc: Implement missing RGSS3 functionality (and bind in MRI) 2014-08-15 22:58:08 +02:00
Jonas Kulla 7790bd6c2c Implement RGSS2 Tilemap class (TilemapVX) 2014-08-15 15:20:32 +02:00
Jonas Kulla 3717609142 Tilemap: Make Autotiles con/destructor private 2014-08-15 15:20:32 +02:00
Jonas Kulla 4742226e7c Tilemap: Fix typo 2014-08-15 15:20:32 +02:00
Jonas Kulla 91d19d0a73 Implement RGSS2 Window class (WindowVX) 2014-08-15 15:20:15 +02:00
Jonas Kulla d654fb7dd6 Add internal 'KeepDestAlpha' BlendType (for use in WindowVX) 2014-08-12 22:26:54 +02:00
Jonas Kulla d95e90db34 Tone: Add 'valueChanged' signal 2014-08-12 22:26:54 +02:00
Jonas Kulla 3550cc0ff5 Use correct default resolution for RGSS2/3 (544x416) 2014-08-12 22:21:57 +02:00
Jonas Kulla d128375d62 DisposeWatch: Make private and constify members 2014-08-12 21:41:59 +02:00
Jonas Kulla 194f70c48c SharedState: Constify most getter methods 2014-08-12 21:41:59 +02:00
Jonas Kulla 18022bf809 quadarray.h: Use size_t for everything (quad) count related 2014-08-12 21:41:59 +02:00
Jonas Kulla 7d30ce1a00 quad.h: Cleanup static functions to use templated Vertex parameter
Collapses all the different Vertex/SVertex/CVertex variants
into one generic one per function.
2014-08-12 21:41:59 +02:00
Jonas Kulla 0af5e9d66c gl-util.h: Add GL ID != operator and TEXFBO::clear
TEXFBO::clear resets the struct into its state right
after creation, nulling all IDs inside so they're invaid.
2014-08-12 21:41:59 +02:00
Jonas Kulla 1767b200c7 etc.h: Constify methods 2014-08-12 21:41:28 +02:00
Jonas Kulla 9967ae022d window.cpp: small cleanups
Constify static numbers
'unsigned char' -> 'uint8_t'
2014-08-12 19:38:31 +02:00
Jonas Kulla e858bbdcf5 Lift 'Disposable' concept from core into bindings
Instead of replicating the RGSS Disposable interface in C++
and merely binding it, redefine the 'disposed' state as the
entire core object being deleted (and the binding object's
private pointer being null).

This makes the behavior more accurate in regard to RMXP.
It is now for example possible to subclass disposable classes
and access their 'dispose'/'disposed?' methods without
initializing the base class first (because the internal pointer
is simply null before initialization). Accessing any other
base methods will still raise an exception.

There are some quirks and irregular behavior in RMXP; eg.
most nullable bitmap attributes of disposable classes
(Sprite, Plane etc.) can still be queried afterwards, but
some cannot (Tilemap#tileset), and disposing certain
attributes crashes RMXP entirely (Tilemap#autotiles[n]).
mkxp tries to behave as close possible, but will be more
lenient some circumstances.

To the core, disposed bitmap attributes will look
identically to null, which slightly diverges from RMXP
(where they're treated as still existing, but aren't drawn).
The Disposable interface has been retained containing a
single signal, for the binding to inform core when
objects are disposed (so active attributes can be set to null).
2014-08-09 21:21:38 +02:00
Jonas Kulla cc0ab35f10 Font: 'exist?' allows any object (returns false if not string) 2014-08-09 21:21:38 +02:00
Jonas Kulla 6c9fbc1465 Bitmap: Clip dest rect when blitting from mega surface 2014-08-09 21:21:38 +02:00
Jonas Kulla bdcf1503bd Bitmap: Normalize rectangle passed to pixman 2014-08-09 21:21:38 +02:00
Jonas Kulla 656c5099ea autotiles.cpp: Fix subrect pattern for indices 23 and 46
Fixes #51.
2014-08-07 10:46:58 +02:00
Jonas Kulla 24759fb97b EventThread: Simplify user event handling 2014-08-06 15:54:44 +02:00
Jonas Kulla 151a1f0d1b Table: Add clone constructor (and bind in MRI)
Fixes #50.
2014-08-05 05:24:13 +02:00
Jonas Kulla 59aed37d3e MidiSource: Improve pitch shifting accuracy
Also drop note events whose keys are shifted out of range
instead of clamping them.
2014-08-02 16:15:11 +02:00
Jonas Kulla 5eb5b0dc83 MidiSource: Fix memory leak and simplify code 2014-08-02 16:14:22 +02:00
Jonas Kulla 3bcf995832 Add option to turn off switching into executable dir on startup 2014-08-02 09:30:17 +02:00
Jonas Kulla cc7218c19d Spacing 2014-08-02 06:50:14 +02:00
Jonas Kulla 751fdc599e Audio: Add MIDI format playback support
This adds a new dependency with libfuildsynth. MIDI support
is built by default, but can be disabled if not desired.

All RTP songs should work well, but there are known problems
with other files (see README). Also, the pitch shift implementation
is somewhat poor and doesn't match RMXP (at least subjectively).

A soundfont is not included and must be provided by
the user themself.
2014-08-02 06:42:55 +02:00
Jonas Kulla 818ca18ebb ALStream: Actually fix issue referenced in prev commit
This bug occured when starting playback of a stream, then immediately
stopping it, loading a different source, and starting playback again.

The real issue was that in stopStream(),  the streaming thread had
not even queued anything yet, so it first decoded some data, then
started playing the source (which had already been stopped in the main
thread), and then finally saw the term request and stopped.

Instead stopping the source after the thread has definitely
terminated fixed the problem.
2014-07-31 05:12:35 +02:00
Jonas Kulla 80937d0d06 ALStream: Fix sometimes not unqueuing all buffers before play
Very rarely rogue buffers would remain and play on loop on song
switch because we only ever cleared processed, not queued, buffers
from the source.

The correct way to completely clear a source's queue is to
simply attach a null buffer to it.
2014-07-31 03:39:36 +02:00
Jonas Kulla 0a94b518dc Add missing header 2014-07-25 14:58:11 +02:00
Jonas Kulla ec16210f8a MRI-Binding: Allow manually specifying load paths in config 2014-07-24 23:11:12 +02:00
Jonas Kulla 393a283d99 Minor cleanups 2014-07-24 23:02:38 +02:00
Jonas Kulla 2f831aea60 RGSSAD: Add RGSS3 archive reader
Everything except the entry table parsing is the same as RGSS1.
2014-07-24 02:45:20 +02:00
Jonas Kulla 6726493ee7 RGSSAD: Add RGSS2 archive reader
Exactly the same as RGSS1 but different file extension.
Also remove some redundant strings.
2014-07-23 23:05:24 +02:00
Jonas Kulla 1ecdd9f980 filesystem.cpp: Split out RGSSAD parts 2014-07-23 22:57:39 +02:00
Jonas Kulla 7b947a50c9 Use macro from util.h for static array size 2014-07-23 21:26:44 +02:00
Jonas Kulla f73b0ba4b5 audio.cpp: Split up into smaller parts 2014-07-23 17:28:20 +02:00
Jonas Kulla 492be508da gl-fun.h: Allow to alternatively be compiled with GLES2 headers
Requires your typical "GLES2/{gl2,gl2ext,gl2platform}.h bundle.
Define "GLES2_HEADER" to use.
2014-07-21 01:49:06 +00:00
Jonas Kulla ca9f83c6de Bitmap: Always upload data in GL_RGBA format 2014-07-21 01:38:22 +00:00
Jonas Kulla c1d627e0ae GLMeta: Disable blending when blitting via quad draw 2014-07-20 13:20:43 +02:00
Jonas Kulla 27b7815f52 GLState: Remove 'BlendNone' mode in favor of disabling blending alltogether 2014-07-20 13:17:12 +02:00
Jonas Kulla 7ce747d34d GLProperty: Assert proper stack usage 2014-07-20 13:15:03 +02:00
Jonas Kulla c44f4d7d28 gl-util.h: GL_RGBA8 is not a legal internalformat under GLES2
GL_RGBA ought to be synonymous.
2014-07-19 15:40:40 +00:00
Jonas Kulla 6f17b6ff46 Hookup mkxp to run under a OpenGL ES 2.0 context 2014-07-19 14:26:42 +00:00
Jonas Kulla 86b207e389 Actually switch to 16 bit index buffers 2014-07-19 09:31:39 +02:00
Jonas Kulla 5640c3d04b Print RGSS thread error message to console 2014-07-19 02:59:05 +02:00
Jonas Kulla 813130fbf6 More size_t fixes 2014-07-19 02:58:57 +02:00
Jonas Kulla ccba946973 util.h: Use size_t for static array sizes 2014-07-19 00:52:00 +02:00
Jonas Kulla 20e46a98dd Plane: Add fallback without GL_REPEAT texture wrapping
This isn't supported under GLES 2.0 for npot textures.
2014-07-17 10:09:58 +02:00
Jonas Kulla 3a3ccf590e Plane: Don't set dirty flags when settings props to existing value 2014-07-16 13:43:13 +02:00
Jonas Kulla b8d861b4cd gl-util.h: Remove wrappers for things abstracted via GLMeta 2014-07-16 05:22:43 +02:00
Jonas Kulla bae977d4ab GLMeta: "Finish" -> "End" 2014-07-16 04:53:08 +02:00
Jonas Kulla a26c73930d GLMeta: Add framebuffer blitting support 2014-07-16 04:48:40 +02:00
Jonas Kulla 4a3a769b15 Graphics: Properly initialize uniform before drawing 2014-07-15 11:54:31 +02:00
Jonas Kulla 97f18beb91 Graphics: Remove dubious optimization 2014-07-15 11:53:34 +02:00
Jonas Kulla c5f18ee535 Print SDL error message if window creation fails 2014-07-14 06:22:49 +02:00
Jonas Kulla 35dbaab0c3 Shader: Use GetShader/Programiv instead of GetObjectParameterivARB
The former are core 2.0 while the latter is part of GL_ARB_shader_objects.
2014-07-14 04:13:15 +02:00
Jonas Kulla 97708d25b6 Tilemap: Reduce a few unnecessary blits
No need to replicate static autotiles if we're not animating
at all.
2014-07-13 14:05:56 +02:00
Jonas Kulla efb2fd2695 GLMeta: Add vertex array object support 2014-07-13 14:05:12 +02:00
Jonas Kulla dac1407120 Add some comments 2014-07-13 13:38:50 +02:00
Jonas Kulla b73461721c Add meta path with fallback for EXT_unpack_subimage parameters 2014-07-13 05:51:04 +02:00
Jonas Kulla a541cb1205 Some RGSS2/RGSS3 compile fixes 2014-07-13 05:34:18 +02:00
Jonas Kulla 91aefdc17a Tilemap: Fix map wrap around 2014-07-11 08:43:39 +02:00
Jonas Kulla d1bad9b45f Bitmap#get_pixel: Use cached client side copy of pixels
A very simplistic optimization for games that create a
Bitmap and then only ever query pixels from it.
2014-07-11 03:25:28 +02:00
Jonas Kulla caae9c5689 Wrap IBO index type into one definition
Makes it easier to switch between types (eg. 32 -> 16 bit).
2014-07-11 02:09:53 +02:00
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 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 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 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 5ba40369cc Don't unnecessarily expose internal constant 2014-05-30 23:13:58 +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 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 c6a3c5aa59 Graphics: Setting 'fixedFramerate' to -1 disables frame limit
Can be useful for benchmarking
2014-05-05 09:21:20 +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 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