Commit Graph

162 Commits

Author SHA1 Message Date
Jonas Kulla 0035c23641 Shader: Group all shaders in one collective struct
Makes sharedstate.{cpp|h} a lot easier to read, and
adding new shaders a one liner.
2013-12-11 05:22:13 +01:00
Jonas Kulla 8c6648f47e Use std algorithm functions 2013-12-08 13:19:22 +01:00
Jonas Kulla ef12e96158 Remove completely outdated note 2013-12-08 13:01:59 +01:00
Jonas Kulla 946d778b96 Audio: Fix BGM not starting after ME has ended
A previous commit prevented the MeWatch from
starting a BGM stream that was in stopped state.
However, when a new BGM is loaded while the ME
is still playing, the BGM stream will be stopped
even though we want it to start after the ME
finishes.

Also add some comments trying to explain members
of 'AudioStream' a bit better.
2013-12-08 12:58:39 +01:00
Jonas Kulla bf712f3738 Graphics: Remove useless and confusing function 2013-12-08 12:57:46 +01:00
Jonas Kulla 5328d17090 Graphics: Fix viewport effect rendering bug
We didn't account for the spec dictating that
scissor test does affect FBO blit operations,
which resulted in corrupted output if more than
one viewport with an active effect (tone, color)
was created.

The reason I never caught this before must be
that the fglrx-legacy driver is actually bugged
in this aspect and ignores the scissor on blit.
2013-12-08 12:23:12 +01:00
Jonas Kulla 8ac70b7879 Sprite: Perform CPU visibility culling 2013-12-06 15:55:18 +01:00
Jonas Kulla 6e3b1d9466 Sprite: Don't draw when opacity == 0 2013-12-05 18:27:53 +01:00
Jonas Kulla 648684e4aa Don't expose global modules' con/destructors
This is just a small change to make the C++ API
match the binding counterparts more closely.
2013-12-05 00:34:11 +01:00
Jonas Kulla 5fca94616c Audio: Implement RGSS3 functionality
'Pos' and 'Play' functions take a float for
their 'pos' parameter, which is in seconds
of playback.

'setupMidi' is a noop at this point.
2013-12-05 00:24:18 +01:00
Jonas Kulla ef2430e0c3 Sanitize #include statements
The general rule I'm aiming for is to <> include
system wide / installed paths / generally everything
that's outside the git managed source tree (this means
mruby paths too!), and "" include everything else,
ie. local mkxp headers.

The only current exception are the mri headers, which
all have './' at their front as to not clash with
system wide ruby headers. I'm leaving them be for now
until I can come up with a better general solution.
2013-12-04 17:48:37 +01:00
Jonas Kulla 9a63140f3e Audio: MeWatch: Don't resume stopped BGM 2013-12-04 17:16:18 +01:00
Jonas Kulla 04526987e4 Audio: Implement RGSS2 ogg looping
With this we now link to libvorbis/ogg directly.
When this is enabled, one can theoretically also
build SDL_sound without ogg support, although I
doubt it makes much of a difference.

Adittionally, count frames instead of samples
for playback offset calculation.
2013-12-04 16:44:34 +01:00
Jonas Kulla 226e860c38 Bitmap: Fix renaming issue in RGSS2 code 2013-12-04 15:53:42 +01:00
Jonas Kulla a817b31e7c Audio: Remove all traces of rubberband
We will not be using librubberband for in place
pitch shifting. RMXP "shifts" PCM based audio
by just playing it back slower/faster, which
OpenAL takes care of for us. A native midi backend
will be able to effortlessly pitch shift by
multiplying note pitches, should we ever get one.

I have been chasing this ghost for way too long.
2013-12-04 14:49:35 +01:00
Jonas Kulla e26d0366f1 Revert "Audio: Make cheap OpenAL pitch shifting a config option"
Making this an option makes no sense. It ought to
be the default behavior, as RMXP pitch shifts PCM
based audio files the exact same way.

