Commit Graph

564 Commits

Author SHA1 Message Date
Jonas Kulla 52e2f2304a Spacing 2014-08-17 00:27:08 +02:00
Jonas Kulla f0e045d057 Font: Add RGSS2 default values 2014-08-17 00:27:07 +02:00
Jonas Kulla 4daff93e29 Put bundled font into its own translation unit 2014-08-17 00:26:35 +02:00
Jonas Kulla cbdd19e525 WindowVX: Make more compatible with RGSS2 2014-08-16 22:32:06 +02:00
Jonas Kulla 8042289291 WindowVX: Fix window resizing from big to small 2014-08-16 20:11:46 +02:00
Jonas Kulla e7882c0d3e Plane: Fix screen shaking in wrong direction 2014-08-16 16:14:00 +02:00
Jonas Kulla 9c421aed45 Add minor comments 2014-08-16 16:14:00 +02:00
Jonas Kulla e208bc49e8 Sprite: Implement Y based Z draw ordering (RGSS2)
If two sprites have the same Z, their order is decided based
on their Y coordinate first, and only then (if equal) by creation
time.
2014-08-16 16:12:51 +02:00
Jonas Kulla 3887342439 Disposable: Emit 'wasDisposed' on destruction, not dispose()
Fixes segfaults when objects that were not explicitly disposed
were collected by the GC.
2014-08-16 11:47:07 +02:00
Jonas Kulla b32d6c69cb SharedState: Add RGSS2 default encrypted archive filename 2014-08-16 11:47:07 +02:00
Jonas Kulla 840ecee084 Fix 'uninitialized value used' warnings 2014-08-16 11:47:07 +02:00
Jonas Kulla f58e4ab00d WindowVX: Don't use uninitialized index value 2014-08-16 11:47:07 +02:00
Jonas Kulla 1195dc15bd WindowVX: Add small hack to visually improve background
Make the stretched background source rect smaller by one pixel.
Greatly improves look of Windows in Majo no Ie.
2014-08-16 11:47:07 +02:00
Jonas Kulla ded18f9a02 TileAtlasVX: RGSS2 knows no shadow layer 2014-08-16 11:47:06 +02:00
Jonas Kulla f036e83a2d WindowVX: Remove faulty cursor rect positioning logic 2014-08-16 11:47:06 +02:00
Jonas Kulla 3277663944 WindowVX: Fix padding rect not updating on size change 2014-08-16 11:47:06 +02:00
Jonas Kulla bce4eb2bee WindowVX: Fix cursor rectangle geometry not updating 2014-08-16 11:47:06 +02:00
Jonas Kulla 062c7267d7 TilemapVX: Fix map viewport not updating on scene geometry change 2014-08-16 11:47:06 +02:00
Jonas Kulla 9003f9a435 Font: Add missing RGSS2+ props basic plumbing (and bind most in MRI)
No core implementations yet for shadow and outline color.
2014-08-16 11:46:25 +02:00
Jonas Kulla 36eea09c7e SharedState: Add RGSS3 default encrypted archive filename 2014-08-16 06:04:02 +02:00
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
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
cremno 95c112bbe4 MRI: add option to use a script's name as filename 2014-04-11 18:11:32 +02:00
Jonas Kulla 4219b91bbb al-util.h: Add include fix for older OpenAL releases
Apparently older versions of 'alext.h' didn't include
'alc.h' despite dependencies on ALC types.
2014-02-06 04:27:17 +01:00
Jonas Kulla af9039f58d Sprite: Implement wave effect (RGSS2)
This initial implementation emulates the way RMVX splits
the sprite into "chunks" of about 8 pixels, which it then
scrolls left/right on a vertical sine wave. It even
replicates the weird behavior when wave_amp < 0, namely
"shrinking" the src_rect horizontally.

