glClear is causing stack corrpution
This commit is contained in:
@ -9,8 +9,11 @@
|
||||
#include "assert/assert.hpp"
|
||||
#include "assert/assertgl.hpp"
|
||||
#include "display/Color.hpp"
|
||||
#include "display/Texture.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
typedef GLuint shadertexturebinding_t;
|
||||
|
||||
enum ShaderOpenGLVariant {
|
||||
GLSL_330_CORE
|
||||
};
|
||||
@ -151,6 +154,18 @@ namespace Dawn {
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderParameterType::BOOLEAN: {
|
||||
auto boolean = (bool_t *)value;
|
||||
glUniform1i(param.location, *boolean ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case ShaderParameterType::TEXTURE: {
|
||||
textureslot_t texture = *((textureslot_t*)value);
|
||||
glUniform1i(param.location, texture);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable("Unsupported ShaderParameterType");
|
||||
}
|
||||
|
@ -23,11 +23,14 @@ void SimpleTexturedShader::getStages(
|
||||
ShaderStageType::VERTEX,
|
||||
"#version 330 core\n"
|
||||
"layout (location = 0) in vec3 aPos;\n"
|
||||
"layout (location = 1) in vec2 aTexCoord;\n"
|
||||
"uniform mat4 u_Projection;\n"
|
||||
"uniform mat4 u_View;\n"
|
||||
"uniform mat4 u_Model;\n"
|
||||
"out vec2 o_TextCoord;\n"
|
||||
"void main() {\n"
|
||||
"gl_Position = u_Projection * u_View * u_Model * vec4(aPos, 1.0);\n"
|
||||
"o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n"
|
||||
"}"
|
||||
);
|
||||
|
||||
@ -37,8 +40,14 @@ void SimpleTexturedShader::getStages(
|
||||
"in vec2 o_TextCoord;\n"
|
||||
"out vec4 o_Color;\n"
|
||||
"uniform vec4 u_Color;\n"
|
||||
"uniform bool u_HasTexture;\n"
|
||||
"uniform sampler2D u_Texture;\n"
|
||||
"void main() {\n"
|
||||
"o_Color = u_Color;"
|
||||
"if(u_HasTexture) {\n"
|
||||
"o_Color = texture(u_Texture, o_TextCoord) * u_Color;\n"
|
||||
"} else {\n"
|
||||
"o_Color = u_Color;"
|
||||
"}\n"
|
||||
"}\n"
|
||||
);
|
||||
break;
|
||||
@ -75,4 +84,16 @@ void SimpleTexturedShader::getStages(
|
||||
&rel->color,
|
||||
ShaderParameterType::COLOR
|
||||
));
|
||||
|
||||
parameters.push_back(ShaderOpenGLParameter(
|
||||
"u_HasTexture",
|
||||
&rel->hasTexture,
|
||||
ShaderParameterType::BOOLEAN
|
||||
));
|
||||
|
||||
parameters.push_back(ShaderOpenGLParameter(
|
||||
"u_Texture",
|
||||
&rel->texture,
|
||||
ShaderParameterType::TEXTURE
|
||||
));
|
||||
}
|
@ -12,6 +12,8 @@ namespace Dawn {
|
||||
glm::mat4 view;
|
||||
glm::mat4 model;
|
||||
struct Color color = COLOR_WHITE;
|
||||
bool hasTexture = false;
|
||||
shadertexturebinding_t texture = 0;
|
||||
};
|
||||
|
||||
class SimpleTexturedShader : public Shader<SimpleTexturedShaderData> {
|
||||
|
Reference in New Issue
Block a user