From d7ad154d20888a4880b5dfba1d81713439168c39 Mon Sep 17 00:00:00 2001 From: shinya Date: Thu, 21 May 2026 12:30:30 +0200 Subject: [PATCH] updated ai shader --- shader_example/motion.frag | 1 - shader_example/shader.cpp | 30 ++++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/shader_example/motion.frag b/shader_example/motion.frag index 50f5edf..084121d 100644 --- a/shader_example/motion.frag +++ b/shader_example/motion.frag @@ -1,5 +1,4 @@ #version 330 core -precision mediump float; in vec2 uv; diff --git a/shader_example/shader.cpp b/shader_example/shader.cpp index 355defa..fc4c952 100644 --- a/shader_example/shader.cpp +++ b/shader_example/shader.cpp @@ -24,6 +24,14 @@ GLuint compile(GLenum t, const std::string& src) const char* c = src.c_str(); glShaderSource(s, 1, &c, NULL); glCompileShader(s); + + GLint ok = 0; + glGetShaderiv(s, GL_COMPILE_STATUS, &ok); + if (!ok) { + char log[1024]; + glGetShaderInfoLog(s, sizeof(log), NULL, log); + std::cout << "shader compile failed:\n" << log; + } return s; } @@ -37,9 +45,9 @@ int main() glewInit(); // ---------------- LOAD IMAGES ---------------- - int w,h,c; - unsigned char* img1 = stbi_load("frame1.jpg",&w,&h,&c,4); - unsigned char* img2 = stbi_load("frame2.jpg",&w,&h,&c,4); + int w,h; + unsigned char* img1 = stbi_load("frame1.jpg",&w,&h,NULL,4); + unsigned char* img2 = stbi_load("frame2.jpg",&w,&h,NULL,4); if(!img1 || !img2) { @@ -48,9 +56,9 @@ int main() } // ---------------- TEXTURES ---------------- - GLuint texA, texB; - glGenTextures(1,&texA); - glGenTextures(1,&texB); + GLuint tex[2]; + glGenTextures(2, tex); + GLuint texA = tex[0], texB = tex[1]; auto upload = [&](GLuint t, unsigned char* d) { @@ -86,6 +94,14 @@ int main() glAttachShader(prog,f); glLinkProgram(prog); + GLint linked = 0; + glGetProgramiv(prog, GL_LINK_STATUS, &linked); + if (!linked) { + char log[1024]; + glGetProgramInfoLog(prog, sizeof(log), NULL, log); + std::cout << "program link failed:\n" << log; + } + // ---------------- QUAD (FIXED) ---------------- GLuint vao,vbo; @@ -142,6 +158,8 @@ int main() glReadPixels(0,0,w,h,GL_RGBA,GL_UNSIGNED_BYTE,out.data()); stbi_write_jpg("frameO.jpg",w,h,4,out.data(),90); + stbi_image_free(img1); + stbi_image_free(img2); std::cout << "done\n"; }