mirror of
https://git.shylie.info/shylie/glerminal.git
synced 2024-12-22 22:50:06 +00:00
Compare commits
No commits in common. "4b740e3eddf05d51f9a60380a90be2fcd37a6ba3" and "844e1b6c7accf890052ccf9e907b7e4a2cbd60dc" have entirely different histories.
4b740e3edd
...
844e1b6c7a
@ -13,14 +13,14 @@ jobs:
|
|||||||
path: curr
|
path: curr
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
lfs: true
|
lfs: true
|
||||||
- name: Checkout previous known working
|
- name: Checkout previous
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
path: prev
|
path: prev
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
lfs: true
|
lfs: true
|
||||||
- run: cd prev && git checkout 10a90a5f6a
|
- run: cd prev && git checkout HEAD^
|
||||||
- name: Build current
|
- name: Build current
|
||||||
run: cmake -S curr -B curr/build -DGLERMINAL_TEST=ON && cmake --build curr/build
|
run: cmake -S curr -B curr/build -DGLERMINAL_TEST=ON && cmake --build curr/build
|
||||||
- name: Build previous
|
- name: Build previous
|
||||||
@ -29,7 +29,7 @@ jobs:
|
|||||||
run: cd curr/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
run: cd curr/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
||||||
- name: Generate PNG file for previous
|
- name: Generate PNG file for previous
|
||||||
run: cd prev/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
run: cd prev/build/tests && ls $PWD/resources && XDG_RUNTIME_DIR=$PWD xvfb-run -a ./test-basic
|
||||||
- name: Upload PNG files
|
- name: Upload current PNG
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: basic
|
name: basic
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
|||||||
[submodule "glfw"]
|
[submodule "glfw"]
|
||||||
path = glfw
|
path = glfw
|
||||||
url = https://git.shylie.info/shylie/glfw.git
|
url = https://git.shylie.info/shylie/glfw.git
|
||||||
[submodule "Lua"]
|
|
||||||
path = Lua
|
|
||||||
url = https://git.shylie.info/shylie/Lua.git
|
|
||||||
|
@ -15,13 +15,11 @@ set(GLERMINAL_CELL_SCALE 4 CACHE STRING "")
|
|||||||
configure_file(source/glerminal-config.h.in glerminal-config.h @ONLY)
|
configure_file(source/glerminal-config.h.in glerminal-config.h @ONLY)
|
||||||
|
|
||||||
add_subdirectory(glfw)
|
add_subdirectory(glfw)
|
||||||
add_subdirectory(Lua)
|
|
||||||
|
|
||||||
add_library(glerminallib STATIC
|
add_library(glerminal STATIC
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/glerminal-config.h
|
${CMAKE_CURRENT_BINARY_DIR}/glerminal-config.h
|
||||||
include/glerminal.h
|
include/glerminal.h
|
||||||
|
|
||||||
source/stb_image.h
|
|
||||||
source/glerminal-private.h
|
source/glerminal-private.h
|
||||||
source/glerminal.cpp
|
source/glerminal.cpp
|
||||||
|
|
||||||
@ -30,12 +28,12 @@ add_library(glerminallib STATIC
|
|||||||
source/glad.c
|
source/glad.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(glerminallib
|
set_target_properties(glerminal
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_STANDARD 11
|
CXX_STANDARD 11
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(glerminallib
|
target_include_directories(glerminal
|
||||||
PUBLIC
|
PUBLIC
|
||||||
include
|
include
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
@ -43,12 +41,12 @@ target_include_directories(glerminallib
|
|||||||
source
|
source
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(glerminallib
|
target_link_libraries(glerminal
|
||||||
PUBLIC
|
PRIVATE
|
||||||
glfw
|
glfw
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(glerminallib
|
target_compile_definitions(glerminal
|
||||||
PUBLIC
|
PUBLIC
|
||||||
GLERMINAL_VERSION=${PROJECT_VERSION}
|
GLERMINAL_VERSION=${PROJECT_VERSION}
|
||||||
GLERMINAL_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
GLERMINAL_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||||
@ -57,22 +55,12 @@ target_compile_definitions(glerminallib
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_link_options(glerminallib
|
target_link_options(glerminal
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"/ENTRY:mainCRTStartup"
|
"/ENTRY:mainCRTStartup"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(glerminal WIN32
|
|
||||||
source/glerminal-main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(glerminal
|
|
||||||
PRIVATE
|
|
||||||
glerminallib
|
|
||||||
lua_static
|
|
||||||
)
|
|
||||||
|
|
||||||
if (PROJECT_IS_TOP_LEVEL)
|
if (PROJECT_IS_TOP_LEVEL)
|
||||||
add_subdirectory(examples examples)
|
add_subdirectory(examples examples)
|
||||||
endif()
|
endif()
|
||||||
|
1
Lua
1
Lua
@ -1 +0,0 @@
|
|||||||
Subproject commit 88246d621abf7b6fba9332f49229d507f020e450
|
|
@ -12,12 +12,10 @@ file(GLOB_RECURSE
|
|||||||
|
|
||||||
foreach(RESOURCE_FILE ${EXAMPLE_RESOURCES})
|
foreach(RESOURCE_FILE ${EXAMPLE_RESOURCES})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
|
${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
|
||||||
COMMAND
|
|
||||||
${CMAKE_COMMAND} -E copy
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_FILE}
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
|
${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_FILE}
|
||||||
)
|
)
|
||||||
@ -36,5 +34,5 @@ list(TRANSFORM EXAMPLE_RESOURCES PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
|
|||||||
foreach(SOURCE_FILE ${EXAMPLE_SOURCES})
|
foreach(SOURCE_FILE ${EXAMPLE_SOURCES})
|
||||||
get_filename_component(SOURCE_FILENAME ${SOURCE_FILE} NAME_WLE)
|
get_filename_component(SOURCE_FILENAME ${SOURCE_FILE} NAME_WLE)
|
||||||
add_executable(${SOURCE_FILENAME} WIN32 ${SOURCE_FILE} ${EXAMPLE_RESOURCES})
|
add_executable(${SOURCE_FILENAME} WIN32 ${SOURCE_FILE} ${EXAMPLE_RESOURCES})
|
||||||
target_link_libraries(${SOURCE_FILENAME} PRIVATE glerminallib)
|
target_link_libraries(${SOURCE_FILENAME} PRIVATE glerminal)
|
||||||
endforeach()
|
endforeach()
|
@ -1,29 +0,0 @@
|
|||||||
local time = 0
|
|
||||||
|
|
||||||
function glerminal.init()
|
|
||||||
if not glerminal.sprites('sprites.png') then
|
|
||||||
print('failed to load sprites')
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, 40 do
|
|
||||||
for j = 1, 25 do
|
|
||||||
glerminal.set(i, j, 1, 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
glerminal.tint(1, 0xA0FFFFFF)
|
|
||||||
|
|
||||||
glerminal.flush()
|
|
||||||
end
|
|
||||||
|
|
||||||
function glerminal.main(dt)
|
|
||||||
time = time + dt / 2
|
|
||||||
|
|
||||||
for i = 1, 40 do
|
|
||||||
for j = 1, 25 do
|
|
||||||
glerminal.offset(i, j, 1, math.cos(time * i / math.pi), math.sin(time * j / math.pi))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
glerminal.flush()
|
|
||||||
end
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6dee3efcdfa72e54a602f69643907bb8e8a3328d2b40c2116dce22ff179d8892
|
|
||||||
size 182
|
|
@ -1,163 +0,0 @@
|
|||||||
#include <glerminal.h>
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define WINDOWS_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
|
||||||
#define CHANGE_WORKING_DIRECTORY(path) !(SetCurrentDirectory(path))
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#define CHANGE_WORKING_DIRECTORY(path) chdir(path)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
int lglerminal_quit(lua_State* L)
|
|
||||||
{
|
|
||||||
glerminal_quit();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_flush(lua_State* L)
|
|
||||||
{
|
|
||||||
glerminal_flush();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_set(lua_State* L)
|
|
||||||
{
|
|
||||||
const unsigned char x = luaL_checkinteger(L, 1) - 1;
|
|
||||||
const unsigned char y = luaL_checkinteger(L, 2) - 1;
|
|
||||||
const unsigned char layer = luaL_checkinteger(L, 3) - 1;
|
|
||||||
const unsigned char sprite = luaL_checkinteger(L, 4) - 1;
|
|
||||||
glerminal_set(x, y, layer, sprite);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_get(lua_State* L)
|
|
||||||
{
|
|
||||||
const unsigned char x = luaL_checkinteger(L, 1) - 1;
|
|
||||||
const unsigned char y = luaL_checkinteger(L, 2) - 1;
|
|
||||||
const unsigned char layer = luaL_checkinteger(L, 3) - 1;
|
|
||||||
lua_pushnumber(L, glerminal_get(x, y, layer) + 1);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_offset(lua_State* L)
|
|
||||||
{
|
|
||||||
const unsigned char x = luaL_checkinteger(L, 1) - 1;
|
|
||||||
const unsigned char y = luaL_checkinteger(L, 2) - 1;
|
|
||||||
const unsigned char layer = luaL_checkinteger(L, 3) - 1;
|
|
||||||
const float ox = luaL_checknumber(L, 4);
|
|
||||||
const float oy = luaL_checknumber(L, 5);
|
|
||||||
glerminal_offset(x, y, layer, ox, oy);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_layer_color(lua_State* L)
|
|
||||||
{
|
|
||||||
const unsigned char layer = luaL_checkinteger(L, 1) - 1;
|
|
||||||
const unsigned int color = luaL_checkinteger(L, 2);
|
|
||||||
glerminal_layer_color(layer, color);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_layer_scale(lua_State* L)
|
|
||||||
{
|
|
||||||
const unsigned char layer = luaL_checkinteger(L, 1) - 1;
|
|
||||||
const float scale = luaL_checknumber(L, 2);
|
|
||||||
glerminal_layer_scale(layer, scale);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lglerminal_load_sprites_file(lua_State* L)
|
|
||||||
{
|
|
||||||
const char* path = luaL_checkstring(L, 1);
|
|
||||||
lua_pushboolean(L, glerminal_load_sprites_file(path));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const luaL_Reg lglerminal_methods[] =
|
|
||||||
{
|
|
||||||
{ "quit", lglerminal_quit },
|
|
||||||
{ "flush", lglerminal_flush },
|
|
||||||
{ "set", lglerminal_set },
|
|
||||||
{ "get", lglerminal_get },
|
|
||||||
{ "offset", lglerminal_offset },
|
|
||||||
{ "tint", lglerminal_layer_color },
|
|
||||||
{ "scale", lglerminal_layer_scale },
|
|
||||||
{ "sprites", lglerminal_load_sprites_file },
|
|
||||||
{ nullptr, nullptr }
|
|
||||||
};
|
|
||||||
|
|
||||||
lua_State* L;
|
|
||||||
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
lua_getglobal(L, "glerminal");
|
|
||||||
lua_getfield(L, -1, "init");
|
|
||||||
lua_remove(L, -2);
|
|
||||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
|
|
||||||
{
|
|
||||||
// ignore error for now
|
|
||||||
lua_remove(L, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mainloop(float dt)
|
|
||||||
{
|
|
||||||
lua_getglobal(L, "glerminal");
|
|
||||||
lua_getfield(L, -1, "main");
|
|
||||||
lua_remove(L, -2);
|
|
||||||
lua_pushnumber(L, dt);
|
|
||||||
if (lua_pcall(L, 1, 0, 0) != LUA_OK)
|
|
||||||
{
|
|
||||||
// ignore error for now
|
|
||||||
lua_remove(L, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
if (argc == 1)
|
|
||||||
{
|
|
||||||
std::cout << "Usage: " << argv[0] << " <project directory>" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CHANGE_WORKING_DIRECTORY(argv[1]))
|
|
||||||
{
|
|
||||||
std::cout << "Failed to find project directory" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
L = luaL_newstate();
|
|
||||||
luaL_openlibs(L);
|
|
||||||
|
|
||||||
luaL_newlib(L, lglerminal_methods);
|
|
||||||
lua_setglobal(L, "glerminal");
|
|
||||||
|
|
||||||
luaL_dofile(L, "main.lua");
|
|
||||||
|
|
||||||
glerminal_run(init, mainloop);
|
|
||||||
|
|
||||||
lua_close(L);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -35,14 +35,9 @@ namespace
|
|||||||
"{\n"
|
"{\n"
|
||||||
" float scales[];\n"
|
" float scales[];\n"
|
||||||
"} lss;\n"
|
"} lss;\n"
|
||||||
"layout (std430, binding = 1) buffer LayerColors"
|
|
||||||
"{\n"
|
|
||||||
" vec4 colors[];\n"
|
|
||||||
"} lcs;\n"
|
|
||||||
"out VS_OUT {\n"
|
"out VS_OUT {\n"
|
||||||
" flat int sprite;\n"
|
" flat int sprite;\n"
|
||||||
" flat int layer;\n"
|
" flat int layer;\n"
|
||||||
" flat vec4 layer_color;\n"
|
|
||||||
" vec2 texcoord;\n"
|
" vec2 texcoord;\n"
|
||||||
"} vs_out;\n"
|
"} vs_out;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
@ -51,7 +46,6 @@ namespace
|
|||||||
" vec2 scaled_offset = 2 * offset * " GRID_SIZE_UNIFORM_NAME ".zw;\n"
|
" vec2 scaled_offset = 2 * offset * " GRID_SIZE_UNIFORM_NAME ".zw;\n"
|
||||||
" vs_out.sprite = sprite;\n"
|
" vs_out.sprite = sprite;\n"
|
||||||
" vs_out.layer = layer;\n"
|
" vs_out.layer = layer;\n"
|
||||||
" vs_out.layer_color = lcs.colors[layer];\n"
|
|
||||||
" vs_out.texcoord = vec2(position.x + 1, -position.y);\n"
|
" vs_out.texcoord = vec2(position.x + 1, -position.y);\n"
|
||||||
" vec2 cell_position = vec2(lss.scales[layer] + (gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) - " GRID_SIZE_UNIFORM_NAME ".x * floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z), -floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z));\n"
|
" vec2 cell_position = vec2(lss.scales[layer] + (gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) - " GRID_SIZE_UNIFORM_NAME ".x * floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z), -floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z));\n"
|
||||||
" vec2 temp = ((position + vec2(-0.5, 0.5)) * lss.scales[layer] + cell_position + vec2(0.5, -0.5)) * " GRID_SIZE_UNIFORM_NAME ".zw * 2 + vec2(-1, 1);\n"
|
" vec2 temp = ((position + vec2(-0.5, 0.5)) * lss.scales[layer] + cell_position + vec2(0.5, -0.5)) * " GRID_SIZE_UNIFORM_NAME ".zw * 2 + vec2(-1, 1);\n"
|
||||||
@ -71,13 +65,8 @@ namespace
|
|||||||
"{\n"
|
"{\n"
|
||||||
" float scales[];\n"
|
" float scales[];\n"
|
||||||
"} lss;\n"
|
"} lss;\n"
|
||||||
"layout (std430, binding = 1) buffer LayerColors"
|
|
||||||
"{\n"
|
|
||||||
" vec4 colors[];\n"
|
|
||||||
"} lcs;\n"
|
|
||||||
"out VS_OUT {\n"
|
"out VS_OUT {\n"
|
||||||
" flat int sprite;\n"
|
" flat int sprite;\n"
|
||||||
" flat vec4 layer_color;\n"
|
|
||||||
" vec2 texcoord;\n"
|
" vec2 texcoord;\n"
|
||||||
"} vs_out;\n"
|
"} vs_out;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
@ -87,7 +76,6 @@ namespace
|
|||||||
" vec2 scaled_offset = 2 * offset * " GRID_SIZE_UNIFORM_NAME ".zw;\n"
|
" vec2 scaled_offset = 2 * offset * " GRID_SIZE_UNIFORM_NAME ".zw;\n"
|
||||||
" vs_out.sprite = sprite;\n"
|
" vs_out.sprite = sprite;\n"
|
||||||
" vs_out.texcoord = vec2(position.x + 1, -position.y);\n"
|
" vs_out.texcoord = vec2(position.x + 1, -position.y);\n"
|
||||||
" vs_out.layer_color = lcs.colors[layer];\n"
|
|
||||||
" vec2 cell_position = vec2(lss.scales[layer] + (gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) - " GRID_SIZE_UNIFORM_NAME ".x * floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z), -floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z));\n"
|
" vec2 cell_position = vec2(lss.scales[layer] + (gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) - " GRID_SIZE_UNIFORM_NAME ".x * floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z), -floor((gl_InstanceID % int(" GRID_SIZE_UNIFORM_NAME ".y)) * " GRID_SIZE_UNIFORM_NAME ".z));\n"
|
||||||
" vec2 temp = ((position + vec2(-0.5, 0.5)) * lss.scales[layer] + cell_position + vec2(0.5, -0.5)) * " GRID_SIZE_UNIFORM_NAME ".zw * 2 + vec2(-1, 1);\n"
|
" vec2 temp = ((position + vec2(-0.5, 0.5)) * lss.scales[layer] + cell_position + vec2(0.5, -0.5)) * " GRID_SIZE_UNIFORM_NAME ".zw * 2 + vec2(-1, 1);\n"
|
||||||
" gl_Position = vec4(scaled_offset.x + temp.x, scaled_offset.y - temp.y, 0, 1);\n"
|
" gl_Position = vec4(scaled_offset.x + temp.x, scaled_offset.y - temp.y, 0, 1);\n"
|
||||||
@ -103,30 +91,25 @@ namespace
|
|||||||
"in VS_OUT {\n"
|
"in VS_OUT {\n"
|
||||||
" flat int sprite;\n"
|
" flat int sprite;\n"
|
||||||
" flat int layer;\n"
|
" flat int layer;\n"
|
||||||
" flat vec4 layer_color;\n"
|
|
||||||
" vec2 texcoord;\n"
|
" vec2 texcoord;\n"
|
||||||
"} gs_in[];\n"
|
"} gs_in[];\n"
|
||||||
"flat out int sprite;\n"
|
"flat out int sprite;\n"
|
||||||
"flat out vec4 layer_color;\n"
|
|
||||||
"out vec2 texcoord;\n"
|
"out vec2 texcoord;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_Layer = gs_in[0].layer;\n"
|
" gl_Layer = gs_in[0].layer;\n"
|
||||||
" gl_Position = gl_in[0].gl_Position;\n"
|
" gl_Position = gl_in[0].gl_Position;\n"
|
||||||
" sprite = gs_in[0].sprite;\n"
|
" sprite = gs_in[0].sprite;\n"
|
||||||
" layer_color = gs_in[0].layer_color;\n"
|
|
||||||
" texcoord = gs_in[0].texcoord;\n"
|
" texcoord = gs_in[0].texcoord;\n"
|
||||||
" EmitVertex();\n"
|
" EmitVertex();\n"
|
||||||
" gl_Layer = gs_in[1].layer;\n"
|
" gl_Layer = gs_in[1].layer;\n"
|
||||||
" gl_Position = gl_in[1].gl_Position;\n"
|
" gl_Position = gl_in[1].gl_Position;\n"
|
||||||
" sprite = gs_in[1].sprite;\n"
|
" sprite = gs_in[1].sprite;\n"
|
||||||
" layer_color = gs_in[1].layer_color;\n"
|
|
||||||
" texcoord = gs_in[1].texcoord;\n"
|
" texcoord = gs_in[1].texcoord;\n"
|
||||||
" EmitVertex();\n"
|
" EmitVertex();\n"
|
||||||
" gl_Layer = gs_in[2].layer;\n"
|
" gl_Layer = gs_in[2].layer;\n"
|
||||||
" gl_Position = gl_in[2].gl_Position;\n"
|
" gl_Position = gl_in[2].gl_Position;\n"
|
||||||
" sprite = gs_in[2].sprite;\n"
|
" sprite = gs_in[2].sprite;\n"
|
||||||
" layer_color = gs_in[2].layer_color;\n"
|
|
||||||
" texcoord = gs_in[2].texcoord;\n"
|
" texcoord = gs_in[2].texcoord;\n"
|
||||||
" EmitVertex();\n"
|
" EmitVertex();\n"
|
||||||
" EndPrimitive();\n"
|
" EndPrimitive();\n"
|
||||||
@ -136,14 +119,13 @@ namespace
|
|||||||
|
|
||||||
constexpr char FRAGMENT_SHADER_SOURCE[] =
|
constexpr char FRAGMENT_SHADER_SOURCE[] =
|
||||||
"#version 450 core\n"
|
"#version 450 core\n"
|
||||||
"flat in int sprite;\n"
|
|
||||||
"flat vec4 layer_color;\n"
|
|
||||||
"in vec2 texcoord;\n"
|
"in vec2 texcoord;\n"
|
||||||
|
"flat in int sprite;\n"
|
||||||
"layout (binding = 0) uniform sampler2DArray " SPRITES_UNIFORM_NAME ";\n"
|
"layout (binding = 0) uniform sampler2DArray " SPRITES_UNIFORM_NAME ";\n"
|
||||||
"out vec4 FragColor;\n"
|
"out vec4 FragColor;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" FragColor = layer_color * texture(" SPRITES_UNIFORM_NAME ", vec3(texcoord, sprite));\n"
|
" FragColor = texture(" SPRITES_UNIFORM_NAME ", vec3(texcoord, sprite));\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
// note: AMD_vertex_shader_layer support required
|
// note: AMD_vertex_shader_layer support required
|
||||||
@ -151,14 +133,13 @@ namespace
|
|||||||
"#version 450 core\n"
|
"#version 450 core\n"
|
||||||
"in VS_OUT {\n"
|
"in VS_OUT {\n"
|
||||||
" flat int sprite;\n"
|
" flat int sprite;\n"
|
||||||
" flat vec4 layer_color;\n"
|
|
||||||
" vec2 texcoord;\n"
|
" vec2 texcoord;\n"
|
||||||
"} fs_in;\n"
|
"} fs_in;\n"
|
||||||
"layout (binding = 0) uniform sampler2DArray " SPRITES_UNIFORM_NAME ";\n"
|
"layout (binding = 0) uniform sampler2DArray " SPRITES_UNIFORM_NAME ";\n"
|
||||||
"out vec4 FragColor;\n"
|
"out vec4 FragColor;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" FragColor = fs_in.layer_color * texture(" SPRITES_UNIFORM_NAME ", vec3(fs_in.texcoord, fs_in.sprite));\n"
|
" FragColor = texture(" SPRITES_UNIFORM_NAME ", vec3(fs_in.texcoord, fs_in.sprite));\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
constexpr const char* FRAGMENT_SHADER_SOURCE_PTR = FRAGMENT_SHADER_SOURCE;
|
constexpr const char* FRAGMENT_SHADER_SOURCE_PTR = FRAGMENT_SHADER_SOURCE;
|
||||||
@ -180,6 +161,10 @@ namespace
|
|||||||
"#version 450 core\n"
|
"#version 450 core\n"
|
||||||
"in vec2 texcoord;\n"
|
"in vec2 texcoord;\n"
|
||||||
"layout (binding = 1) uniform sampler2DArray " LAYERS_UNIFORM_NAME ";\n"
|
"layout (binding = 1) uniform sampler2DArray " LAYERS_UNIFORM_NAME ";\n"
|
||||||
|
"layout (std430, binding = 1) buffer LayerColors"
|
||||||
|
"{\n"
|
||||||
|
" vec4 colors[];\n"
|
||||||
|
"} lcs;\n"
|
||||||
"uniform int " LAYER_COUNT_UNIFORM_NAME ";\n"
|
"uniform int " LAYER_COUNT_UNIFORM_NAME ";\n"
|
||||||
"out vec4 FragColor;\n"
|
"out vec4 FragColor;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
@ -187,7 +172,7 @@ namespace
|
|||||||
" vec3 current_color = vec3(0);\n"
|
" vec3 current_color = vec3(0);\n"
|
||||||
" for (int i = 0; i < " LAYER_COUNT_UNIFORM_NAME "; i++)\n"
|
" for (int i = 0; i < " LAYER_COUNT_UNIFORM_NAME "; i++)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" vec4 texsample = texture(" LAYERS_UNIFORM_NAME ", vec3(texcoord, i));\n"
|
" vec4 texsample = lcs.colors[i] * texture(" LAYERS_UNIFORM_NAME ", vec3(texcoord, i));\n"
|
||||||
" current_color = mix(current_color, texsample.rgb, texsample.a);\n"
|
" current_color = mix(current_color, texsample.rgb, texsample.a);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" FragColor = vec4(current_color, 1);\n"
|
" FragColor = vec4(current_color, 1);\n"
|
||||||
@ -237,8 +222,6 @@ namespace glerminal
|
|||||||
GLERMINAL_G = this;
|
GLERMINAL_G = this;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
glerminal_flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glerminal::~glerminal()
|
glerminal::~glerminal()
|
||||||
@ -544,8 +527,8 @@ namespace glerminal
|
|||||||
glDeleteShader(geometry_shader);
|
glDeleteShader(geometry_shader);
|
||||||
glDeleteShader(fragment_shader);
|
glDeleteShader(fragment_shader);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, "Could not compile vertex shader.");
|
log(GL_DEBUG_TYPE_ERROR, 0, 0, "Could not compile vertex shader.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 0, 0, info_log);
|
||||||
throw std::runtime_error("Could not compile vertex shader.");
|
throw std::runtime_error("Could not compile vertex shader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,8 +541,8 @@ namespace glerminal
|
|||||||
glDeleteShader(geometry_shader);
|
glDeleteShader(geometry_shader);
|
||||||
glDeleteShader(fragment_shader);
|
glDeleteShader(fragment_shader);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 1, GL_DEBUG_SEVERITY_HIGH, "Could not compile geometry shader.");
|
log(GL_DEBUG_TYPE_ERROR, 1, 0, "Could not compile geometry shader.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 1, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 1, 0, info_log);
|
||||||
throw std::runtime_error("Could not compile geometry shader.");
|
throw std::runtime_error("Could not compile geometry shader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,8 +555,8 @@ namespace glerminal
|
|||||||
glDeleteShader(geometry_shader);
|
glDeleteShader(geometry_shader);
|
||||||
glDeleteShader(fragment_shader);
|
glDeleteShader(fragment_shader);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 2, GL_DEBUG_SEVERITY_HIGH, "Could not compile fragment shader.");
|
log(GL_DEBUG_TYPE_ERROR, 2, 0, "Could not compile fragment shader.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 2, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 2, 0, info_log);
|
||||||
throw std::runtime_error("Could not compile fragment shader.");
|
throw std::runtime_error("Could not compile fragment shader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,8 +582,8 @@ namespace glerminal
|
|||||||
|
|
||||||
glDeleteProgram(m_program);
|
glDeleteProgram(m_program);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 3, GL_DEBUG_SEVERITY_HIGH, "Could not link shader program.");
|
log(GL_DEBUG_TYPE_ERROR, 3, 0, "Could not link shader program.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 3, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 3, 0, info_log);
|
||||||
throw std::runtime_error("Could not link shader program.");
|
throw std::runtime_error("Could not link shader program.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,8 +611,8 @@ namespace glerminal
|
|||||||
glDeleteShader(screen_vertex_shader);
|
glDeleteShader(screen_vertex_shader);
|
||||||
glDeleteShader(screen_fragment_shader);
|
glDeleteShader(screen_fragment_shader);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 4, GL_DEBUG_SEVERITY_HIGH, "Could not compile screen vertex shader.");
|
log(GL_DEBUG_TYPE_ERROR, 4, 0, "Could not compile screen vertex shader.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 4, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 4, 0, info_log);
|
||||||
throw std::runtime_error("Could not compile screen vertex shader.");
|
throw std::runtime_error("Could not compile screen vertex shader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,8 +624,8 @@ namespace glerminal
|
|||||||
glDeleteShader(screen_vertex_shader);
|
glDeleteShader(screen_vertex_shader);
|
||||||
glDeleteShader(screen_fragment_shader);
|
glDeleteShader(screen_fragment_shader);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 5, GL_DEBUG_SEVERITY_HIGH, "Could not compile screen fragment shader.");
|
log(GL_DEBUG_TYPE_ERROR, 5, 0, "Could not compile screen fragment shader.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 5, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 5, 0, info_log);
|
||||||
throw std::runtime_error("Could not compile screen fragment shader.");
|
throw std::runtime_error("Could not compile screen fragment shader.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,8 +643,8 @@ namespace glerminal
|
|||||||
{
|
{
|
||||||
glDeleteProgram(m_screen_program);
|
glDeleteProgram(m_screen_program);
|
||||||
|
|
||||||
log(GL_DEBUG_TYPE_ERROR, 6, GL_DEBUG_SEVERITY_HIGH, "Could not link screen shader program.");
|
log(GL_DEBUG_TYPE_ERROR, 6, 0, "Could not link screen shader program.");
|
||||||
log(GL_DEBUG_TYPE_ERROR, 6, GL_DEBUG_SEVERITY_HIGH, info_log);
|
log(GL_DEBUG_TYPE_ERROR, 6, 0, info_log);
|
||||||
throw std::runtime_error("Could not link screen shader program.");
|
throw std::runtime_error("Could not link screen shader program.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ target_include_directories(test-common
|
|||||||
${CMAKE_SOURCE_DIR}/source
|
${CMAKE_SOURCE_DIR}/source
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(test-common PRIVATE glerminallib)
|
target_link_libraries(test-common PRIVATE glerminal)
|
||||||
|
|
||||||
file(GLOB_RECURSE
|
file(GLOB_RECURSE
|
||||||
TEST_RESOURCES
|
TEST_RESOURCES
|
||||||
@ -52,5 +52,5 @@ list(TRANSFORM TEST_RESOURCES PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
|
|||||||
foreach(SOURCE_FILE ${TEST_SOURCES})
|
foreach(SOURCE_FILE ${TEST_SOURCES})
|
||||||
get_filename_component(SOURCE_FILENAME ${SOURCE_FILE} NAME_WLE)
|
get_filename_component(SOURCE_FILENAME ${SOURCE_FILE} NAME_WLE)
|
||||||
add_executable(test-${SOURCE_FILENAME} WIN32 ${SOURCE_FILE} ${TEST_RESOURCES})
|
add_executable(test-${SOURCE_FILENAME} WIN32 ${SOURCE_FILE} ${TEST_RESOURCES})
|
||||||
target_link_libraries(test-${SOURCE_FILENAME} PRIVATE glerminallib test-common)
|
target_link_libraries(test-${SOURCE_FILENAME} PRIVATE glerminal test-common)
|
||||||
endforeach()
|
endforeach()
|
Loading…
Reference in New Issue
Block a user