Fixing circle shader

This commit is contained in:
John Alanbrook 2023-02-26 17:28:52 +00:00
parent 186c83659c
commit b2b54ddce9
3 changed files with 22 additions and 4 deletions

View file

@ -26,6 +26,7 @@ void debugdraw_init()
{
circleShader = MakeShader("circlevert.glsl", "circlefrag.glsl");
shader_setUBO(circleShader, "Projection", 0);
shader_setUBO(circleShader, "Resolution", 0);
glGenBuffers(1, &circleVBO);
glGenVertexArrays(1, &circleVAO);

View file

@ -60,6 +60,7 @@ struct sprite *tsprite = NULL;
static unsigned int projUBO;
static unsigned int resUBO;
void debug_draw_phys(int draw) {
debugDrawPhysics = draw;
@ -107,6 +108,14 @@ void openglInit()
shader_setUBO(spriteShader, "Projection", 0);
shader_setUBO(textShader, "Projection", 0);
shader_setUBO(animSpriteShader, "Projection", 0);
/*
glGenBuffers(1,&resUBO);
glBindBuffer(GL_UNIFORM_BUFFER, resUBO);
glBufferData(GL_UNIFORM_BUFFER, sizeof(float)*2, NULL, GL_DYNAMIC_DRAW);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, resUBO, 0, sizeof(float)*2);
glBindBuffer(GL_UNIFORM_BUFFER,0);
*/
}
@ -126,7 +135,6 @@ void add_zoom(float val) { zoom = val; }
void openglRender(struct window *window)
{
glCullFace(GL_BACK);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -150,7 +158,11 @@ void openglRender(struct window *window)
glBindBuffer(GL_UNIFORM_BUFFER, projUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, projection);
/*
float res[2] = {window->width, window->height};
glBindBuffer(GL_UNIFORM_BUFFER, resUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(float)*2, res);
*/
/* Game sprites */
switch (renderMode) {

View file

@ -7,8 +7,13 @@ layout (std140) uniform Projection
mat4 projection;
};
layout (std140) uniform Resolution
{
vec2 resolution;
};
void main()
{
gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);
coords = vertex.zw;
}
coords = vertex.zw*resolution;
}