Added OpenGL error logging, trying to draw colored lines...
parent
207094b0c8
commit
454ea72a85
|
@ -1,8 +1,8 @@
|
|||
#version 150 core
|
||||
#extension GL_ARB_explicit_attrib_location : require
|
||||
|
||||
layout(location = 0) in vec3 inCoord;
|
||||
layout(location = 1) in vec3 inColor;
|
||||
in vec3 inCoord;
|
||||
in vec3 inColor;
|
||||
|
||||
uniform mat4 uModelViewProj;
|
||||
|
||||
|
|
18
src/main.cc
18
src/main.cc
|
@ -43,6 +43,20 @@ static void error_callback(int error, const char* description)
|
|||
fprintf(stderr, "Error (%d): %s\n", error, description);
|
||||
}
|
||||
|
||||
static void opengl_error_callback(
|
||||
GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam )
|
||||
{
|
||||
gLog ("OpenGL Error: %s type %0x%x, severity = 0x%x, message = %s",
|
||||
( type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : "" ),
|
||||
type, severity, message );
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
|
@ -117,6 +131,10 @@ int main(void)
|
|||
std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << endl;
|
||||
std::cout << "GLSL Version : " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
|
||||
|
||||
// During init, enable debug output
|
||||
glEnable ( GL_DEBUG_OUTPUT );
|
||||
glDebugMessageCallback( (GLDEBUGPROC) opengl_error_callback, 0 );
|
||||
|
||||
// imgui initialization.
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
|
|
|
@ -42,10 +42,10 @@ static const GLfloat g_textured_quad_vertex_buffer_data[] = {
|
|||
};
|
||||
|
||||
static const GLfloat g_coordinate_system_vertex_buffer_data[] = {
|
||||
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 255.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f, 255.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f
|
||||
};
|
||||
|
@ -296,10 +296,13 @@ void Renderer::RenderGl() {
|
|||
// glDrawArrays(GL_TRIANGLES, 0, 3); // starting from vertex 0; 3 vertices total
|
||||
glDisableVertexAttribArray(0);
|
||||
|
||||
glBindAttribLocation(mDefaultProgram.mProgramId, 0, "inCoord");
|
||||
glBindAttribLocation(mDefaultProgram.mProgramId, 1, "inColor");
|
||||
|
||||
// Coordinate system
|
||||
glBindVertexArray(mCoordinateSystem.mVertexArrayId);
|
||||
glEnableVertexAttribArray(0);
|
||||
glUniform4fv(muDefaultColor, 1, Vector4f(1.0f, 0.0f, 1.0f, 1.0f).data());
|
||||
glUniform4fv(muDefaultColor, 1, Vector4f(1.0f, 0.0f, 0.0f, 1.0f).data());
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mCoordinateSystem.mVertexBuffer);
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
|
|
|
@ -19,7 +19,7 @@ using namespace SimpleMath;
|
|||
//
|
||||
|
||||
RenderProgram::~RenderProgram() {
|
||||
if (mProgramId > 0)
|
||||
if (mProgramId != -1)
|
||||
glDeleteProgram(mProgramId);
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,6 @@ void Texture::MakeGrid(const int& size, const Vector3f &c1, const Vector3f &c2)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
glGenTextures(1, &mTextureId);
|
||||
glBindTexture(GL_TEXTURE_2D, mTextureId);
|
||||
|
||||
|
|
Loading…
Reference in New Issue