Commit graph

615 commits

Author SHA1 Message Date
Clownacy
5c1012aa8e Fix upscaled framebuffer skipping
Skipping it an 1x is wrong: it should only be skipped if the window
is an integer multiple of the framebuffer size
2020-09-18 21:21:28 +01:00
Clownacy
4763aecdbd Correct Lanczos array initialisation
I must have forgotten that Lanczos reads backwards too
2020-09-18 00:59:05 +01:00
Clownacy
83e8320d84 Fix other renderers 2020-09-17 18:26:32 +01:00
Clownacy
5c6b71e3a1 Optimise a little when using OpenGL3 2020-09-17 18:22:44 +01:00
Clownacy
b8ceefcefd Flexible OpenGL unpack alignment 2020-09-17 18:05:38 +01:00
Clownacy
86d084f750 Get OpenGL renderers working again 2020-09-17 17:39:02 +01:00
Clownacy
fe76fe6dea Big scary messy unfinished font overhaul
This is currently hardcoded to 640x480 English builds.

What I've done is temporarily gutted the FreeType2 font renderer, and
instead introduced a system where the font is read from a
pre-rendered font atlas. This allows me to get 100% accurate font
rendering to Windows XP... because I literally created these atlases
with Windows XP.

So not only does this eliminate the issue of FreeType producing
misshapen glyphs, but it also works around the copyright issue
regarding bundling the Courier New and MS Gothic fonts with CSE2.

You see, font files can be copyrighted like any old software, however
typefaces have a lot less protection - they're basically fair-game.
IANAL, of course - look it up yourself.

I don't really want to throw away the FreeType font system since I
spent a ton of time working on it, it allows you to use other font
files, and I'll probably wind up needing it for CSE2EX. I guess I'll
just have to find some way to either have the two systems coexist, or
make it so one or the other can be selected at compile-time.
2020-09-17 15:02:36 +01:00
Clownacy
08b14fa03f Don't use upscaled framebufer if it's not needed
This matches the SDLTexture backend.

Again, it would be really nice if this code weren't duplicated.
2020-09-15 22:16:05 +01:00
Clownacy
97d5373fa5 Add smooth upscaling to the OpenGL backends
Bleh, this is kind of messy and ugly. I also don't like how much
duplicate code there is from the SDLTexture backend.
2020-09-15 22:05:58 +01:00
Clownacy
fd82adf099 Remove invalid comment 2020-09-15 21:00:27 +01:00
Clownacy
13ce62ae05 Minor cleanup 2020-09-15 20:51:04 +01:00
Clownacy
52c2a5ceee Make software renderer a bit more foolproof
This also eliminates some comparisons with mismatching signedness
2020-09-15 20:48:18 +01:00
Clownacy
11bbad7372 Cleanup
Now RenderBackend_DrawGlyph doesn't pass an unnecessary parameter
2020-09-15 19:40:10 +01:00
Clownacy
392d5898a3 Make GetVertexBufferSlot consistent
It would be nice keep this batching stuff in a common file
somewhere...
2020-09-15 16:28:35 +01:00
Clownacy
e2b64df84a Oops, also offload colour-fill vertices as well 2020-09-15 16:18:48 +01:00
Clownacy
0f5af36951 Offload vertex transformation to the GPU 2020-09-15 16:08:56 +01:00
Clownacy
07e4e3b971 Offload texture coord transformation to GPU
I imagine this isn't too helpful when the GPU is the bottleneck, like
on my Raspberry Pi.
2020-09-15 14:21:58 +01:00
Clownacy
f0e1119a91 Move OpenGL shader stuff to a struct
The uniform naming scheme was already emulating this
2020-09-15 14:13:45 +01:00
Clownacy
6b96ada4a8 Use proper OpenGL buffer access specifier
The previous value was inherited from the old pre-batching code,
where it actually made sense.
2020-09-15 00:48:14 +01:00
Clownacy
611afe7417 Remove those annoying renderer sanity checks
Duplicate junk. If they're that important, they can go in the game,
not the backends.
2020-09-14 23:55:39 +01:00
Clownacy
27b3980a56 Flush Wii U vertex buffers when stuff happens
You know, this 50-character commit name limit is really annoying.
2020-09-14 23:47:52 +01:00
Clownacy
e96ee6ed89 Don't leave dangling OpenGL texture IDs 2020-09-14 23:43:18 +01:00
Clownacy
2bcab6adee Change software renderer sub-backend API
No more locking
2020-09-14 23:26:55 +01:00
Clownacy
30ea89d3fa Remove some now-unneeded struct members 2020-09-14 23:17:21 +01:00
Clownacy
e18ec87f99 Update Wii U renderer 2020-09-14 23:16:45 +01:00
Clownacy
98f66444d7 Updated OpenGL renderers 2020-09-14 23:12:18 +01:00
Clownacy
f55c965a70 Update SDLTexture backend 2020-09-14 23:09:55 +01:00
Clownacy
37a1518056 Update SDLSurface renderer 2020-09-14 23:06:42 +01:00
Clownacy
6b18ec91be Replace LockSurface with UploadSurface
The old locking/unlocking API was plain inefficient. Soon I'll move
upscaling to the backend anyway, to minimise the overhead where
possible.

