Commit graph

121 commits

Author SHA1 Message Date
Clownacy
98f66444d7 Updated OpenGL renderers 2020-09-14 23:12:18 +01:00
Clownacy
63e4ac9aa9 Remove RenderBackend_FlushGlyphs
No longer used for anything
2020-09-14 12:25:39 +01:00
Clownacy
daa55b1a3c Allow font atlases to be non-square
Saves a little memory in some cases. It's the backend's job to decide
if this is a problem or not, and pad it if it has to.
2020-09-14 12:08:27 +01:00
Clownacy
a6408b330f Fix build error 2020-09-11 23:10:47 +01:00
Clownacy
69f3fbcd5a Change a dumb parameter 2020-09-10 17:56:22 +01:00
Clownacy
0fa538732d Use PrintError instead of ShowMessageBox 2020-09-10 17:48:21 +01:00
Clownacy
988f1128dd Convert a bunch of ints to size_t
ints are dumb - only use them when you have to
2020-09-10 17:36:21 +01:00
Clownacy
07f70200d0 Renderer cleanup 2020-09-08 12:48:25 +01:00
Clownacy
23156d38de Optimise OpenGL renderer a little 2020-09-08 01:55:57 +01:00
Clownacy
1d9446d425 Update SDLSurface renderer for new font batcher 2020-09-07 23:44:51 +01:00
Clownacy
096fa3b578 New custom font batcher
Previously, the font batching system was very shoddy: basically,
glyph bitmaps would be cached to system memory, and uploaded
on-demand to the GPU.

The OpenGL3, OpenGLES2, and SDLTexture backends relied on
`cute_spritebatch.h` to handle batching. While nice, this library is
overkill: it's intended for managing a whole game, not just a couple
of glyphs. It also depends on C++11, which is something I'd rather be
without.

Being so complex, it appears that internally it spams the backend
when merging atlases together. According to bug reports, this causes
the game to skip a lot of frames.

Instead, I've ditched the system-memory-side caching, and made the
game maintain its own atlas. Unlike `cute_spritebatch.h`, this one
doesn't purge glyphs after they've gone unused for 30(?) seconds -
instead, glyphs are only purged when room in the atlas runs out, at
which point the oldest glyph is replaced. This method doesn't involve
creating or destroying atlases at runtime, avoiding the overhead of
whatever OpenGL/DirectX do internally when that happens.

Currently only the OpenGL3, OpenGLES2, and Software renderers have
been updated with this - the others will fail to build.

