Refactor OpenGL bindings and clean up unused functions in lua.cpp and opengl.cpp
Update video texture reference in test.lua and enhance .gitignore for media files
This commit is contained in:
12
.gitignore
vendored
12
.gitignore
vendored
@@ -3,3 +3,15 @@ build/
|
||||
compile_commands.json
|
||||
CMakeUserPresets.json
|
||||
cmake/
|
||||
*.mp4
|
||||
*.mkv
|
||||
*.avi
|
||||
*.mov
|
||||
*.flv
|
||||
*.wmv
|
||||
*.mp3
|
||||
*.wav
|
||||
*.ogg
|
||||
*.flac
|
||||
*.aac
|
||||
*.opus
|
||||
|
||||
@@ -2,7 +2,7 @@ effect = nil
|
||||
video = nil
|
||||
|
||||
function _create()
|
||||
video = Texture.FromGStreamer("filesrc location=" .. Resolve("sunset.mkv"))
|
||||
video = Texture.FromGStreamer("filesrc location=" .. Resolve("video.mkv"))
|
||||
|
||||
local fxSrc = [[uniform sampler2D uTexture;
|
||||
|
||||
|
||||
73
src/lua.cpp
73
src/lua.cpp
@@ -384,70 +384,23 @@ static void RegisterOpenGL(sol::state& lua) {
|
||||
static_cast<void(*)(const Vector3&)>(&OpenGL::Clear),
|
||||
static_cast<void(*)(const Vector4&)>(&OpenGL::Clear)
|
||||
);
|
||||
gl["ClearDepth"] = &OpenGL::ClearDepth;
|
||||
|
||||
// ── Viewport ────────────────────────────────────────────────────────
|
||||
gl["SetViewport"] = &OpenGL::SetViewport;
|
||||
|
||||
// ── Blending ────────────────────────────────────────────────────────
|
||||
gl["EnableBlending"] = &OpenGL::EnableBlending;
|
||||
gl["DisableBlending"] = &OpenGL::DisableBlending;
|
||||
gl["SetBlendFunc"] = &OpenGL::SetBlendFunc;
|
||||
|
||||
// ── Depth ───────────────────────────────────────────────────────────
|
||||
gl["EnableDepthTest"] = &OpenGL::EnableDepthTest;
|
||||
gl["DisableDepthTest"] = &OpenGL::DisableDepthTest;
|
||||
gl["SetDepthFunc"] = &OpenGL::SetDepthFunc;
|
||||
gl["SetDepthMask"] = &OpenGL::SetDepthMask;
|
||||
|
||||
// ── Culling ─────────────────────────────────────────────────────────
|
||||
gl["EnableCullFace"] = &OpenGL::EnableCullFace;
|
||||
gl["DisableCullFace"] = &OpenGL::DisableCullFace;
|
||||
gl["SetCullFace"] = &OpenGL::SetCullFace;
|
||||
|
||||
// ── Scissor ─────────────────────────────────────────────────────────
|
||||
gl["EnableScissorTest"] = &OpenGL::EnableScissorTest;
|
||||
gl["DisableScissorTest"] = &OpenGL::DisableScissorTest;
|
||||
gl["SetScissor"] = &OpenGL::SetScissor;
|
||||
|
||||
// ── Wireframe ───────────────────────────────────────────────────────
|
||||
gl["SetWireframe"] = &OpenGL::SetWireframe;
|
||||
|
||||
// ── Color Mask ──────────────────────────────────────────────────────
|
||||
gl["SetColorMask"] = &OpenGL::SetColorMask;
|
||||
|
||||
// ── Textures ─────────────────────────────────────────────────────────
|
||||
gl["ActiveTexture"] = &OpenGL::ActiveTexture;
|
||||
|
||||
// ── GL enum constants ───────────────────────────────────────────────
|
||||
auto glEnum = lua.create_named_table("GL");
|
||||
|
||||
// Blend factors
|
||||
glEnum["ZERO"] = GL_ZERO;
|
||||
glEnum["ONE"] = GL_ONE;
|
||||
glEnum["SRC_COLOR"] = GL_SRC_COLOR;
|
||||
glEnum["ONE_MINUS_SRC_COLOR"] = GL_ONE_MINUS_SRC_COLOR;
|
||||
glEnum["DST_COLOR"] = GL_DST_COLOR;
|
||||
glEnum["ONE_MINUS_DST_COLOR"] = GL_ONE_MINUS_DST_COLOR;
|
||||
glEnum["SRC_ALPHA"] = GL_SRC_ALPHA;
|
||||
glEnum["ONE_MINUS_SRC_ALPHA"] = GL_ONE_MINUS_SRC_ALPHA;
|
||||
glEnum["DST_ALPHA"] = GL_DST_ALPHA;
|
||||
glEnum["ONE_MINUS_DST_ALPHA"] = GL_ONE_MINUS_DST_ALPHA;
|
||||
|
||||
// Depth functions
|
||||
glEnum["NEVER"] = GL_NEVER;
|
||||
glEnum["LESS"] = GL_LESS;
|
||||
glEnum["EQUAL"] = GL_EQUAL;
|
||||
glEnum["LEQUAL"] = GL_LEQUAL;
|
||||
glEnum["GREATER"] = GL_GREATER;
|
||||
glEnum["NOTEQUAL"] = GL_NOTEQUAL;
|
||||
glEnum["GEQUAL"] = GL_GEQUAL;
|
||||
glEnum["ALWAYS"] = GL_ALWAYS;
|
||||
|
||||
// Cull face
|
||||
glEnum["FRONT"] = GL_FRONT;
|
||||
glEnum["BACK"] = GL_BACK;
|
||||
glEnum["FRONT_AND_BACK"] = GL_FRONT_AND_BACK;
|
||||
gl["ZERO"] = GL_ZERO;
|
||||
gl["ONE"] = GL_ONE;
|
||||
gl["SRC_COLOR"] = GL_SRC_COLOR;
|
||||
gl["ONE_MINUS_SRC_COLOR"] = GL_ONE_MINUS_SRC_COLOR;
|
||||
gl["DST_COLOR"] = GL_DST_COLOR;
|
||||
gl["ONE_MINUS_DST_COLOR"] = GL_ONE_MINUS_DST_COLOR;
|
||||
gl["SRC_ALPHA"] = GL_SRC_ALPHA;
|
||||
gl["ONE_MINUS_SRC_ALPHA"] = GL_ONE_MINUS_SRC_ALPHA;
|
||||
gl["DST_ALPHA"] = GL_DST_ALPHA;
|
||||
gl["ONE_MINUS_DST_ALPHA"] = GL_ONE_MINUS_DST_ALPHA;
|
||||
}
|
||||
|
||||
void RegisterLuaBindings(sol::state& lua) {
|
||||
@@ -464,4 +417,10 @@ void RegisterLuaBindings(sol::state& lua) {
|
||||
RegisterFrameBuffer(lua);
|
||||
RegisterEffect(lua);
|
||||
RegisterOpenGL(lua);
|
||||
|
||||
// Globals
|
||||
lua["DesktopSize"] = g_DesktopSize;
|
||||
lua["Displays"] = sol::as_table(g_Displays);
|
||||
lua["Mouse"] = g_Mouse;
|
||||
lua["Time"] = &g_Time;
|
||||
}
|
||||
@@ -16,16 +16,6 @@ void Clear(const Vector4& color) {
|
||||
Clear(color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
void ClearDepth(float depth) {
|
||||
glClearDepth(depth);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
// ── Viewport ────────────────────────────────────────────────────────────
|
||||
void SetViewport(int x, int y, int width, int height) {
|
||||
glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
// ── Blending ────────────────────────────────────────────────────────────
|
||||
void EnableBlending() {
|
||||
glEnable(GL_BLEND);
|
||||
@@ -39,62 +29,4 @@ void SetBlendFunc(GLenum src, GLenum dst) {
|
||||
glBlendFunc(src, dst);
|
||||
}
|
||||
|
||||
// ── Depth ───────────────────────────────────────────────────────────────
|
||||
void EnableDepthTest() {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void DisableDepthTest() {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void SetDepthFunc(GLenum func) {
|
||||
glDepthFunc(func);
|
||||
}
|
||||
|
||||
void SetDepthMask(bool write) {
|
||||
glDepthMask(write ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
// ── Culling ─────────────────────────────────────────────────────────────
|
||||
void EnableCullFace() {
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
void DisableCullFace() {
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
void SetCullFace(GLenum face) {
|
||||
glCullFace(face);
|
||||
}
|
||||
|
||||
// ── Scissor ─────────────────────────────────────────────────────────────
|
||||
void EnableScissorTest() {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
void DisableScissorTest() {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
void SetScissor(int x, int y, int width, int height) {
|
||||
glScissor(x, y, width, height);
|
||||
}
|
||||
|
||||
// ── Wireframe ───────────────────────────────────────────────────────────
|
||||
void SetWireframe(bool enabled) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, enabled ? GL_LINE : GL_FILL);
|
||||
}
|
||||
|
||||
// ── Color Mask ──────────────────────────────────────────────────────────
|
||||
void SetColorMask(bool r, bool g, bool b, bool a) {
|
||||
glColorMask(r, g, b, a);
|
||||
}
|
||||
|
||||
void ActiveTexture(size_t textureUnit)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + static_cast<GLenum>(textureUnit));
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
||||
29
src/opengl.h
29
src/opengl.h
@@ -9,39 +9,10 @@ namespace OpenGL {
|
||||
void Clear(float r, float g, float b, float a = 1.0f);
|
||||
void Clear(const Vector3& color);
|
||||
void Clear(const Vector4& color);
|
||||
void ClearDepth(float depth = 1.0f);
|
||||
|
||||
// ── Viewport ────────────────────────────────────────────────────────────
|
||||
void SetViewport(int x, int y, int width, int height);
|
||||
|
||||
// ── Blending ────────────────────────────────────────────────────────────
|
||||
void EnableBlending();
|
||||
void DisableBlending();
|
||||
void SetBlendFunc(GLenum src, GLenum dst);
|
||||
|
||||
// ── Depth ───────────────────────────────────────────────────────────────
|
||||
void EnableDepthTest();
|
||||
void DisableDepthTest();
|
||||
void SetDepthFunc(GLenum func);
|
||||
void SetDepthMask(bool write);
|
||||
|
||||
// ── Culling ─────────────────────────────────────────────────────────────
|
||||
void EnableCullFace();
|
||||
void DisableCullFace();
|
||||
void SetCullFace(GLenum face);
|
||||
|
||||
// ── Scissor ─────────────────────────────────────────────────────────────
|
||||
void EnableScissorTest();
|
||||
void DisableScissorTest();
|
||||
void SetScissor(int x, int y, int width, int height);
|
||||
|
||||
// ── Wireframe ───────────────────────────────────────────────────────────
|
||||
void SetWireframe(bool enabled);
|
||||
|
||||
// ── Color Mask ──────────────────────────────────────────────────────────
|
||||
void SetColorMask(bool r, bool g, bool b, bool a);
|
||||
|
||||
// ── Textures ────────────────────────────────────────────────────────────
|
||||
void ActiveTexture(size_t textureUnit);
|
||||
|
||||
} // namespace OpenGL
|
||||
|
||||
Reference in New Issue
Block a user