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

Draft
wants to merge 81 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
d4c6858
Strip out the current software based scaler code
katajakasa Apr 21, 2023
405035b
Quick typos and misc fixes
katajakasa Apr 21, 2023
61a9426
Set up basic GL 3.3 context
katajakasa Apr 21, 2023
20f6894
Find OpenGL in cmake, and link it in
katajakasa Apr 21, 2023
0af9ef5
Find GLEW in cmake, and link it in
katajakasa Apr 22, 2023
8646d3b
Basic shader loading
katajakasa Apr 22, 2023
e8f1ad3
Use path manager to handle shader directory finding
katajakasa Apr 23, 2023
424250f
Install libglew in CI scripts
katajakasa Apr 23, 2023
46f0936
asd
katajakasa Apr 23, 2023
a5cc115
Get rid of GLEW and use libepoxy instead.
katajakasa Apr 24, 2023
f569123
Properly handle shader deletion
katajakasa Apr 24, 2023
a83e290
Dump code
katajakasa Apr 25, 2023
73c25eb
Improve game-controller loader logging
katajakasa Apr 25, 2023
11203b6
Split video renderer into smaller files
katajakasa Apr 25, 2023
6681bc3
Properly SDL clear error in joystick_load_external_mappings
katajakasa Apr 25, 2023
34bcb44
Use SDL_GetTicks64 as recommended by SDL2 library docs
katajakasa Apr 26, 2023
bfc7326
Make it upload vertices to the gpu and do some basic drawing.
katajakasa Apr 26, 2023
de128cd
Fix test naggings.
katajakasa Apr 26, 2023
c6ab515
Bump SDL2 requirement to 2.0.18 due to SDL_GetTicks64.
katajakasa Apr 26, 2023
bac5c44
Allow more vertex coords.
katajakasa Apr 26, 2023
646ead5
Leverage some macro magic to make setting coords nicer.
katajakasa Apr 27, 2023
d187544
Mark cmake paths as advanced
katajakasa Apr 30, 2023
c6228c4
Allow skipping val_len field fetch in hashmap
katajakasa Apr 30, 2023
29773f1
Add some missing vector features
katajakasa Apr 30, 2023
555f58a
Remove last tcache remnants
katajakasa Apr 30, 2023
39cd872
Make warp speed less aggressive ;)
katajakasa Apr 30, 2023
5708064
Hide mp tag debug printer for now
katajakasa Apr 30, 2023
2256005
Make surfaces hash themselves for identity
katajakasa Apr 30, 2023
ecaf824
Draw textures.
katajakasa Apr 30, 2023
528ce35
API for binding uniform blocks to shader programs
katajakasa Apr 30, 2023
7911e1c
Some plans for palette mapper
katajakasa Apr 30, 2023
5b21d8d
Move opengl buffer handling to a separate place
katajakasa Apr 30, 2023
43ee917
Move opengl buffer state management to the application.
katajakasa Apr 30, 2023
f010a5f
Make clang-tidy be quiet about pointless stuff.
katajakasa Apr 30, 2023
baa0e21
Upload basic palettes to the vram via ubo.
katajakasa Apr 30, 2023
e1ac166
Handle sprite flipping
katajakasa May 1, 2023
5846c41
Use constants for native screen size
katajakasa May 1, 2023
ad41d15
Drop unnecessary video_copy_pal_range
katajakasa May 1, 2023
561c50f
Video enum cleanups
katajakasa May 1, 2023
658fa93
Check return values on glGetUniformBlockIndex and glGetUniformLocation
katajakasa May 2, 2023
fa6591f
Fix code formatting
katajakasa May 2, 2023
f595699
Split rendering into two phases
katajakasa May 2, 2023
52f731c
Drop unnecessary (it seems ?) glClear
katajakasa May 2, 2023
bdcedab
Fix "error C7549: OpenGL does not allow C style initializer" on nvidia
katajakasa May 2, 2023
92789ff
Fix off-by-one in shader log printer
katajakasa May 2, 2023
7de6975
Split file handling to a separate library with some added safety checks
katajakasa May 3, 2023
97a8059
Fix logging in shader deletion
katajakasa May 3, 2023
1ab6b84
Rename the pal_buffer_* to shared_*, since that reflects its duties b…
katajakasa May 3, 2023
8dc6e9d
Get rid of errno.
katajakasa May 3, 2023
1fe3e52
Throw out fseek.
katajakasa May 3, 2023
ebf07c8
Set correct READ_BLOCK_SIZE and add some comments.
katajakasa May 3, 2023
2c55d26
Add object properties UBO
katajakasa May 3, 2023
c259c3d
Initial implementation of multiple rendering passes for palette remap…
katajakasa May 5, 2023
1e0f192
Fix batching
katajakasa May 6, 2023
a18c9af
Allow switching output to show atlas texture instead of render target
katajakasa May 7, 2023
05d2c88
Handle menu palette, and move the palette conversions to a macro
katajakasa May 8, 2023
2437371
Remove video_render_bg_separately hack, it is now unnecessary.
katajakasa May 9, 2023
8eecc17
Fix oops in background palette setter
katajakasa May 9, 2023
4a2f907
Bump max object limit for text glyphs
katajakasa May 9, 2023
36c0208
Load fonts as palettized instead of rgba
katajakasa May 9, 2023
ac9bbf9
Make image handler only handle paletted stuff
katajakasa May 9, 2023
c79237a
Make the basic UI stuff render on the palettized renderer
katajakasa May 9, 2023
5da2aa3
glVertexAttribIPointer() and palette offset.
katajakasa May 12, 2023
bd5a4ff
Fiddle with the rendering API and deprecate everything.
katajakasa May 31, 2023
e3dd462
Add some docs to palette.c
katajakasa May 31, 2023
275c9d0
Convert gauge.c to use palettized rendering
katajakasa May 31, 2023
4c92c89
Remove the fonttool as broken
katajakasa Jun 1, 2023
e262fd7
Disable clang-format for specific parts of music.c and settings.c
katajakasa Jun 1, 2023
f98dceb
Get rid of video_render_sprite.
katajakasa Jun 1, 2023
327aebe
Implement video_draw_offset
katajakasa Jun 3, 2023
0d5b7b1
Make HARs also respect the palette offset limit
katajakasa Jun 3, 2023
8eb0d09
Fix screenshots.
katajakasa Jun 3, 2023
3bcd9ee
Quick and dirty grayscale conversion.
katajakasa Jun 3, 2023
423a1c6
Snap the screen capture from correct position for newsroom.
katajakasa Jun 3, 2023
d4ade21
Use video_draw_offset to render the selection highlight in melee.c
katajakasa Jun 5, 2023
91b79b3
Darken the colors in scoreboard using palette tricks instead of RGBA …
katajakasa Jun 8, 2023
54e0e53
Small const addition to game_state.[c|h]
katajakasa Jun 8, 2023
c801a1c
Aaargh.
katajakasa Jun 8, 2023
91acd62
Drop RGBA mode from surface.
katajakasa Jun 8, 2023
7e5b989
Melee seems more or less correct.
katajakasa Jul 14, 2023
ed9f901
Move text color handling to palette.
katajakasa Jul 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/compilation.yml
Expand Up @@ -46,7 +46,7 @@ jobs:
sudo apt-get update
sudo apt-get -y install cmake cmake-data libargtable2-dev libcunit1-dev \
libsdl2-mixer-dev libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev \
clang-tidy ${{ matrix.config.cc }}
libepoxy-dev clang-tidy ${{ matrix.config.cc }}