This reverts commit ac35d4214e.
2013-12-04 13:39:39 +01:00
Jonas Kulla ac35d4214e Audio: Make cheap OpenAL pitch shifting a config option 2013-12-01 09:36:15 +01:00
Jonas Kulla a65956818f Bitmap: Feed image extension into SDL2_image for faster loading 2013-11-30 14:28:50 +01:00
Jonas Kulla 64f35071ab Audio: Replace SFML solution by using OpenAL directly
This is a major change in the Audio module that comes with
many changes throughout the codebase and dependency list.
The main gist is that we're finally nuking the last pieces
of SFML from the project. sfml-audio brought with itself
unneeded and big dependencies (libsndfile, libvorbisenc)
while at the same time limiting the amount of audio formats
mkxp can support (eg. we now get mp3 for free, and wma/midi
can be implemented by extending SDL_sound directly).

The increased control gained by interfacing with OpenAL directly
will also allow for easy integration of a dedicated audio
stretcher (librubberband), as well as enable us to implement
looped ogg vorbis (via the 'LOOPSTART'/'LOOPLENGTH' tags),
as required by RGSS2, in the future.

The FileSystem class has had its SFML parts removed.
Aditionally, audio file extensions to be supplemented are
now automatically detected based on how SDL_sound was
built (ie. if no mp3 support was built, mkxp won't try
to look for *.mp3 files). The final used extension
can be optionally returned by 'openRead' calls so
SDL_sound and SDL2_image can immediately choose the
right decoder.

The OpenAL context is created and destroyed in main.cpp
along side the GL context.
2013-11-30 12:00:11 +01:00
Jonas Kulla 0b195cbffc Perftimer: Make GPU query count configurable 2013-11-30 11:47:03 +01:00
Jonas Kulla 0038d27c11 Input: Fix default key bindings 2013-11-30 11:45:17 +01:00
Jonas Kulla ac9bc21947 TexPool: Simplify code 2013-11-23 12:40:23 +01:00
Jonas Kulla da2f68cdba TexPool: Rename 'CacheObject' to 'CacheNode' 2013-11-23 12:27:10 +01:00
Jonas Kulla 06f5a06f67 Filesystem: Optimize RGSSAD file enumeration
Finally got around to nuking that ugly pile of shit that was
previously there for PhysFS file enumeration because filepath
cache generation with unencrypted game files + archive + RTP
has started taking around 6 seconds. Thank $DEITY.
2013-11-01 08:24:14 +01:00
Jonas Kulla 28ff5cd33c Bitmap: Ensure cloned bitmap is non-mega 2013-10-31 10:26:39 +01:00
Jonas Kulla 7549778dc6 Font: Add clone constructor 2013-10-31 10:09:57 +01:00
Jonas Kulla 8dd6b63fc4 EventThread: Mouse button IDs greater than 'SDL_BUTTON_X2' are possible 2013-10-29 08:54:57 +01:00
Jonas Kulla b6890a3c35 Remove unused code 2013-10-29 08:53:56 +01:00
Jonas Kulla 58bd60a70f Graphics: Attempt to provide more consistent frame timings
We now actively track how far behind / in front of an
ideal timestep we are during each frame, and try to
catch up / delay approximate this timing.

Therefore we use more precise timers and sleep functions
(nanosleep if available). We also delay **before** the
final buffer swap so the frame displays at more consistent
points in time.

Not only should this provide a somewhat more consistent
looking map scrolling at lower frame rates, it also
guarantees that we don't fall out of sync eg. with the
Audio during longer cutscenes.

'Graphics.frameReset()' now finally has a function, in
that it resets the ideal timestep approximation, which I
beliefe was also its job in the original RMXP engine.

I'm not sure how well this will work when the frame rate
is set to the monitor refresh rate and vsync is turned on.
Very likely unnecessary frame skips will occur here and there
due to imprecise timers. In the future we should probably
check if the frame rate is equal to or higher than the
monitor rate, and disable frame skip accordingly.

