Commit graph

865 commits

Author SHA1 Message Date
Clownacy
0b874153d4 Free the string returned by SDL_GetBasePath
Thanks, Fayti1703.
2019-07-29 14:33:14 +00:00
Clownacy
2d73fd8bb9 Use GLEW to check if OpenGL 2.1 is supported 2019-07-27 03:42:51 +00:00
Clownacy
0abac07aab Note the new dependency on GLEW
I wonder if I could use SDL2's SDL_GL_GetProcAddress,
SDL_GL_ExtensionSupported, and SDL_GL_LoadLibrary functions to bypass
needing GLEW? Then again, I'd like to remove the dependency on SDL2
at some point as well...
2019-07-27 03:36:35 +00:00
Clownacy
aa728979a3 Fix the Texture backend not rendering text the accurate buggy way
A shame I have to fall back on the Surface fallback. Speaking of, I
really need to replace that fallback with my software renderer.
2019-07-25 00:39:03 +01:00
Clownacy
defe234ff2 Clean up some ugly formatting 2019-07-25 00:09:10 +01:00
Clownacy
145864cf2d Added sanity checks to the backends
This fixes the Texture backend bug that made the program take forever
to shut down:

The problem was that the font system would try to load a glyph that's
0 pixels wide/tall (likely the space character), which SDL2 didn't
like, so it would fail to allocate the texture, causing
Backend_CreateSurface, and by extension Backend_CreateGlyph, to
return a NULL. Later, upon shutdown, the font system would pass this
NULL to Backend_FreeGlyph, causing NULL pointer dereferences that
make the program take forever to shut down.

Personally, I think passing NULLs to the backend is valid behaviour,
so I've added a bunch of sanity checks to make sure they're never
dereferenced.
2019-07-24 23:34:16 +01:00
Clownacy
679c6d0391 More efficient OpenGL font loading 2019-07-24 22:21:39 +01:00
Clownacy
d6888040a2 Backport some OpenGL 2.1 fixes 2019-07-24 22:08:37 +01:00
Clownacy
9948fa8b07 Move the SDL_Window creation to the rendering backends
Whoops, didn't mean to commit the Main.cpp edit way back when I made
the OpenGL 2.1 backend.
2019-07-24 20:20:06 +01:00
Clownacy
b998719ff1 Update CMakeLists.txt, the Makefile, and the readme 2019-07-24 20:09:27 +01:00
Clownacy
7bbc0321cd Backport OpenGL2 fixes from the enhanced branch 2019-07-24 20:00:50 +01:00
Clownacy
b2244f17fc Dumb indent 2019-07-23 23:15:44 +01:00
Clownacy
0ce05e1837 Move a function 2019-07-23 23:13:57 +01:00
Clownacy
e170485849 Document a "bug" in the SDL_Texture backend 2019-07-23 23:11:24 +01:00
Clownacy
d3129bc4bc Font refactor part 5: Sigil (optimised software renderer) 2019-07-23 21:49:40 +01:00
Clownacy
8aad8a6628 Font refactor part 4: Thy Flesh Co- I mean, OpenGL
Hard mode. Wound up debugging a weird issue for about half an hour.
Turns out you don't need to reset the matrix when you switch
framebuffer target? I don't really know how that works.

Anyway, yay font rendering is in the OpenGL backend now.
2019-07-23 21:49:40 +01:00
Clownacy
e2054918a6 Font refactor part 3: SDL_Texture
Getting kinda messy, having to maintain two different ways of
drawing - colour-key and alpha-blending. In the enhanced branch,
which uses alpha-blending for everything, these can be merged.

I'm noticing a huge delay in shutdown time. There's probably a bug
in here.
2019-07-23 21:49:40 +01:00
Clownacy
6a7fd14833 Font refactor part 2: SDL_Surface
No per-component alpha support here
2019-07-23 17:20:56 +01:00
Clownacy
6d385e674f Font refactor part 1: Software
With this, font blitting is handled by the rendering backend, paving
the way for hardware-accelerated font drawing in the accelerated
backends.
2019-07-23 16:38:04 +01:00
Clownacy
90f29377fe Apply some surface ID constants 2019-07-23 15:20:13 +01:00
Clownacy
05f382961d Added OpenGL 2.1 renderer
Yay 100% hardware-acceleration. Yes, I know 2.1 is outdated and
crappy, but it was the easiest one to write. I'll probably make an
OpenGL 3.0 Core renderer at some point.