I know immediate-mode renderers won't benefit from this, but it
replaces the leaky old caching system, so it's still an improvement.
2020-09-07 23:11:01 +01:00
Clownacy
1582af91cf Replace more float logic with integer-only
I hate floats >:(
2020-07-09 01:09:19 +01:00
Gabriel Ravier
32c8795ead src: Cleaned up includes to only (and always) include what we use
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-07-01 18:26:22 +02:00
Clownacy
93535c5501 Sync OpenGL3 renderer with Wii U renderer 2020-06-29 18:36:38 +01:00
Clownacy
c7bd79e13f Comment style tweaks 2020-06-29 15:25:01 +01:00
Clownacy
5596c33b38 Fix stuff
Looks like the Null backend's been broken for a while though
2020-05-06 23:10:40 +01:00
Clownacy
a8d0595bcd Update other backends to current API
The only other backend besides the Wii U one to use `render_target`
is the SDLTexture one.
2020-04-23 14:38:45 +01:00
Clownacy
b4d9b15a9c Add a TODO 2020-04-21 15:23:20 +01:00
Clownacy
ff9c2dc4fc Remove now-unneeded sanity checks 2020-04-21 14:57:05 +01:00
Clownacy
c51a074fad Big disgusting backend rework
We need to avoid `WindowsWrapper.h` in the backends whenever we can,
to avoid name collisions (the Wii U homebrew library) defines its own
BOOL/TRUE/FALSE, which really doesn't work with CSE2.
2020-04-13 18:19:39 +01:00
Clownacy
8fbf3bbecf Account for GetVertexBufferSlot failure 2020-04-13 13:40:35 +01:00
Clownacy
4f7cc9582d Revert "Backends: Added init/de-init messages for backends"
This reverts commit 9be8b9a493.
2020-04-13 13:28:57 +01:00
Gabriel Ravier
9be8b9a493 Backends: Added init/de-init messages for backends
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 02:26:51 +02:00
Gabriel Ravier
65e7164c42 Backends/Rendering/OpenGL3: Use != NULL instead of implicit conversion to bool
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:59:02 +02:00
Gabriel Ravier
4d10c2cc21 Backends/Rendering/OpenGL3: Wrap both sides of if-else with {} equally.
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:58:09 +02:00
Gabriel Ravier
1a5da443d7 Backends/Rendering/OpenGL3: Fixed OpenGLES2 compile
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:55:12 +02:00
Gabriel Ravier
89fb2222b6 Backends/Rendering/OpenGL: Replaced printf with Backend_PrintInfo
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:46:05 +02:00
Gabriel Ravier
dcd4bcf1b2 Backends: Fix some of the error handling and replaced some printf calls
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 00:42:24 +02:00
Gabriel Ravier
f2b2c071a2 Backends/Rendering/OpenGL3: Improve error handling
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-11 23:28:31 +02:00
Clownacy
ba069de70e Fix window resizing
If you made the window square, the screen wouldn't be centered
properly.
2020-04-10 00:45:57 +01:00
Clownacy
135035bb1a Change 'PlatformBackend' namespace to 'Backend' 2020-04-04 20:31:27 +01:00
Clownacy
4d322be866 Change render backend namespace to RenderBackend_ 2020-04-04 20:24:34 +01:00
Clownacy
40464a9fc0 Move-around Backend files
Hoping to introduce some degree of grouping
2020-04-03 14:42:11 +01:00
Clownacy
ee7cf6799b Yet another warning 2020-04-03 02:12:06 +01:00
Clownacy
5b996b3459 Give glad a CMake file
Today I learned that CMake will error if the project shares a
dependency with a nested CMake file (which could be from an
entirely-separate project that you have no control over).

I'm starting to really hate CMake.
2020-04-03 01:34:47 +01:00
Clownacy
ff70664604 Cleanup and fixes 2020-04-01 16:11:34 +01:00
Clownacy
4d8be3bc36 More refactoring
Get fullscreen mostly working in GLFW3
2020-04-01 15:21:40 +01:00
Clownacy
c4aa8e28bb More refactoring 2020-04-01 14:57:07 +01:00
Clownacy
5dbca99e19 Extremely horrible terrible nightmare refactoring
Working on ridding CSE2 of its hard SDL2 dependency.

For now, I have a rudimentary GLFW3 backend.
2020-03-31 21:56:10 +01:00
Clownacy
142bca6578 Split SDL2 code from Draw.cpp 2020-03-31 16:11:31 +01:00
Clownacy
d0b20316de Don't do -Iexternal
It pollutes the #include space.
2020-03-31 14:26:24 +01:00
Clownacy
61e708751d Apply missing OpenGL constants 2020-03-31 12:53:58 +01:00
Clownacy
60d3cc2ed6 Update cute_spritebatch.h 2020-02-09 12:40:35 +00:00
Clownacy
8edca4fb2e Style tweak 2020-02-09 12:35:38 +00:00
Clownacy
59a8c2617f Tweak some variable naming
The enhanced branch calls them the 'internal *screen* width/height',
which I think is more appropriate.
2020-02-05 15:52:43 +00:00
Clownacy
2af6a043ef Clean-up the OpenGL renderers a little 2020-02-04 16:35:42 +00:00
Clownacy
1140ab0916 Clean-up renderer backend initialisation 2020-02-04 15:51:19 +00:00
Clownacy
ba6d711d3a Tick cute_spritebatch once per frame
...As opposed to once per draw call.

This change was made because multiple draw calls can be made per
frame, or a only a handful of draw calls may be made per minute.

Since draw calls are an inconsistent metric, I just switched to
frames instead.
2020-02-04 14:57:06 +00:00
Clownacy
2e5e1994c2 Enable debug console prints in non-debug builds 2020-02-03 16:44:52 +00:00
Clownacy
53c0e8470f Add an optimisation to the OpenGL renderers
Since we track the currently-bound "source texture", we don't need
to poll the OpenGL driver for the same info.
2020-02-03 15:53:59 +00:00