- name: Build tests
run: |
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install cmake libargtable2-dev libcunit1-dev libsdl2-mixer-dev \
libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev
libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev libepoxy-dev

- name: Generate Release
run: |
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
maintainer: ${{ github.repository_owner }}
version: 0.6.6-${{ steps.slug.outputs.sha8 }}
arch: 'amd64'
depends: 'libargtable2, libsdl2-mixer, libconfuse, libenet, libsdl2, libxmp, libpng'
depends: 'libargtable2, libsdl2-mixer, libconfuse, libenet, libsdl2, libxmp, libpng, libepoxy0'
desc: 'One Must Fall 2097 Remake'

- name: Upload DEB artifact
Expand All @@ -130,7 +130,7 @@ jobs:
- name: Install Mac Dependencies
run: |
brew update
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng libepoxy

- name: Generate Release
run: |
Expand Down
41 changes: 27 additions & 14 deletions CMakeLists.txt
Expand Up @@ -38,12 +38,14 @@ if(GIT_FOUND)
)
message(STATUS "Git SHA1 Hash: ${SHA1_HASH}")
add_definitions(-DSHA1_HASH="${SHA1_HASH}")
endif()
endif ()

# System packages (hard dependencies)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(xmp)
find_package(OpenGL REQUIRED)
find_package(Epoxy REQUIRED)
find_package(enet)
find_package(confuse)
find_package(argtable2)
Expand Down Expand Up @@ -81,6 +83,8 @@ set(COREINCS
${CMAKE_CURRENT_BINARY_DIR}/src/
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIR}
${EPOXY_INCLUDE_DIR}
${CONFUSE_INCLUDE_DIR}
${Intl_INCLUDE_DIR}
${XMP_INCLUDE_DIR}
Expand Down Expand Up @@ -124,24 +128,30 @@ add_library(openomf_core OBJECT ${OPENOMF_SRC})
set(CORELIBS openomf_core ${CORELIBS})