As with bush_opacity, this effect in combination with
rotation will render differently from RMVX.
2014-02-03 15:32:50 +01:00
Jonas Kulla bb8f2351cc Bitmap: Remove leftover 'flush()' calls 2014-02-02 23:36:01 +01:00
Jonas Kulla e0a4dfe372 Bitmap: Make #get_pixel/#set_pixel more accurate
This gets rid of the "batch/flush" semantics for #set_pixel
and instead just directly uploads the pixel color to the
texture, circumventing the float conversion entirely.
Also makes a lot of code simpler in many places as calling
'flush()' is no longer required for bitmaps.
2014-01-31 10:19:16 +01:00
Jonas Kulla b6a299541f Bitmap: Fix #get_pixel returning bogus values
We never bound the Bitmap FBO to the READ binding point,
so glReadPixels was blindly reading data off of whatever
was last bound there.
2014-01-28 16:38:10 +01:00
Jonas Kulla 96d2707edb Bitmap: Fix #get_pixel returning bogus values
We never bound the Bitmap FBO to the READ binding point,
so glReadPixels was blindly reading data off of whatever
was last bound there.
2014-01-28 16:34:28 +01:00
Jonas Kulla f956f21ce1 Revert "Font: Adhere to spec and set Font.default_name to "MS PGothic""
This reverts commit c9423164d4.

Turns out the spec was not adjusted correctly for the
English RGSS version; the de facto default is "Arial"
after all.
2014-01-26 08:06:54 +01:00
Jonas Kulla b28863d8eb Add comment 2014-01-25 09:30:48 +01:00
Jonas Kulla 87c1e376b9 GLState: Add bound shader program to managed state
Squishes a handful of redundant binds per frame.
2014-01-20 00:58:39 +01:00
Jonas Kulla b729da249b Graphics: Don't unbind shader 2014-01-20 00:56:00 +01:00
Jonas Kulla e93e1fd292 debugwriter.h: Use std::newl instead of '\n' 2014-01-20 00:54:42 +01:00
Jonas Kulla f3572f5ba4 Bitmap: Don't unbind shader after render op
Since all rendering is now shader based, there's normally
no reason to ever unbind a shader program.
2014-01-20 00:53:58 +01:00
Jonas Kulla f39d1239bb TileAtlas: Slightly optimize out some allocation
User vector instead of list for colums.s
2014-01-16 19:17:46 +01:00
Jonas Kulla b0a41a23e0 Rename typedef and fix wrong documenting comment 2014-01-16 19:16:09 +01:00
Jonas Kulla 316457b988 Refactoring 2014-01-16 04:19:22 +01:00
Jonas Kulla 91efcfa06d FileSystem: More stringent RGSSAD header checks 2014-01-16 01:06:59 +01:00
Jonas Kulla bbb9bff239 FileSystem: Fix path cache for mounted zip archives 2014-01-15 01:51:56 +01:00
Jonas Kulla f14a379ee9 FileSystem: Trim redundant error message on ENOENT
MRI adds the "No such file or directory - " itself;
I guess we can just emulate this behavior everywhere else.
2014-01-15 01:47:16 +01:00
Jonas Kulla 64cb4ee4f1 Use stdint types 2014-01-15 01:43:46 +01:00
Jonas Kulla 0f004b8601 Spacing 2014-01-15 00:48:34 +01:00
Jonas Kulla c33144552a Config: Parse from command line options on top of config file
Any options that are not arrays (ie. RTP paths) specified
as command line options will override entries in mkxp.conf.