Currently only the software renderer has been updated.
2020-09-14 23:03:23 +01:00
Clownacy
95f370a720 Integer-only ratio logic 2020-09-14 16:31:54 +01:00
Clownacy
afed830366 Only mark render-target textures as lost
SDL2 only loses target textures.
2020-09-14 12:49:34 +01:00
Clownacy
05b8b607fa Correct outdated comment 2020-09-14 12:26:56 +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
0cdd6ad4df Rename a rect 2020-09-14 10:44:54 +01:00
Clownacy
2d5f6a547d Disable blending for the framebuffer 2020-09-14 10:42:31 +01:00
Clownacy
5e28463509 Remember to free the upscaled framebuffer 2020-09-14 10:39:16 +01:00
Clownacy
56b96ed432 Only use an upscaled framebuffer if we have to 2020-09-14 10:36:35 +01:00
Clownacy
53e96486ce Use proper texture access type 2020-09-13 19:50:47 +01:00
Clownacy
2f748810bf Disable blending for the upscaled framebuffer
I'd set it to RGB24 instead of RGBA32, but I don't know if there'd be
a performance penalty.
2020-09-13 19:41:19 +01:00
Clownacy
4517c9be9e Fix incorrect upscaled framebuffer size 2020-09-13 19:37:01 +01:00
Clownacy
c12149b96e Fix a weird old typo 2020-09-13 19:35:31 +01:00
Clownacy
7bc028f5d8 Enable window-resizing in the SDLTexture renderer
Previously, the window was a fixed size just like the original.

This change highlights a weird issue in CSE2: this doesn't exactly
match the behaviour of the original game, so why did I change it?
Simple: monitors had much lower pixel-densities back in the early
2000s, meaning that 320x240 and 640x480 weren't as laughably small as
they are today.

I like to think of CSE2's portable branch as Cave Story's equivalent
to Chocolate Doom: the point isn't to replicate the game's behaviour
100% - that's the accurate branch's job - no, the point of the
portable branch is to replicate the *experience* of the game, as it
was back in 2004. This means no commically-small windows.

This is the same reason font anti-aliasing is disabled, even in
versions of Windows later than XP.

Sidenote: the OpenGL3/OpenGLES2 renderers already had this feature,
but they used linear-filtering, causing the screen to be extremely
blurry in 320x240 mode. This renderer uses a better method, which
does apply slight blurring at the edges of pixels at resolutions
that aren't an exact multiple of 320x240/640x480, but otherwise it
resembles nearest-neighbour. This is way nicer to look at, and fits
the game's aesthetic. This feature will be ported to the other
renderers soon.
2020-09-13 18:17:58 +01:00
Clownacy
aa3cd55b43 Fix SDLTexture surface freeing 2020-09-13 12:30:56 +01:00
Clownacy
a6408b330f Fix build error 2020-09-11 23:10:47 +01:00
Clownacy
a37e1d31f2 Remove extra newline 2020-09-11 13:06:52 +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
b065882f24 More size_t 2020-09-10 17:42:18 +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