473,240 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

pyopengl help

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():
for a in letters:
glTranslatef(a[3], a[3], 3)
glScalef(0.005, 0.005, 0.005)
drawStrokeString(a, GLUT_STROKE_MONO_ROMAN)

def reshape(width, height):
glViewport(0, 0, width, height)
gluOrtho2D(0, width, 0, height)

def keyboard(key,x,y):
if key == chr(27):

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] ])

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
glutInitWindowSize(400, 400)
Dec 5 '07 #1
0 1198

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Timo Finnilä | last post by:
Hi, I'm having some weird issues with Python 2.4 and PyOpenGL (and also with older versions). When I call glutGetModifiers from event handler functions (set using glutMouseFunc,...
by: Erik Max Francis | last post by:
I was interesting in adding selection and hit testing to ZOE, and was looking at the PyOpenGL wrappers' handling of selection and picking. I see glSelectBuffer to specify the size of the buffer,...
by: Sébastien Ramage | last post by:
Bonjour à tous, Dans la folie j'ai installé le nouveau python, impatient de voir les nouveautés mais je pense que j'ai été un peu rapide car j'ai voulu utiliser pyOpenGL et là problème il...
by: joroy | last post by:
Hi all, I think this is ctypes related but how can I call the glShaderSourceARB function? The function have this header: glShaderSourceARB( GLhandleARB(shaderObj), GLsizei(count),...
by: sweetmelon | last post by:
(I'm a newbie in Python and pyOpenGL.) Environment: WinXP SP2 Python ver. 2.5 WingIDE easy_install is installed PIL, pyNum is installed Download PyOpenGL-3.0.0a5-py2.5.egg run: easy_install...
by: shirish | last post by:
Hi all, Is it possible to have Python+Pygame+PyOpenGL in one compact package so people can play the games released at pyweek.org . I have been having a hard time getting the whole thing on windows...
by: seb.haase | last post by:
Hi, I am distributing a package with a precompiled collection of modules and packages useful for Python based medical/biological/astronomical image analysis and algorithm development. (Codename:...
by: Colin J. Williams | last post by:
I have just installed PyOpenGL and get a series of warning messages: Best match: PyOpenGL 3.0.0b3 Downloading...
by: Clay Hobbs | last post by:
I need a tutorial for PyOpenGL (specifically, to be used with wxPython). I searched with Google and didn't find one. Does anybody know where one is? -- Ratfink
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.