Jump to content
  • Advertisement
Sign in to follow this  
gtsown

pyopengl problems

This topic is 3876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everyone, i'm not sure if this is the best place for this post, but since i'm a novice at pyopengl, i thought this might be the place. i have this piece of code which is giving some errors and would like some feedback as to why this is so. using pyopengl. i have a simple list and would like with my mousebutton select the one of the items from the list when the button is pressed. any help on this would be great. thank you in advance... import sys, math, time, string from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * import random letters = ['hello', 'no', 'yes'] print letters def drawStrokeString(text, font=GLUT_STROKE_ROMAN): for c in text: glutStrokeCharacter(font, ord(c)) def draw(): glClear(GL_COLOR_BUFFER_BIT) for a in letters: glPushMatrix() glTranslatef(a[3], a[3], 3) glColor3fv(a[2]) glScalef(0.005, 0.005, 0.005) drawStrokeString(a, GLUT_STROKE_MONO_ROMAN) glPopMatrix() glutSwapBuffers() def reshape(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluOrtho2D(0, width, 0, height) glMatrixMode(GL_MODELVIEW) def keyboard(key,x,y): if key == chr(27): sys.exit(0) def mousebutton(button, state, x, y): print button, state if button == GLUT_LEFT_BUTTON and state == GLUT_DOWN: letters.append([ x,glutGet(GLUT_WINDOW_HEIGHT)-y, [1,0,0] ]) elif button == GLUT_MIDDLE_BUTTON: letters.append([ x,glutGet(GLUT_WINDOW_HEIGHT)-y, [0,1,0] ]) elif button == GLUT_RIGHT_BUTTON: letters.append([ x,glutGet(GLUT_WINDOW_HEIGHT)-y, [0,0,1] ]) glutPostRedisplay() glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(400, 400) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutMouseFunc(mousebutton) glutReshapeFunc(reshape) reshape(400,400) glutMainLoop()

Share this post


Link to post
Share on other sites
Advertisement
Please format the code in a code or source box (see the forums' faq), and post the errors that you are getting.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!