[ syntax error with glfloat python? ]
I am getting this error (note the code is from openGL red book:
GLfloat mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
^
SyntaxError: invalid syntax
for the following code, i know i need to import something use GLfloat, can you any one tell me what do i need to import for doing this in python.
GLfloat mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
GLfloat mat_shininess[] = { 32.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST)
Answer 1
Basic Python syntax issues here. First, in Python, you don't declare the variable type (GLfloat
). Second (related to the first), you don't need the square braces after the variable name ([]
) to denote that it is an array. And third, to use a list in Python (similar to an array), you need to wrap the contents in square brackets ([]
), not curly brackets ({}
). Taking all that into account, it should look like:
mat_specular = [0.8, 0.8, 0.8, 1]
All that being said, even if you do manage to convert the code to Python, you need to first find libraries that you can use from Python. Using functions with the same names doesn't magically make OpenGL work.