The syntax is: --<option>=<value>
2014-01-10 20:16:34 +01:00
Jonas Kulla b8fc5e25b9 Audio: Make thread names more descriptive 2014-01-07 16:06:50 +01:00
Jonas Kulla 0a53a894dc Merge branch 'master' of github.com:Ancurio/mkxp 2014-01-07 05:26:05 +01:00
Jonas Kulla 063793c4d9 Turn screenshots (F3) off by default 2014-01-07 05:25:00 +01:00
Edward Rudd c60ffa6384 fix npos comparison check in baseName method 2014-01-06 12:45:01 -05:00
Jonas Kulla 953f903149 Spacing 2014-01-05 16:09:00 +01:00
Jonas Kulla e9cf77dbce Config: Fix preceeding '/' in deducted game title
Also factor out the common code path
2014-01-05 10:31:15 +01:00
Jonas Kulla 19dc83a5d5 Bitmap: Supply image filename on loading error 2014-01-05 10:28:35 +01:00
Jonas Kulla 8ed6de22a4 Input: Return const -20 mouse position when outside window 2014-01-05 01:15:33 +01:00
Edward Rudd 318162a229 fix screen grab crash when in fullscreen
- read the FBO size NOT the screen size.
2014-01-04 13:52:11 +01:00
Jonas Kulla 56b49acf39 Spacing 2014-01-04 13:50:07 +01:00
Jonas Kulla 43321b8ed7 Coding style fixes 2014-01-04 13:49:32 +01:00
Jonas Kulla 092e6ad948 Typo 2014-01-04 13:48:23 +01:00
Jonas Kulla d93c1280aa Font: Open TTF font as late as possible
This reduces opened fonts that were never going
to be used anyway.
2014-01-04 13:47:00 +01:00
Jonas Kulla 857693d4a1 Font: Fix 'Font#set_name' not actually changing underlying TTF_Font 2014-01-04 13:00:38 +01:00
Jonas Kulla 78f9272e3d Typo 2014-01-04 13:00:04 +01:00
Jonas Kulla c9423164d4 Font: Adhere to spec and set Font.default_name to "MS PGothic" 2014-01-04 12:58:03 +01:00
Jonas Kulla a8bff666eb Audio: Don't try to fill and queue null buffer
Fixes skipping audio after interrupting and resuming
the program via eg. a debugger.
2014-01-04 12:28:16 +01:00
Jonas Kulla 3daf805350 Table: Serialize actual table dimensions instead of '3'
This allows savegames created with mkxp to be read with RMXP.
2014-01-02 03:39:22 +01:00
Jonas Kulla 5f16eef273 EventThread: Properly allocate SDL user event codes 2014-01-02 02:22:10 +01:00
Jonas Kulla 0a336ea315 Spacing 2014-01-02 00:17:31 +01:00
Jonas Kulla a0a27889a3 Merge #8 2014-01-02 00:11:57 +01:00
Edward Rudd 5b4f0b239c add config option to set the window icon 2014-01-01 16:52:07 -05:00
Edward Rudd a740f7754c add option to choose whether left alt or both alts toggle's fullscreen 2014-01-01 15:56:38 -05:00
Edward Rudd c6bd61d2de code style fixes 2014-01-01 11:01:05 -05:00
Jonas Kulla 1bacceddf0 Spacing 2014-01-01 12:59:40 +01:00
Jonas Kulla ce7bf97dd4 FileSystem: Make path caching optional via config
Because Windows has case insensitive paths, this should
be turned on (which it is by default) for maximum
compatibility. Can be turned off as an optimization
(this will speed up startup a little depending on the
number of game assets).
2014-01-01 07:13:35 +01:00
Edward Rudd a18497ca7b change to exe dir on startup and add some extra guards around boost program option parsing. 2013-12-31 21:03:53 -05:00
Jonas Kulla 3f08b6b3db Remove dead code 2014-01-01 02:13:02 +01:00
Edward Rudd e87bdb8a95 cleaner approach to handling the viewport bug 2013-12-31 19:56:20 -05:00
Edward Rudd f42539e02b accept any alt for fullscreen switch 2013-12-31 19:31:29 -05:00
Edward Rudd 1120c60cae fix viewport resizing on screen resize. 2013-12-31 19:31:14 -05:00
Edward Rudd f8e8d704b5 use copy construction to pass the config along so the main constructor gets run once. 2013-12-31 17:23:15 -05:00
Edward Rudd f2bb0b2e79 initialize gameFolder to be SDL_GetBasePath() 2013-12-31 17:19:05 -05:00
Edward Rudd 7aa07630e4 can't sizeof an iVar in a static function 2013-12-31 16:32:12 -05:00
Edward Rudd af70e8c1ff correct ScanRow forward declares 2013-12-31 16:31:24 -05:00
Edward Rudd eacc143ea0 update extension usage..
nearly all of the previous required extensions are CORE in OpenGL 2.0
the remaining ones need to have fallback checks for ARB vs EXT vs APPLE 
variants..
2013-12-31 16:31:03 -05:00
Edward Rudd 27ae261d0e don't use base name it's destructive to the incoming string which you shouldn't modify as c_str() is const. 2013-12-31 16:27:28 -05:00
Jonas Kulla f2d2a1886f Shader: Throw on compile/link error, and print info logs
Also let go of the startup debug prints when compiling.
The engine will now tell us properly which shader fails
at which part.
2013-12-30 01:38:47 +01:00
Jonas Kulla 680e407a38 SharedState: Throw exception on errors (and handle them)
First up: throw if chdir(gameFolder) fails.
2013-12-30 01:37:55 +01:00
Jonas Kulla 9759e52b3c Exception: Constructor now takes printf style arguments 2013-12-29 18:05:11 +01:00
Jonas Kulla d8e22a8b3c Remove unused definition 2013-12-29 14:36:32 +01:00
Jonas Kulla 2adf8ab265 Transition from QtCore to stdc++ / STL / boost
This looks like a pretty major change, but in reality,
80% of it is just renames of types and corresponding
methods.