# Set icon for windows executable
if(WIN32)
if (WIN32)
SET(ICON_RESOURCE "resources/icons/openomf.rc")
endif()
endif ()

# Build the game binary
add_executable(openomf src/main.c src/engine.c ${ICON_RESOURCE})

# This is used to copy shader files from source directory to the binary output directory during compile.
add_custom_target(
copy_shaders ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/shaders ${CMAKE_BINARY_DIR}/shaders
)
add_dependencies(openomf copy_shaders)

# Build tools if requested
set(TOOL_TARGET_NAMES)
if(USE_TOOLS)
if (USE_TOOLS)
add_executable(bktool tools/bktool/main.c
tools/shared/animation_misc.c
tools/shared/conversions.c)
tools/shared/animation_misc.c
tools/shared/conversions.c)
add_executable(aftool tools/aftool/main.c
tools/shared/animation_misc.c
tools/shared/conversions.c)
tools/shared/animation_misc.c
tools/shared/conversions.c)
add_executable(soundtool tools/soundtool/main.c)
add_executable(fonttool tools/fonttool/main.c)
add_executable(languagetool tools/languagetool/main.c)
add_executable(omf_parse tools/stringparser/main.c)
add_executable(afdiff tools/afdiff/main.c)
Expand All @@ -157,7 +167,6 @@ if(USE_TOOLS)
bktool
aftool
soundtool
fonttool
languagetool
omf_parse
afdiff
Expand Down Expand Up @@ -238,9 +247,10 @@ endif()

# Make sure libraries are linked
target_link_libraries(openomf ${CORELIBS})
target_link_libraries(openomf SDL2::Main SDL2::Mixer)
target_link_libraries(openomf SDL2::Main SDL2::Mixer OpenGL::GL Epoxy::Main)
foreach(TARGET ${TOOL_TARGET_NAMES})
target_link_libraries(${TARGET} ${CORELIBS} SDL2::Main SDL2::Mixer)
target_link_libraries(${TARGET} ${CORELIBS})
target_link_libraries(${TARGET} SDL2::Main SDL2::Mixer OpenGL::GL Epoxy::Main)
endforeach()

# Testing stuff
Expand All @@ -258,7 +268,7 @@ if(CUNIT_FOUND)
target_compile_definitions(openomf_test_main PRIVATE
TESTS_ROOT_DIR="${CMAKE_SOURCE_DIR}/testing")

