Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL #468

Merged
merged 18 commits into from
Sep 30, 2024
Merged

OpenGL #468

merged 18 commits into from
Sep 30, 2024

Conversation

katajakasa
Copy link
Member

@katajakasa katajakasa commented Apr 22, 2023

WIP, do not merge.

Plan:

  1. Dump sprites to an RG8 texture atlas (R = color, G = alpha)
  2. Dump vertices and texture coords to a VBO
  3. Dump palettes and remappings to UBO(s) (or possibly consider 1D textures later for gotta go faster ?)
  4. Create an R8 texture and bind it to FBO, set FBO as target.
  5. Draw all objects. Shader should do any palette trickery now.
  6. Switch back to default FBO, and bind the previous render target texture.
  7. Ram the textuer through RGBA conversion with current palette.
  8. Run any upscaler shaders we want also (scalehqx, vhs, scanline, etc).
  9. Profit!

Notes:

  • Currently FBO size is 320x200, and we change the viewport to match that on fbo rendering phase. If/when we do sprite packs for larger sprites, we should bump the size. Perhaps some config option ?
  • When everything else works, consider using https://github.com/libretro/glsl-shaders for upscaling the result in rgba phase.

It might make sense to split the rendering into three, as the news caster guy wants images from arenas without the text and UI crap. So perhaps first render all game objects, then snatch any screenshots, and then draw the UI crap.

Cleanup TODO:

@katajakasa katajakasa force-pushed the ttv-use-opengl branch 5 times, most recently from 3667586 to fa3a964 Compare April 23, 2023 13:40
src/video/video.c Outdated Show resolved Hide resolved
@turol
Copy link

turol commented Apr 24, 2023

Prefer libepoxy over libglew. It supports GL ES too and starts up faster.

@katajakasa
Copy link
Member Author

Prefer libepoxy over libglew. It supports GL ES too and starts up faster.

Interesting, I will take a look. Glew is a total pain to maintain.

src/video/texture_atlas.c Outdated Show resolved Hide resolved
src/video/opengl/shaders.c Outdated Show resolved Hide resolved
@turol
Copy link

turol commented May 2, 2023

Reading from UBO with a varying offset might be a slow path. Use a texture instead. Either GL_TEXTURE_1D or a 2d texture with width or height of 1.

Using discard in shader is potentially a slow path. Prefer outputting fully transparent color instead.

@katajakasa katajakasa force-pushed the ttv-use-opengl branch 2 times, most recently from 02bb69f to 7ba8baf Compare May 2, 2023 15:13
@katajakasa
Copy link
Member Author

Reading from UBO with a varying offset might be a slow path. Use a texture instead. Either GL_TEXTURE_1D or a 2d texture with width or height of 1.

Using discard in shader is potentially a slow path. Prefer outputting fully transparent color instead.

Interesting. I added these on my future to-do list.

@turol
Copy link

turol commented May 3, 2023

@katajakasa
Copy link
Member Author

You probably want this: https://www.reddit.com/r/gamedev/comments/2j17wk/a_slightly_faster_bufferless_vertex_shader_trick/

Lol. On to the list it goes.

src/utils/io.c Show resolved Hide resolved
shaders/palette.frag Outdated Show resolved Hide resolved
shaders/palette.frag Outdated Show resolved Hide resolved
src/engine.c Show resolved Hide resolved
@katajakasa katajakasa force-pushed the ttv-use-opengl branch 2 times, most recently from fa126a3 to 2000aab Compare September 29, 2024 23:09
@Vagabond Vagabond force-pushed the ttv-use-opengl branch 2 times, most recently from dffcf41 to 3063a55 Compare September 30, 2024 00:46
@mrannanj mrannanj marked this pull request as ready for review September 30, 2024 22:50
@mrannanj mrannanj merged commit 49b386a into master Sep 30, 2024
7 checks passed
@katajakasa katajakasa deleted the ttv-use-opengl branch September 30, 2024 23:17
@katajakasa
Copy link
Member Author

Further work items are now here: #612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants