Foros del Web » Programando para Internet » Python »

como instalo pyOpengl

Estas en el tema de como instalo pyOpengl en el foro de Python en Foros del Web. me podrian decir lo que enverdad necesito para instalar pyOpenGl me quede en el archivo ez_setup.py y nose si compilarlo o va sobre el archivo ...
  #1 (permalink)  
Antiguo 14/01/2009, 19:31
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Pregunta como instalo pyOpengl

me podrian decir lo que enverdad necesito para instalar pyOpenGl me quede en el archivo ez_setup.py y nose si compilarlo o va sobre el archivo setup.py para ejecutar oque no entendi en la pagina bueno lo demas si pero lo de este archivo m m!
  #2 (permalink)  
Antiguo 16/01/2009, 12:46
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: como instalo pyOpengl

http://downloads.sourceforge.net/pyo...1&big_mirror=0

¿lo descargaste de ahí?
  #3 (permalink)  
Antiguo 19/01/2009, 16:06
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Respuesta: como instalo pyOpengl

si pero primero entre a su pagina
  #4 (permalink)  
Antiguo 19/01/2009, 16:17
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: como instalo pyOpengl

Pues si lo descargaste de ahí, tenés un instalador ejecutable que debería haber dejado todo listo


Saludos.
  #5 (permalink)  
Antiguo 20/01/2009, 12:53
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Respuesta: como instalo pyOpengl

a!? pero no se necesita algo mas para que funcione? en su pagina de instalacion dice que necesita tantos archivos para funcionar ¿no?
  #6 (permalink)  
Antiguo 20/01/2009, 13:02
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: como instalo pyOpengl

Bueno pero justamente para eso es el instalador, para que se encargue de copiar todo
Tu nada más pruébalo y fíjate si funciona.


Saludos.
  #7 (permalink)  
Antiguo 20/01/2009, 18:14
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Respuesta: como instalo pyOpengl

encontre un tutorial pero no esta del todo completo como hago que vea las clases en la aplicacion