Anyway, font rendering isn't here yet, because I plan to overhaul it.
2019-07-23 15:20:14 +01:00
Clownacy
a3278a60b5 A fix, some documentation, and cleanup 2019-07-19 19:19:35 +01:00
Clownacy
24d104e2e8 Tweak in Font.cpp
MSVC2003 would complain about that code because it didn't understand
the C++ standard. It looked ugly anyway.
2019-07-19 09:02:17 +01:00
Clownacy
74c9931ebb Change the renderer backend API for uploading pixels
Also fix some blatant build errors. I must be going mad - I swear
I've fixed that typedef thing like twice already.
2019-07-19 08:45:59 +01:00
Clownacy
2fe0c44971 Fix readme derp
Thanks, Fayti1703
2019-07-17 16:40:18 +01:00
Clownacy
f1e6103a46 ...Actually add the SDL_Surface renderer file 2019-07-17 16:35:33 +01:00
Clownacy
44456e4a25 Add an SDL_Surface-based renderer
Ha, my custom software renderer is faster!
2019-07-17 16:09:18 +01:00
Clownacy
f21f17f4c2 Cleanup 2019-07-17 14:13:49 +01:00
Clownacy
36fdb4596d Cleanup and an accuracy improvement 2019-07-16 13:21:21 +01:00
Clownacy
6c7d49ad50 Added DoConfig to the Makefile 2019-07-16 12:25:22 +00:00
Clownacy
7c12e7817c Use SDL_ALPHA_OPAQUE 2019-07-16 00:37:31 +01:00
Clownacy
81eb438482 Fixes and tweaks 2019-07-16 00:15:20 +01:00
Clownacy
a679373c14 Disable font anti-aliasing when FIX_BUGS is enabled
It causes ugly artifacting around the text
2019-07-15 18:20:24 +00:00
Clownacy
9eaba52caf Actually fix the Makefile
Sorry, couldn't test the last commit because I was on a Windows
machine without MSYS2
2019-07-15 18:08:15 +00:00
Clownacy
8fb3f302a0 Got the Makefile working again, and updated the readme 2019-07-15 17:58:33 +01:00
Clownacy
6a4f4e0df3 Added handlers for render target loss/window resize
These only really happen when you use exclusive fullscreen and
alt-tab out. Or, at least, it does on Windows with SDL2 in DirectX
mode.
2019-07-15 17:47:22 +01:00
Clownacy
b84661d88a Move the backend files around a bit 2019-07-15 17:01:42 +01:00
Clownacy
15bfd00d25 Added hardware-accelerated rendering backend
Still need to add the code for surviving render target losses
2019-07-15 16:47:10 +01:00
Clownacy
21cf78b86d Split Draw.cpp into common code and backend code
Should be easy to add the new hardware renderer now
2019-07-15 13:42:49 +01:00
Clownacy
3ef9b67b1d Replaced a lot of Draw.cpp with a software renderer
Also fixed the SDL_Window not being freed. This commit's a bit of a
blob, since I made a bunch of tweaks to Draw.cpp while adding the new
renderer. Don't worry though, I'll add the hardware accelerated code
back again soon. In fact, I've got an idea on how to make it even
faster, while still being able to survive render target losses.

Hopefully this software renderer will come in handy for the Wii U
port: its SDL2 port's hardware acceleration is broken, and the
SDL_Surface API is too slow.
2019-07-15 11:41:40 +01:00
Clownacy
f9de3f8216 Added another bugfix
This was causing MSVC debug builds to raise a warning whenever a save
was loaded.
2019-07-12 13:09:08 +01:00
Clownacy
97acb292bb Made Game.cpp ASM-accurate
Working towards #74.
2019-06-30 03:03:25 +01:00
Clownacy
5167a341aa Made NpChar.cpp ASM-accurate
SetBulletObject has a commented-out if, it seems, and the leftover
braces affected the ASM.
2019-06-30 00:57:19 +01:00
Clownacy
c162d06f96 BossAlmo1.cpp extra accuracy
I forgot, the Linux debug data tells us the exact line number each
variable is declared on.
2019-06-30 00:30:30 +01:00
Clownacy
deb0538d03 Boss.cpp cleanup 2019-06-30 00:20:32 +01:00
Clownacy
a9940c9ca9 ArmsItem.cpp code cleanup and accuracy improvements 2019-06-29 23:29:44 +01:00
Clownacy
2c23de27d5 Made KeyControl.cpp ASM-accurate
Didn't realise this file was so tiny. Anyway, working towards #74.
2019-06-29 21:16:43 +01:00
Clownacy
729540d2b8 Fixed DoConfig
Turns out I never fixed the button order in the first place.
2019-06-28 18:51:28 +01:00
Clownacy
21d5ba34b0 Shut up some Clang warnings in the Enhanced branch
Once again SDL2 using plain ints everywhere causes issues.
2019-06-27 18:01:55 +00:00
Clownacy
26af89d5bb Merge branch 'master' of https://github.com/cuckydev/Cave-Story-Engine-2 2019-06-27 17:51:05 +00:00