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 drawStrokeStrin g(text, font=GLUT_STROK E_ROMAN):
for c in text:
glutStrokeChara cter(font, ord(c))
def draw():
glClear(GL_COLO R_BUFFER_BIT)
for a in letters:
glPushMatrix()
glTranslatef(a[3], a[3], 3)
glColor3fv(a[2])
glScalef(0.005, 0.005, 0.005)
drawStrokeStrin g(a, GLUT_STROKE_MON O_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(but ton, state, x, y):
print button, state
if button == GLUT_LEFT_BUTTO N and state == GLUT_DOWN:
letters.append([ x,glutGet(GLUT_ WINDOW_HEIGHT)-y, [1,0,0] ])
elif button == GLUT_MIDDLE_BUT TON:
letters.append([ x,glutGet(GLUT_ WINDOW_HEIGHT)-y, [0,1,0] ])
elif button == GLUT_RIGHT_BUTT ON:
letters.append([ x,glutGet(GLUT_ WINDOW_HEIGHT)-y, [0,0,1] ])
glutPostRedispl ay()
glutInit(sys.ar gv)
glutInitDisplay Mode(GLUT_DOUBL E | GLUT_RGB)
glutInitWindowS ize(400, 400)
glutCreateWindo w(sys.argv[0])
glutDisplayFunc (draw)
glutKeyboardFun c(keyboard)
glutMouseFunc(m ousebutton)
glutReshapeFunc (reshape)
reshape(400,400 )
glutMainLoop()
0 1231 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 2.0.2.01 (and
also with older versions).
When I call glutGetModifiers from event handler functions (set using
glutMouseFunc, glutMotionFunc etc...), it just says:
"GLUT: Warning in foo: glutCurrentModifiers: do not call outside core
input callback."
|
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, and glRenderMode
properly returns the number of hits when put back into GL_RENDER mode,
but I don't see any way within PyOpenGL itself to access the select
buffer to actually process the hits. Is there any way to do this
without using...
|
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 n'existe pas pour python 2.5 ?!!! de plus
il semble que pyopengl est été abandonné depuis 2005 ? plus rien ne
bouge sur le site...
je suis sous windows et je ne dispose pas des outils pour faire moi
|
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),
POINTER(arrays.GLcharARBArray)(string), GLintArray(length) ) -None
|
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 PyOpenGL-3.0.0a5-py2.5.egg
pyOpenGL is installed in
| |
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 as well as
linux (Ubuntu 7.04) . Strangely, my pleas for the same on pyopengl
have gone unanswered.
http://sourceforge.net/mailarchive/forum.php?thread_name=511f47f50704260036y2888db21p5cf650a7e472559b%40mail.gmail.com&forum_name=pyopengl-users...
|
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: Priithon).
For Priithon I put all modules/packages in a simple / single directory
(tree) including one starting batch/script file. This script sets up
PYTHONPATH to find modules at this place.
It works fine for Windows,Linux and Mac-OSX.
Now I...
|
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
http://downloads.sourceforge.net/pyopengl/PyOpenGL-3.0.0b3.zip?modtime=1213363873&big_mirror=0
Processing PyOpenGL-3.0.0b3.zip
Running PyOpenGL-3.0.0b3\setup.py -q
bdist_egg --dist-dir
c:\docume~1\cjw\locals~1\temp\easy_install-hjyff7\PyOpenGL-3.0.0b3\egg-dist-tmp-iqd53p
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |