Commit graph

866 commits

Author SHA1 Message Date
Clownacy
c4599bc146 Allow third-party in-source files to go in the external folder 2019-08-10 22:47:40 +01:00
Clownacy
cdbcd5f6c3 Added a local copy of GLEW 2019-08-10 21:47:06 +01:00
Clownacy
85f58d7d39 Rendering backend API naming improvements 2019-08-10 19:50:10 +01:00
Clownacy
2b86db32a0 Backend_Blit always uses a colour key 2019-08-10 19:31:45 +01:00
Clownacy
64f2a78279 OpenGL: Remove SetFramebufferTarget
It's causing state conflicts in the enhanced branch. Also, with the
new vertex batching, state changes are minimised, so this function
is redundant.
2019-08-10 19:23:29 +01:00
Clownacy
fc0653e5aa Back to OpenGL 3.2 (I really want the core profile)
In OpenGL 3.1, compatibility mode was an extension, meaning it could
never actually be disabled. 3.2 fixed that with the introduction of
profiles.
2019-08-10 18:05:01 +01:00
Clownacy
3b20c5f3b8 Implement vertex batching in the OpenGL renderer
Finally, the performance issue is fixed. I can move back up to OpenGL
3.2 now, and reenable the core profile.
2019-08-10 18:01:48 +01:00
Clownacy
d5ceed4f97 Some minor OpenGL cleanup 2019-08-09 20:04:46 +01:00
Clownacy
7146288e94 Sod it, fall back on compatibility mode if it's available
This way, I can use immediate mode, which is way faster than using
buffers for some reason. Since I'm not using profiles anymore, I
dropped the minimum requirement to OpenGL 3.1. If a driver doesn't
support Legacy GL, then it can use the slow buffer code.

But seriously, I need to figure out why using buffers is so slow.
If this was a common problem, Modern OpenGL wouldn't have made it the
only option.
2019-08-09 19:19:43 +01:00
Clownacy
4afe7f4b11 Use orphaning to slightly speed up rendering GPU-side
For some reason CPU usage is still double that of the SDLTexture
backend (SDL2 uses OpenGL 2.1, with glEnable/glDisable-style
immediate mode).

If I downgrade to OpenGL 2.1, and use VBO-less glDrawArrays, I get
great performance. I just wish I knew what the AMD driver is doing
that's so much faster.
2019-08-09 16:25:36 +01:00
Clownacy
5712c4ad63 Use an appropriate usage specifier for glBufferData
Turns out DYNAMIC was so horribly wrong that it slaughtered the GPU
performance.
2019-08-09 15:58:58 +01:00
Clownacy
b1a706c312 Call glFramebufferTexture2D as rarely as possible
Turns out performance is absolutely abysmal on my laptop's copy of
Windows 10 (AMD A9 APU).

This is only one of the weird bottleecks: glFramebufferTexture2D
is a CPU sinkhole, so don't call it often.
2019-08-09 15:55:42 +01:00
Clownacy
ac273d2d7c Make the ShiftJIS->Unicode translation table *slightly* less ugly 2019-08-08 05:22:24 +00:00
Clownacy
8acd46bce6 Move the font gamma-correction up to Font.cpp
Reduces duplicate code
2019-08-08 05:04:08 +00:00
Clownacy
7e926451de Optimise the gamma-correction
I should probably create a Common.cpp file or something
2019-08-08 02:59:02 +00:00
Clownacy
fc102cd5a5 Add subpixel font rendering to the OpenGL backend
Finally, something besides the software renderer supports it
2019-08-07 22:33:13 +00:00
Clownacy
7e04741c29 Correct the rendering backend glyph API, and add a missing #include
For some reason, FT_BITMAP's 'width' member specifies subpixels,
not pixels as the documentation says.
2019-08-07 22:31:45 +00:00
Clownacy
b56a49a1d5 Reapply SDL2 modifications
The prevents Windows builds from leaking SDL2's exports
2019-08-01 13:37:12 +00:00
Clownacy
ff61c099df Updated SDL2 to 2.0.10
Will reapply my modifications in the next commit
2019-08-01 13:36:19 +00:00
Clownacy
6a040c2248 Add missing #includes to rendering backends 2019-08-01 13:32:27 +00:00
Clownacy
6d8c5c1d75 Updated local copy of Freetype to 2.10.1 2019-08-01 13:29:28 +00:00
Clownacy
d8aec418f9 OpenGL: Use a struct for defining 2D coordinates
Makes the code a bit more readable
2019-08-01 13:11:55 +00:00
Clownacy
67b3143ed6 OpenGL: Only enable blending for glyphs
Should improve performance
2019-08-01 01:26:04 +00:00
Clownacy
cf94736cbf OpenGL: Free VAO and VBO 2019-08-01 00:38:23 +00:00
Clownacy
d8d971c459 Added another bugfix 2019-08-01 00:34:35 +00:00
Clownacy
f0c062cdc8 OpenGL: Clamp textures
This fixes this weird thing you'd see in the enhanced branch if the
screen is scaled (happens if you resize the window).

