[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] 3D sample code
On Mon, June 11, 2007 2:05 pm, David wrote:
> My previous response indicated that the Lamina demo should work with an
> installed Ocemp GUI. Actually, it will not work with the 0.2 version, but
> needs the 0.1 version; It needs the dirty-rectangle list from update, to
> know when to regenerate the texture. Marcus does maintain both versions.
>
>
> Would an example without a GUI, using regular pygame 2d drawing methods,
> be helpful?
Yeah. I tried playing with demo code some more, and still couldn't make it
work. The line in the pseudocode declaring "lamina.LaminaPanelSurface(
(640,480), (-1,1,2,2) )" should have those two parameters switched, for
one thing. Here's what I tried this time, and what happened. The upshot is
that I still can't create the Lamina surface at all.
I did try installing OcempGUI, but since there's no Windows installer all
I've got is its source and a setup script with no instructions on how to
install it. How do you use these source packages, anyway?
<code>
## Hacked-together Lamina test
import lamina
##from pygame import display, key, init, event
##from pygame import time as pytime
import pygame
from pygame.locals import *
import OpenGL.GL as ogl
import OpenGL.GLU as oglu
pygame.init()
screen = lamina.LaminaPanelSurface( (-1,1,2,2), (640,480) )
class GUI:
def __init__(self):
global screen
self.screen = screen
def Draw(self):
pygame.draw.rect(self.screen,(255,255,255),(100,100,100,100))
return False
gui = GUI()
# hide mouse cursor
pygame.mouse.set_visible(0)
done = False
while not done:
for event in pygame.event.get():
if event.type == KEYDOWN and event.key == K_ESCAPE:
done = True
# detect changes to surface
changed = gui.Draw()
if changed:
# and mark for update
screen.refresh()
# draw opengl geometry .....
pass
# display gui
# opengl code to set modelview matrix for desired gui surface pos
screen.display()
</code>
Result:
Traceback (most recent call last):
File "C:\Documents and Settings\Owner\Desktop\lamina\lamina_test_k.py",
line 14, in ?
screen = lamina.LaminaPanelSurface( (-1,1,2,2), (640,480) )
File "..\lamina.py", line 112, in __init__
s.clear()
File "..\lamina.py", line 120, in clear
s._surfTotal = raw.convert_alpha()
error: No video mode has been set