Hello i just followed the youtube tutorial example but it didnt work. I think i cannot use another way becuse then the other videos of the tutorial would be different for me. I just paste the shader code here and not the window creation etc. I also removed the lines that would warn me if something went from (there did not come any errors)
const char* vertexSource = "#version 330 core\n"
"layout (location = 0) in vec3 position;\n"
"out vec3 currentPos;\n"
"void main() {\n"
"gl_Position = vec4(position.x, position.y, position.z, 1.0f);\n"
"currentPos = position;\n"
"}\0";
const char* fragmentSource = "#version 330 core\n"
"in vec3 currentPos;\n"
"out vec4 colour;\n"
"void main() {\n"
"colour = vec4(currentPos.x + 0.5, currentPos.y + 0.5, currentPos.z + 1.0, 1.0);\n"
"}\0";
this are the stings for the shader Here comes the stuff before the while loop
float vertices[] = {
-0.5f, -0.5f, 0.0f,
0.5f, 0.5f, 0.5f,
0.0f, 0.5f, 0.0f
};
unsigned int vaoID;
glGenVertexArrays(1, &vaoID);
glBindVertexArray(vaoID);
unsigned int vboID;
glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
unsigned int vertexshaderID;
vertexshaderID = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexshaderID, 1, &vertexSource, null);
glCompileShader(vertexshaderID);
int success;
glGetShaderiv(vertexshaderID, GL_COMPILE_STATUS, &success);
unsigned int fboID;
glGenBuffers(1, &fboID);
glBindBuffer(GL_ARRAY_BUFFER, fboID);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
unsigned int fragmentshaderID;
fragmentshaderID = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentshaderID, 1, &fragmentSource, null);
glCompileShader(fragmentshaderID);
glGetShaderiv(vertexshaderID, GL_COMPILE_STATUS, &success);
unsigned int shaderProg;
shaderProg = glCreateProgram();
glAttachShader(shaderProg, vertexshaderID);
glAttachShader(shaderProg, fragmentshaderID);
glLinkProgram(shaderProg);
glGetProgramiv(shaderProg, GL_LINK_STATUS, &success);
glUseProgram(shaderProg);
glDeleteShader(vertexshaderID);
glDeleteShader(fragmentshaderID);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*) 0);
glEnableVertexAttribArray(0);
And in the while loop i call
glUseProgram(shaderProg);
glBindVertexArray(vaoID);
glDrawArrays(GL_TRIANGLES, 0, 3);
I watched the video 2 more times but could not find what is wrong! Here is also die YT vid if you need it for some reason: https://www.youtube.com/watch?v=YMIKl2xvh2E&t=916s