Código python:
Ver original
  1. import wx
  2. import sys
  3. from wx import glcanvas
  4. from OpenGL.GL import*
  5. from OpenGL.GLUT import*
  6.  
  7. class MyCanvasBase(glcanvas.GLCanvas):
  8.     def __init__(self, parent):
  9.         glcanvas.GLCanvas.__init__(self, parent, -1)
  10.         self.int = False
  11.         #initial mouse position
  12.         self.lastx = self.x = 30
  13.         self.lasty = self.y = 30
  14.         self.size = None
  15.         self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
  16.         self.Bind(wx.EVT_SIZE, self.OnSize)
  17.         self.Bind(wx.EVT_PAINT, self.OnPaint)
  18.         self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)
  19.         self.Bind(wx.WVT_LEFT_UP, self.OnMouseUp)
  20.         self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
  21.  
  22.     def OnEraseBackground(self, event):
  23.         pass
  24.     def OnSize(self, event):
  25.         size = self.size = self.GetClientSize()
  26.         if self.GetContext():
  27.             self.SetCurrent()
  28.             glViewport(0, 0, size.width, size.height)
  29.         event.Skip()
  30.  
  31.     def OnPaint(self, event):
  32.         dc = wx.PaintDC(self)
  33.         self.SetCurrent()
  34.         if not self.init:
  35.             self.InitGL()
  36.             self.init = True
  37.         self.OnDraw()
  38.  
  39.     def OnMouseDown(self, event):
  40.         self.CaptureMouse()
  41.         self.x, self.y = self.lastx, self.lasty = wvt.GetPosition()
  42.  
  43.     def OnMouseUp(self, event):
  44.         self.ReleaseMouse()
  45.  
  46.     def OnMouseMotion(self, event):
  47.         if evt.Dragging() and evt.LeftIsDown():
  48.             self.lastx, self.lasty = self.x, self.y
  49.             self.x, self.y, = evt.GetPosition()
  50.             self.Refresh(False)
  51.  
  52. class CubeCanvas(MyCanvasBase):
  53.     def InitGL(self):
  54.         glMatrixMode(GL_PROJECTION)
  55.         glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0)
  56.  
  57.         #position viewer
  58.         glMatrixMode(GL_MODELVIEW)
  59.         glTranslatef(0.0, 0.0, -2.0)
  60.  
  61.         #position object
  62.         glRotatef(self.y, 1.0, 0.0, 0.0)
  63.         glRotatef(self.x, 0.0, 1.0, 0.0)
  64.  
  65.         glEnable(GL_DEPTH_TEST)
  66.         glEnable(GL_LIGHTING)
  67.         glEnable(GL_LIGHTO)
  68.  
  69.     def OnDraw(self):
  70.         #clear color and depth buffers
  71.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  72.  
  73.         #draw six faces of a cube
  74.         glBegin(GL_QUADS)
  75.         glNormal3f( 0.0, 0.0, 1.0)
  76.         glVertex3f( 0.5, 0.5, 0.5)
  77.         glVertex3f(-0.5, 0.5, 0.5)
  78.         glVertex3f(-0.5,-0.5, 0.5)
  79.         glVertex3f( 0.5,-0.5, 0.5)
  80.  
  81.         glNormal3f( 0.0, 0.0,-1.0)
  82.         glVertex3f(-0.5,-0.5,-0.5)
  83.         glVertex3f(-0.5, 0.5,-0.5)
  84.         glVertex3f( 0.5, 0.5,-0.5)
  85.         glVertex3f( 0.5,-0.5,-0.5)
  86.  
  87.         glNormal3f( 0.0, 1.0, 0.0)
  88.         glVertex3f( 0.5, 0.5, 0.5)
  89.         glVertex3f( 0.5, 0.5,-0.5)
  90.         glVertex3f(-0.5, 0.5,-0.5)
  91.         glVertex3f(-0.5, 0.5, 0.5)
  92.  
  93.         glNormal3f( 0.0,-1.0, 0.0)
  94.         glVertex3f(-0.5,-0.5,-0.5)
  95.         glVertex3f( 0.5,-0.5,-0.5)
  96.         glVertex3f( 0.5,-0.5, 0.5)
  97.         glVertex3f(-0.5,-0.5, 0.5)
  98.  
  99.         glNormal3f( 1.0, 0.0, 0.0)
  100.         glVertex3f( 0.5, 0.5, 0.5)
  101.         glVertex3f( 0.5,-0.5, 0.5)
  102.         glVertex3f( 0.5,-0.5,-0.5)
  103.         glVertex3f( 0.5, 0.5,-0.5)
  104.  
  105.         glNormal3f(-1.0, 0.0, 0.0)
  106.         glVertex3f(-0.5,-0.5,-0.5)
  107.         glVertex3f(-0.5,-0.5, 0.5)
  108.         glVertex3f(-0.5, 0.5, 0.5)
  109.         glVertex3f(-0.5, 0.5,-0.5)
  110.         glEnd()
  111.  
  112.         if self.size is None:
  113.             self.size = self.GetClientSize()
  114.         w, h = self.size
  115.         w = max(w, 1.0)
  116.         h = max(h, 1.0)
  117.         xScale = 180.0 / w
  118.         yScale = 180.0 / h
  119.         glRotatef((self.y - self.lasty) * yScale, 1.0, 0.0, 0.0);
  120.         glRotatef((self.x - self.lastx) * xScale, 0.0, 1.0, 0.0);
  121.  
  122.         self.SwapBuffers()
  123.  
  124. class ConeCanvas(MyCanvasBase):
  125.     def InitGL( self ):
  126.         glMatrixMode(GL_PROYECTION)
  127.         #camera frustrum setup
  128.         glFrustum(-5.0, 0.5, -0.5, 1.0, 3.0)
  129.         glMaterial(GL_FRONT, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
  130.         glMaterial(GL_FRONT, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
  131.         glMaterial(GL_FRONT, GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
  132.         glMaterial(GL_FRONT, GL_SHININESS, 50.0)
  133.         glLight(GL_LIGHTO, GL_AMBIENT, [0.0, 1.0, 0.0, 1.0])
  134.         glLight(GL_LIGHTO, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
  135.         glLight(GL_LIGHTO, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
  136.         glLight(GL_LIGHTO, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
  137.         glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
  138.         glEnable(GL_LIGHTING)
  139.         glEnable(GL_LIGHTO)
  140.         glDepthFunc(GL_LESS)
  141.         glEnable(GL_DEPTH_TEST)
  142.         glCler(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  143.         #position viewer
  144.         glMatrixMode(GL_MODELVIEW)
  145.         #position viewer
  146.         glTranslatef(0.0, 0.0, -2.0);
  147.         #
  148.         glutInit(sys.argv)
  149.  
  150.     def OnDraw(self):
  151.         #clear coor and depth buffers
  152.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  153.         #use a fresh transformation matrix
  154.         glPushMatrix()
  155.         #position object
  156.         #glTranslate(0.0, 0.0, -2.0)
  157.         glRotate(30.0, 1.0, 0.0, 0.0)
  158.         glRotate(30.0, 0.0, 1.0, 0.0)
  159.  
  160.         glTranslate(0, -1, 0)
  161.         glRotate(250, 1, 0, 0)
  162.         glutSolidCone(0.5, 1, 30, 5)
  163.         glPopMatrix()
  164.         glRotatef((self.y - self.lasty), 0.0, 0.0, 1.0);
  165.         glRotatef((self.x - self.lastx), 1.0, 0.0, 0.0);
  166.         #push into visible buffer
  167.         self.SwapBuffers()
  168.  
  169. class MainWindow(wx.Frame):
  170.     def __init__(self, parent = None, id = -1, title ="PyOpenGl example"):
  171.         #Init
  172.         wx.Frame.__init__(self, parent, id, title, size = (400, 200),
  173.                           style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
  174.         self.base = MyCanvasBase(self)
  175.        
  176.  
  177.        
  178.  
  179. if __name__ == '__main__':
  180.     app = wx.App()
  181.     MainWindow().Show()
  182.     app.MainLoop()
  #8 (permalink)  
Antiguo 21/01/2009, 19:13
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: como instalo pyOpengl

Tenés varios errores que el compilador te ayuda a solucionar:

- Línea 19, error de sintaxis ("WVT" en vez de "EVT")
- Línea 10: se crea un atributo self.int que luego se referencia como self.init. Hay que cambiar o el nombre o el uso posterior.
- Línea 67: Se referencia a una constante GL_LIGHTO que no existe. Debe ser GL_LIGHT0. (Cero, no "o" mayúscula)
- Varios errores al referenciar la variable en los eventos: se define como "event" pero se intenta usar como "evt".
- Línea 41: "wvt.GetPosition" cuando debería ser "evt.GetPosition" (en realidad, "event")
- Línea 26: se usa una constante GL_PROYECTION cuando debería ser GL_PROJECTION
- Línea 128: Falta un parámetro para la función glFrustum. Copiada la línea correspondiente del método InitGL de la otra clase
- Línea 142: llamada a una función glCler que no existe. Sí existe glClear

Para terminar, dado que son las "subclases" las que implementan el método InitGL, deberías crear un objeto de la clase CubeCanvas o ConeCanvas, no de MyCanvasBase.

Con esos cambios funciona bien.
El compilador es tu amigo, te dirá los errores que tengas. Debes leer los mensajes que te lanza e intentar solucionar los errores por tí mismo, de otra forma no aprenderás.


Saludos.

Última edición por AlvaroG; 21/01/2009 a las 19:21
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:28.