praxmon
praxmon

Reputation: 5121

Invalid Enumerant

I am using OpenGL to draw a line. The code is:

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import sys
def init():
    glClearColor(1.0, 1.0, 1.0, 1.0)
    gluOrtho2D(-100.0, 100.0, -100.0, 100.0)

def plotpoints():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(0.0, 0.5, 0.0)
    glPointSize(4.0)
    glBegin(GL_LINE)
    glVertex2f(50.0,0.0)
    glVertex2f(10.0,0.0)
    glEnd()
    glFlush()

def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB)
    glutInitWindowSize(500,500)
    glutInitWindowPosition(100,100)
    glutCreateWindow("Again")
    glutDisplayFunc(plotpoints)
    init()
    glutMainLoop()

main()

The problem is, on execution I get the error:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\OpenGL\GLUT\special.py", line 121, in safeCall
    return function( *args, **named )
  File "C:\Users\Administrator\Desktop\eclipse\Python Projects\Serverclient\Try.py", line 16, in plotpoints
    glEnd()
  File "C:\Python27\lib\site-packages\OpenGL\latebind.py", line 61, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
  File "C:\Python27\lib\site-packages\OpenGL\GL\exceptional.py", line 57, in glEnd
    return baseFunction( )
  File "C:\Python27\lib\site-packages\OpenGL\error.py", line 208, in glCheckError
    baseOperation = baseOperation,
GLError: GLError(
    err = 1280,
    description = 'invalid enumerant',
    baseOperation = glEnd,
    cArguments = ()
)
GLUT Display callback <function plotpoints at 0x02D6FAB0> with (),{} failed: returning None GLError(
    err = 1280,
    description = 'invalid enumerant',
    baseOperation = glEnd,
    cArguments = ()
)

Where am I going wrong?

Upvotes: 1

Views: 1944

Answers (1)

user1118321
user1118321

Reputation: 26345

I think the problem is that you need GL_LINES in the call to glBegin() rather than GL_LINE. They are 2 different values used for 2 different things.

Upvotes: 2

Related Questions