0
\$\begingroup\$

I am starting with OpenGL and I am translating the code from learnopengl to python and for some reason I am not being able to compile the Vertex Shader. This is all that I have:

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GL.shaders import *
import pygame as pg

pg.init()

screen = pg.display.set_mode((200, 300), pg.DOUBLEBUF | pg.OPENGL | pg.OPENGLBLIT)

VERT = """
#version 330 core

layout (location = 0) in vec2 aPos; // the position variable has attribute position 0

out vec4 vertexColor; // specify a color output to the fragment shader

void main()
{
    gl_Position = vec4(aPos, 1.0); // see how we directly give a vec3 to vec4's constructor
    vertexColor = vec4(0.5, 0.0, 0.0, 1.0); // set the output variable to a dark-red color
}
"""

FRAG = """
#version 330 core

out vec4 FragColor;

in vec4 vertexColor; // the input variable from the vertex shader (same name and same type)  

void main()
{
    FragColor = vertexColor;
} 
"""

vertShader = glCreateShader(GL_VERTEX_SHADER)
glShaderSource(vertShader, VERT)
glCompileShader(vertShader)
VERTstatus = glGetShaderiv(vertShader, GL_COMPILE_STATUS)


if not VERTstatus:
    info = glGetShaderInfoLog(vertShader)
    print("Error in Vertex Shader:")
    print(info.decode("utf-8"))

input()

This code is throwing 2 errors:

ERROR: 0:10: error(#174) Not enough data provided for construction constructor
ERROR: error(#273) 1 compilation errors. No code generated

Why this is throwing this errors? And someone could give me the website for the documentation, because I can't find it?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.