Re: [pygame] gui with pygame + pyopengl

2008-06-19 Thread Astan Chee

Hi,
Thanks for the suggestion and Im trying it out with pgu. Now Im having 
problems with the pgu interface. Can anyone help me?
I've attached my test code. Its basically a button or event that brings 
up a text entry dialog. So far its fine, as soon as the dialog is 
closed, it wont close. Any ideas?

Cheers
Stan

René Dudfield wrote:

hi,

Lamina allows you to use any pygame 2d gui with opengl.
http://pitchersduel.python-hosting.com/browser/branches/Lamina/

It's fairly easy to use, and comes with demos for ocempgui and pgu.

cheers,



On Wed, Jun 18, 2008 at 2:58 PM, Astan Chee <[EMAIL PROTECTED]> wrote:
  

Hi,
I was wondering if there is a way to get a simple text entry dialog on a
pygame+opengl surface. I've tried several and all of them seem to dislike
doing a .blit on a opengl surface and crash badly whenever I do anything on
it. Are there simple alternatives?
Thanks
Astan

--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose
two."


Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you
are not the intended recipient of this email, you must not disclose or use
the information contained in it. Please notify the sender immediately and
delete this document if you have received it in error. We do not guarantee
this email is error or virus free.







  


--
"Formulations of number theory: Complete, Consistent, Non-trivial. Choose two."



Animal Logic
http://www.animallogic.com

Please think of the environment before printing this email.

This email and any attachments may be confidential and/or privileged. If you 
are not the intended recipient of this email, you must not disclose or use the 
information contained in it. Please notify the sender immediately and delete 
this document if you have received it in error. We do not guarantee this email 
is error or virus free.

#!/usr/bin/env python
# demo of laminar.PanelOverlaySurface, by
#  David Keeney 2006
# based on version of Nehe's OpenGL lesson04
#  by Paul Furber 2001 - [EMAIL PROTECTED]

# you need pgu to be installed, and you need a copy of the default theme directory
#   as 'test_theme', and you need the accompanying config.txt in that test_theme dir.

import sys
sys.path.insert( 0, '..' )

from OpenGL.GL import *
from OpenGL.GLU import *
import pygame
from pygame.locals import *

# import gui stuff
try:
from pgu import gui as pgui
except ImportError:
print "PGU GUI must be installed in order to run this demo. "
print "PGU can be obtained from: "
print " https://sourceforge.net/project/showfiles.php?group_id=145281";
sys.exit()

import lamina

rtri = rquad = 0.0

triOn = quadOn = True
zoomAngle = 45
open_d = None

class OpenDialog(pgui.Dialog):
def __init__(self,**params):
title = pgui.Label("Input Position")

t = pgui.Table()

self.value = pgui.Form()

t.tr()
t.td(pgui.Label("Position: "))
t.td(pgui.Input(name="pos"),colspan=3)

t.tr()
e = pgui.Button("Ok")
e.connect(pgui.CLICK,self.send,pgui.CHANGE)
t.td(e,colspan=2)

e = pgui.Button("Cancel")
e.connect(pgui.CLICK,self.close,None)
t.td(e,colspan=2)

pgui.Dialog.__init__(self,title,t)

def resize((width, height)):
if height==0:
height=1
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(zoomAngle, 1.0*width/height, 0.1, 100.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

def init():
glShadeModel(GL_SMOOTH)
glClearColor(0.0, 0.5, 0.0, 0.0)
glClearDepth(1.0)
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)

def draw():

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(-1.5, 0.0, -6.0)

# draw triangle
global rtri
glRotatef(rtri, 0.0, 1.0, 0.0)

glBegin(GL_TRIANGLES)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(0.0, 1.0, 0.0)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-1.0, -1.0, 0)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(1.0, -1.0, 0)
glEnd()

# draw quad
glLoadIdentity()
glTranslatef(1.5, 0.0, -6.0)
global rquad
glRotatef(rquad, 1.0, 0.0, 0.0)

glColor3f(0.5, 0.5, 1.0)
glBegin(GL_QUADS)
glVertex3f(-1.0, 1.0, 0)
glVertex3f(1.0, 1.0, 0)
glVertex3f(1.0, -1.0, 0)
glVertex3f(-1.0, -1.0, 0)
glEnd()

# draw gui
glLoadIdentity()
global gui_screen
gui_screen.display()


def main():

global rtri, rquad, gui_screen, open_d
video_flags = OPENGL|DOUBLEBUF

pygame.init()
pygame.display.set_mode((640,480), video_flags)
font = pygame.font.SysFont("default", 18)
fontBig = pygame.font.SysFont("default", 24)
fontSub = pygame.font.SysFont("default", 20)
theme = pgui.

Re: [pygame] gui with pygame + pyopengl

2008-06-17 Thread René Dudfield
hi,

Lamina allows you to use any pygame 2d gui with opengl.
http://pitchersduel.python-hosting.com/browser/branches/Lamina/

It's fairly easy to use, and comes with demos for ocempgui and pgu.

cheers,



On Wed, Jun 18, 2008 at 2:58 PM, Astan Chee <[EMAIL PROTECTED]> wrote:
> Hi,
> I was wondering if there is a way to get a simple text entry dialog on a
> pygame+opengl surface. I've tried several and all of them seem to dislike
> doing a .blit on a opengl surface and crash badly whenever I do anything on
> it. Are there simple alternatives?
> Thanks
> Astan
>
> --
> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose
> two."
>
>
> Animal Logic
> http://www.animallogic.com
>
> Please think of the environment before printing this email.
>
> This email and any attachments may be confidential and/or privileged. If you
> are not the intended recipient of this email, you must not disclose or use
> the information contained in it. Please notify the sender immediately and
> delete this document if you have received it in error. We do not guarantee
> this email is error or virus free.
>
>
>
>