These changes currently break the F2 FPS display (it shows
a value that's slightly too high).
2013-10-22 17:05:46 +02:00
Jonas Kulla 765fd55bce Tilemap: Use simple "TexPool" replacement for atlas allocation
Releasing a Tilemap atlas into the pool on every map switch
will blow out tons of smaller textures for very little gain,
as atlas textures are already pretty much impossible to
recycle anywhere but in new Tilemaps.
2013-10-22 06:36:13 +02:00
Jonas Kulla 10b3e04dee Add config entry "allowSymlinks" 2013-10-20 22:38:46 +02:00
Jonas Kulla dcdfea55f1 Bitmap: Make 'Bitmap::textSize()' work with multibyte characters 2013-10-20 22:14:38 +02:00
Jonas Kulla d63c8cdc19 Bitmap: Add FIXME 2013-10-20 21:05:48 +02:00
Jonas Kulla 7236ca0515 Spacing 2013-10-19 01:47:12 +02:00
Jonas Kulla 82e2901726 Plane, Sprite: Fix Bitmap flushes in draw handler
Comparing the current SceneElement classes to the earlier
written documentation actually immediatelly exposed some
bugs. Yay! :D
2013-10-17 15:28:55 +02:00
Jonas Kulla 52dd1dbe2f Bitmap: Add warning to 'flush()' 2013-10-17 15:28:43 +02:00
Jonas Kulla f67a73cb4f Attempt at better documentation for SceneElement subclasses 2013-10-17 15:27:48 +02:00
Jonas Kulla f5a178b9bb Add config option "fixedFramerate" 2013-10-17 02:18:16 +02:00
Jonas Kulla 9dcd09d64f Serialization: Fix typos resulting in corrupted data 2013-10-17 01:01:25 +02:00
Jonas Kulla 9e3d7f579c Bitmap: Use PixelStore to avoid aux clip surface 2013-10-16 22:54:05 +02:00
Jonas Kulla 397856089d Tilemap: Optimize atlas assembly from mega surface tileset
Use 'glPixelStorei()' parameters to upload sub images
directly from the same surface instead of creating
helper surfaces to upload from.
2013-10-16 19:20:36 +02:00
Jonas Kulla 94911b61a6 Revert "Always request OpenGL Core profile"
This reverts commit 34d4103111.

Turns out we need at least GLSL 1.50, for which we'd
have to throw our OpenGL 2.0 compatibility in the water.
Nope, not yet.
2013-10-16 00:04:01 +02:00
Jonas Kulla 1e98413a7e Init: Print various GL implementation strings 2013-10-15 23:19:52 +02:00
Jonas Kulla 6b20147a72 Table: Minor cleanups
Fix up comment style and remove the MIN macro
in favor of the template defined in util.h.
2013-10-15 19:39:29 +02:00
Jonas Kulla bf5e80dd6a Init: Check for OpenGL 2.0 and destroy context on error 2013-10-15 19:35:03 +02:00
Jonas Kulla 36b904ede3 Clean up serialization helpers and add endianness check
We don't handle big endian at the moment, so let's
error out on that.
2013-10-14 12:57:30 +02:00
Jonas Kulla 2a83cfc1e1 Init: glClear the window as early as possible 2013-10-14 03:03:31 +02:00
Jonas Kulla caccee5db2 Fix up glew include paths 2013-10-14 02:22:34 +02:00
Jonas Kulla 39436ad231 Fix up SDL2 include paths
Using "SDL2/SDL_xxx.h" instead of "SDL_xxx.h" caused
the include paths provided by pkg-config to be ignored,
and headers from a standard include path to be used instead.
2013-10-13 23:21:34 +02:00
Jonas Kulla 8b9c501249 Remove useless SDL_Init() flag 2013-10-13 23:07:40 +02:00