void GL_UpdateTexture(gl_effect_layer *Test, void *Data, uint16 Width, uint16 Height, uint16 BytesPerPixel, bool32 Multisample); static uint16 Effect_GL_InitShader(const char *Effect); static void GL_BindDefaultVertexArrays(); void Effect_GL_Start(gl_effect_layer *Test, int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram) { GL_UpdateTexture(Test, EffectBitmapAddress, Width, Height, BytesPerPixel, 0); GL_BindDefaultVertexArrays(); glUseProgram(ShaderProgram); glBindFramebuffer(GL_FRAMEBUFFER, Test->FramebufferObject); glBindRenderbuffer(GL_RENDERBUFFER, Test->Color_Renderbuffer); glBindTexture(GL_TEXTURE_2D, Test->Texture); int ByteFlag = (BytesPerPixel == 4) ? GL_RGBA : GL_RGBA16; int ByteFlag2 = (BytesPerPixel == 4) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; glTexImage2D(GL_TEXTURE_2D, 0, ByteFlag, Width, Height, 0, GL_RGBA, ByteFlag2, EffectBitmapAddress); } void Effect_GL_DrawColor(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram, v4 Color, blend_mode BlendMode) { gl_effect_layer Test = {}; int ByteFlag = (BytesPerPixel == 4) ? GL_RGBA : GL_RGBA16; int ByteFlag2 = (BytesPerPixel == 4) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; Effect_GL_Start(&Test, Width, Height, BytesPerPixel, EffectBitmapAddress, ShaderProgram); int Uniform = glGetUniformLocation(ShaderProgram, "Color"); glUniform4f(Uniform, Color.r, Color.g, Color.b, Color.a); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glReadPixels(0, 0, Width, Height, GL_RGBA, ByteFlag2, EffectBitmapAddress); glBindFramebuffer(GL_FRAMEBUFFER, 0); GL_DeleteHWBuffer(&Test); } void Effect_GL_GaussianBlur(int Width, int Height, int BytesPerPixel, void *EffectBitmapAddress, uint16 ShaderProgram, real32 Radius) { gl_effect_layer Test = {}; int ByteFlag = (BytesPerPixel == 4) ? GL_RGBA : GL_RGBA16; int ByteFlag2 = (BytesPerPixel == 4) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; Effect_GL_Start(&Test, Width, Height, BytesPerPixel, EffectBitmapAddress, ShaderProgram); // horizontal pass int Uniform = glGetUniformLocation(ShaderProgram, "Radius"); glUniform1f(Uniform, Radius + 1.60f); Uniform = glGetUniformLocation(ShaderProgram, "Direction"); glUniform2f(Uniform, 1.0f, 0.0f); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glReadPixels(0, 0, Width, Height, GL_RGBA, ByteFlag2, EffectBitmapAddress); // // vertical pass glTexImage2D(GL_TEXTURE_2D, 0, ByteFlag, Width, Height, 0, GL_RGBA, ByteFlag2, EffectBitmapAddress); Radius = glGetUniformLocation(ShaderProgram, "Direction"); glUniform2f(Uniform, 0.0f, 1.0f); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glReadPixels(0, 0, Width, Height, GL_RGBA, ByteFlag2, EffectBitmapAddress); // glBindFramebuffer(GL_FRAMEBUFFER, 0); GL_DeleteHWBuffer(&Test); }