When the screen is scaled, OpenGL uses linear interpolation. This
would cause it to fetch samples from outside the texture. IIRC, by
default, the default behaviour is GL_REPEAT, which causes it to blend
with samples from the other side of the texture, creating strange
pixels at the end of the screen.
2019-08-01 00:08:23 +00:00
Clownacy
706aff0c8c Remove more redundant OpenGL code 2019-07-31 23:43:08 +00:00
Clownacy
607bbfcef8 Remove some debug prints
I prefer to only print on error
2019-07-31 23:12:06 +00:00
Clownacy
90ffbacd29 Put OpenGL in 'forward-compatible' mode
Disables deprecated functionality
2019-07-31 23:07:45 +00:00
Clownacy
4769397c7a Clean up OpenGL error callback print 2019-07-31 23:03:32 +00:00
Clownacy
24dcd35522 More OpenGL cleanup and tweaks 2019-07-31 23:01:14 +00:00
Clownacy
ff5a0189e0 OpenGL: Ditch index buffer
Seems completely unnecessary for 2D
2019-07-31 22:50:14 +00:00
Clownacy
350ba46f2e Some OpenGL cleanup 2019-07-31 22:48:37 +00:00
Clownacy
eb62a80956 Change references to OpenGL 2.1 to 3.2 2019-07-31 22:38:33 +00:00
Clownacy
4c024b540f Migrated OpenGL backend to OpenGL 3.2
Goddammit 3.2 is so complex.

The reason I want 3.2 is because I'm not convinced Legacy OpenGL will
be well-supported in the future. 3.2 is about as far back as I can go
without breaking forward-compatibility (it was the first version to
introduce the Core Profile).
2019-07-31 22:33:22 +00:00
Clownacy
2c9531062b Move away from Legacy OpenGL shader variables 2019-07-31 21:00:07 +00:00
Clownacy
e447c9fb92 Missed some matrix code 2019-07-31 06:36:13 +00:00
Clownacy
74c29dbe3c Disable texture coordinates entirely when colour-filling 2019-07-31 06:35:32 +00:00
Clownacy
106827c2ee No more Legacy OpenGL ModelView matrix
I'd replace it with a custom matrix, but I get the feeling the
overhead of uploading a 4x4 matrix every quad is higher than just
manipulating the vertexes CPU-side
2019-07-31 05:49:39 +00:00
Clownacy
bd731321f2 Use triangle fans instead of quads
Quads are Legacy OpenGL
2019-07-31 04:54:22 +00:00
Clownacy
eab2a80ae5 Remove some vestigal matrix code 2019-07-31 04:52:31 +00:00
Clownacy
42765792bc Shut up some warnings 2019-07-31 04:41:46 +00:00
Clownacy
3973419cef Fix Makefile when building SDLSurface backend 2019-07-31 03:51:18 +00:00
Clownacy
a5fd0cebc0 Use specialised shaders for everything
Saves us having to do a bunch of extra legwork (setting up the blank
default texture, setting the colour modifier to white, etc.), and
should improve performance.

While I was at it, I made the colour modifier a uniform, so it only
has to be set once per quad, rather than once per vertex.
2019-07-31 03:39:30 +00:00
Clownacy
d9929a8e1f This shouldn't be needed anymore 2019-07-31 03:04:32 +00:00
Clownacy
92476bd30a Made the OpenGL 2.1 backend use custom shaders
Edging towards OpenGL 3.
2019-07-31 03:00:56 +00:00
Clownacy
f0809fb901 Change colour_buffer assignments 2019-07-31 02:57:11 +00:00
Clownacy
9cc1a5a098 Change colour_buffer to unsigned bytes instead of floats 2019-07-31 02:55:22 +00:00
Clownacy
64f7a2eae3 Use GL_LUMINANCE_ALPHA instead of GL_ALPHA
GL_ALPHA sets the RGB values to 0.0, but I want them set to 1.0
2019-07-31 02:52:43 +00:00
Clownacy
348a691c6c GLU is unneeded 2019-07-31 02:49:07 +00:00