The config parsing code has been completely replaced
with a boost::program_options based version. This
means that the config file format slightly changed
(checkout the updated README).

I still expect there to be bugs / unforseen events.
Those should be fixed in follow up commits.

Also, finally reverted back to using pkg-config to
locate and link libruby. Yay for less hacks!
2013-12-29 13:59:26 +01:00
Jonas Kulla 01529c5741 Audio: Fix stream not being unlocked on exception 2013-12-28 23:10:43 +01:00
Jonas Kulla 99866fb84c Replace QStack with std::stack 2013-12-27 20:10:01 +01:00
Jonas Kulla 922a16a013 TexPool: Fix wrong total memory consumption calculation
The byte count of textures released into the pool was
erroneously added twice to the total byte count.
2013-12-27 18:46:04 +01:00
Jonas Kulla fbf02cf2ce Remove Qt style forloop 2013-12-27 06:19:30 +01:00
Jonas Kulla f3def32461 Constify 2013-12-27 06:11:18 +01:00
Jonas Kulla 231e38ae8e Replace QVector, QList with std::vector, std::list
An exception is made of TexPool, which will need a
bit more testing before transitioning to std containers.

Also replace 'int' with 'size_t' where it is used only
as an array index.
2013-12-26 20:18:33 +01:00
Jonas Kulla 8215bc7e7d Remove useless lines 2013-12-26 15:00:03 +01:00
Jonas Kulla 19bb6c924e Gaphics: Make frame skip a config option
When using something like Valgrind that will run
mkxp 20 times slower than normal, frame skip will
make the redraw loop completely grind to a halt.
Set 'frameSkip' to false in the config to
avert this.
2013-12-21 21:18:20 +01:00
Jonas Kulla cb36a28b09 Add a very crude screenshot function (press F3)
Files are named after the current date+time (down to seconds),
and written to the gameFolder directory.
2013-12-20 09:17:15 +01:00
Jonas Kulla 99cbb4d594 FileSystem: Remove useless code 2013-12-20 07:38:29 +01:00
Jonas Kulla f1df97551c FileSystem: Add "otf" to recognized font extensions 2013-12-15 10:19:22 +01:00
Jonas Kulla 5f290c5b11 Audio: Prevent div-by-zero 2013-12-15 10:12:44 +01:00
Jonas Kulla 8161b00804 Remove unneeded include 2013-12-11 23:52:20 +01:00
Jonas Kulla 3b8484a280 Audio: Silence "unused" errors with latest libvorbisfile 2013-12-11 21:08:40 +01:00
Jonas Kulla 1f2470deb7 Graphics: Fix some RGSS2 bitrot 2013-12-11 21:07:41 +01:00
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