target_link_libraries(openomf_test_main ${CORELIBS} SDL2::Main SDL2::Mixer)
target_link_libraries(openomf_test_main ${CORELIBS} SDL2::Main SDL2::Mixer OpenGL::GL Epoxy::Main)

if(MINGW)
# Always build as a console executable with mingw
Expand All @@ -281,12 +291,15 @@ if(WIN32)
# This way we have an "openomf/" root directory inside the zip file.
install(TARGETS openomf RUNTIME DESTINATION openomf/ COMPONENT Binaries)
install(FILES resources/openomf.bk DESTINATION openomf/resources/ COMPONENT Data)
install(DIRECTORY shaders/ DESTINATION openomf/shaders COMPONENT Data)
install(FILES README.md INSTALL.md LICENSE DESTINATION openomf/ COMPONENT Data)
else()
# On unixy systems, follow standard.
install(TARGETS openomf RUNTIME DESTINATION bin COMPONENT Binaries)
install(FILES resources/openomf.bk resources/icons/openomf.png
install(
FILES resources/openomf.bk resources/icons/openomf.png
DESTINATION share/games/openomf/
COMPONENT Data
)
install(DIRECTORY shaders/ DESTINATION share/games/openomf/shaders COMPONENT Data)
endif()
13 changes: 6 additions & 7 deletions INSTALL.md
Expand Up @@ -19,10 +19,7 @@ instructions are also available there.
2. Extract the zip file somewhere on your computer. If possible, use a directory other
than "C:\Program Files".
3. Install the game resources. Please see step 3. of this guide for this.
4. [optional] If you wish, you may install an xBRZ sprite scaler plugin.
This can be found from https://github.com/omf2097/openomf-scaler-xbrz/releases .
Note that this is not necessary for running the game.
5. Start the game by running openomf.exe.
4. Start the game by running openomf.exe.

### Ubuntu

Expand All @@ -42,7 +39,8 @@ Compiling from source should be your last option, unless you know what you are d
Use at least GCC 9 or Clang 10. MSVC is not supported at this time.

Required:
* SDL2 (>=2.0.16): http://www.libsdl.org/download-2.0.php
* SDL2 (>=2.0.18): http://www.libsdl.org/download-2.0.php
* libepoxy: https://github.com/anholt/libepoxy
* confuse: http://www.nongnu.org/confuse/
* Gettext (if you have problems with libintl)
* Enet: http://enet.bespin.org/
Expand All @@ -55,12 +53,13 @@ Required:

On debian, it is possible to pull some libraries using apt-get.
```
apt-get install libsdl2-dev libsdl2-mixer-dev libpng-dev libconfuse-dev libenet-dev libargtable2-dev libxmp-dev
apt-get install libsdl2-dev libsdl2-mixer-dev libpng-dev libconfuse-dev libenet-dev \
libargtable2-dev libxmp-dev libepoxy-dev libopengl-dev
```

On Mac, you can use brew:
```
brew install argtable sdl2_mixer confuse enet sdl2 libxmp libpng
brew install argtable sdl2_mixer confuse enet sdl2 libxmp libpng libepoxy
```

### Acquiring the sources
Expand Down
14 changes: 8 additions & 6 deletions cmake-scripts/FindCUnit.cmake
Expand Up @@ -16,12 +16,14 @@ FIND_LIBRARY(CUNIT_LIBRARY cunit
PATHS ${CUNIT_SEARCH_PATHS}
)

IF(CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
SET(CUNIT_FOUND TRUE)
ENDIF(CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
IF (CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)
SET(CUNIT_FOUND TRUE)
ENDIF (CUNIT_INCLUDE_DIR AND CUNIT_LIBRARY)

IF(CUNIT_FOUND)
IF (CUNIT_FOUND)
MESSAGE(STATUS "Found CUnit: ${CUNIT_LIBRARY}")
ELSE(CUNIT_FOUND)
ELSE (CUNIT_FOUND)
MESSAGE(STATUS "Could not find CUnit. Tests will not be available.")
ENDIF(CUNIT_FOUND)
ENDIF (CUNIT_FOUND)

mark_as_advanced(CUNIT_INCLUDE_DIR CUNIT_LIBRARY CUNIT_SEARCH_PATHS)
28 changes: 28 additions & 0 deletions cmake-scripts/FindEpoxy.cmake
@@ -0,0 +1,28 @@
set(EPOXY_SEARCH_PATHS /usr/local /usr /opt)

find_path(EPOXY_INCLUDE_DIR epoxy/gl.h
HINTS
PATH_SUFFIXES include
PATHS ${EPOXY_SEARCH_PATHS}
)
find_library(EPOXY_LIBRARY epoxy
HINTS
PATH_SUFFIXES lib64 lib
PATHS ${EPOXY_SEARCH_PATHS}
)

if (EPOXY_INCLUDE_DIR AND EPOXY_LIBRARY)
set(EPOXY_FOUND TRUE)
endif ()

if (EPOXY_FOUND)
add_library(Epoxy::Main UNKNOWN IMPORTED)
set_target_properties(Epoxy::Main PROPERTIES
IMPORTED_LOCATION "${EPOXY_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${EPOXY_INCLUDE_DIR}")
message(STATUS "Found libepoxy: ${EPOXY_LIBRARY}")
else ()
message(WARNING "Could not find libepoxy")
endif ()

mark_as_advanced(EPOXY_INCLUDE_DIR EPOXY_LIBRARY EPOXY_SEARCH_PATHS)
13 changes: 7 additions & 6 deletions cmake-scripts/Findconfuse.cmake
Expand Up @@ -16,13 +16,14 @@ FIND_LIBRARY(CONFUSE_LIBRARY confuse
PATHS ${CONFUSE_SEARCH_PATHS}
)

IF(CONFUSE_INCLUDE_DIR AND CONFUSE_LIBRARY)
SET(CONFUSE_FOUND TRUE)
IF (CONFUSE_INCLUDE_DIR AND CONFUSE_LIBRARY)
SET(CONFUSE_FOUND TRUE)
ENDIF (CONFUSE_INCLUDE_DIR AND CONFUSE_LIBRARY)


IF(CONFUSE_FOUND)
IF (CONFUSE_FOUND)
MESSAGE(STATUS "Found libConfuse: ${CONFUSE_LIBRARY}")
ELSE(CONFUSE_FOUND)
ELSE (CONFUSE_FOUND)
MESSAGE(WARNING "Could not find libConfuse")
ENDIF(CONFUSE_FOUND)
ENDIF (CONFUSE_FOUND)

mark_as_advanced(CONFUSE_INCLUDE_DIR CONFUSE_LIBRARY CONFUSE_SEARCH_PATHS)
13 changes: 7 additions & 6 deletions cmake-scripts/Findenet.cmake
Expand Up @@ -16,13 +16,14 @@ FIND_LIBRARY(ENET_LIBRARY enet
PATHS ${ENET_SEARCH_PATHS}
)

IF(ENET_INCLUDE_DIR AND ENET_LIBRARY)
SET(ENET_FOUND TRUE)
IF (ENET_INCLUDE_DIR AND ENET_LIBRARY)
SET(ENET_FOUND TRUE)
ENDIF (ENET_INCLUDE_DIR AND ENET_LIBRARY)


IF(ENET_FOUND)
IF (ENET_FOUND)
MESSAGE(STATUS "Found ENet: ${ENET_LIBRARY}")
ELSE(ENET_FOUND)
ELSE (ENET_FOUND)
MESSAGE(WARNING "Could not find ENet")
ENDIF(ENET_FOUND)
ENDIF (ENET_FOUND)

mark_as_advanced(ENET_INCLUDE_DIR ENET_LIBRARY ENET_SEARCH_PATHS)
3 changes: 2 additions & 1 deletion cmake-scripts/Findxmp.cmake
Expand Up @@ -20,9 +20,10 @@ IF(XMP_INCLUDE_DIR AND XMP_LIBRARY)
SET(XMP_FOUND TRUE)
ENDIF()


IF(XMP_FOUND)
MESSAGE(STATUS "Found libxmp: ${XMP_LIBRARY}")
ELSE()
MESSAGE(WARNING "Could not find libxmp")
ENDIF()

mark_as_advanced(XMP_INCLUDE_DIR XMP_LIBRARY XMP_SEARCH_PATHS)
2 changes: 1 addition & 1 deletion packaging/debian/CMakeLists.txt
Expand Up @@ -7,7 +7,7 @@ SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "extra")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0 (>= 2.0.3), libsdl2-mixer-2.0-0, libconfuse0, libenet7, libpng16-16, libxmp4")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0 (>= 2.0.3), libsdl2-mixer-2.0-0, libconfuse0, libenet7, libpng16-16, libxmp4, libepoxy0")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tuomas Virtanen <katajakasa@gmail.com>")
SET(CPACK_DEB_COMPONENT_INSTALL 1)

Expand Down
49 changes: 49 additions & 0 deletions shaders/palette.frag
@@ -0,0 +1,49 @@
#version 330 core

layout (location = 0) out vec4 color;

in vec2 tex_coord;
in vec2 fbo_coord;
flat in int blend_mode;
flat in int palette_offset;
flat in int palette_limit;

uniform sampler2D atlas;
uniform sampler2D framebuffer;
layout (std140) uniform remaps {
vec4 mappings[19 * 256];
};

void main() {
// Get rid of the branching later! We can split this into two or three shaders pretty easily
// TODO: FIX LATER.
katajakasa marked this conversation as resolved.
Show resolved Hide resolved
if (blend_mode == 0) {
vec4 texel = texture(atlas, tex_coord);
if (texel.g == 0) {
discard;
}
vec4 src = texture(framebuffer, fbo_coord);
int pal_index = int(src.r * 256.0);
if (pal_index <= palette_limit) {
pal_index = clamp(palette_limit, 0, pal_index + palette_offset);
}
float sprite_index = texel.r * 255.0;
int layer = int(clamp(18.9, 0.0, sprite_index + 3.0));
int index = clamp(255, 0, pal_index);
int offset = layer * 256 + index;
float red = mappings[offset].r;
color = vec4(red, 0.0, 0.0, 1.0);
} else if (blend_mode == 1) {
vec4 texel = texture(atlas, tex_coord);
if (texel.g == 0) {
discard;
}
int pal_index = int(texel.r * 256.0);
if (pal_index <= palette_limit) {
pal_index = clamp(palette_limit, 0, pal_index + palette_offset);
}
color = vec4(pal_index / 255.0, 0.0, 0.0, 1.0);
} else {
color = texture(framebuffer, tex_coord).rgba;
}
}
26 changes: 26 additions & 0 deletions shaders/palette.vert
@@ -0,0 +1,26 @@
#version 330 core

layout (location = 0) in vec2 position;
layout (location = 1) in vec2 tex_offset;
layout (location = 2) in int mode;
layout (location = 3) in int pal_offset;
layout (location = 4) in int pal_limit;
uniform mat4 projection;

out vec2 tex_coord;
out vec2 fbo_coord;
flat out int blend_mode;
flat out int palette_offset;
flat out int palette_limit;

void main() {
blend_mode = mode;
palette_offset = pal_offset;
palette_limit = pal_limit;
tex_coord = tex_offset.xy;
fbo_coord = vec2(
position.x / 320.0,
(200.0 - position.y) / 200.0
);
gl_Position = projection * vec4(position.xy, 0.0, 1.0);
}
17 changes: 17 additions & 0 deletions shaders/rgba.frag
@@ -0,0 +1,17 @@
#version 330 core

// In
in vec2 tex_coord;
layout (std140) uniform palette {
vec4 colors[256];
};
uniform sampler2D framebuffer;

// Out
layout (location = 0) out vec4 color;

void main() {
vec4 texel = texture(framebuffer, tex_coord);
int index = int(texel.r * 255);
color = colors[index].rgba;
}