Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Python by Kulik ( 16 years ago )
import os, sys
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
os.environ['PATH'] = "YOUR_PATH_WHERE_PYD_FILES_ARE;" + os.environ['PATH']
import CEGUI
import CEGUIOpenGLRenderer
# put datafiles folder from svn to the same directory as this python script
class SampleApp(object):
def __init__(self):
glutInit(sys.argv)
glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA)
glutInitWindowSize(640, 480)
glutInitWindowPosition(100, 100)
glutCreateWindow("Crazy Eddie's GUI Mk-2 - Sample Application")
glutSetCursor(GLUT_CURSOR_NONE)
glutDisplayFunc(self.displayFunc)
glutReshapeFunc(self.reshapeFunc)
glutMotionFunc(self.mouseMotionFunc)
glutPassiveMotionFunc(self.mouseMotionFunc)
CEGUIOpenGLRenderer.OpenGLRenderer.bootstrapSystem()
def __del__(self):
CEGUIOpenGLRenderer.OpenGLRenderer.destroySystem()
def initialiseResources(self):
rp = CEGUI.System.getSingleton().getResourceProvider()
rp.setResourceGroupDirectory("schemes", "./datafiles/schemes")
rp.setResourceGroupDirectory("imagesets", "./datafiles/imagesets")
rp.setResourceGroupDirectory("fonts", "./datafiles/fonts")
rp.setResourceGroupDirectory("layouts", "./datafiles/layouts")
rp.setResourceGroupDirectory("looknfeels", "./datafiles/looknfeel")
rp.setResourceGroupDirectory("schemas", "./datafiles/xml_schemas")
CEGUI.Imageset.setDefaultResourceGroup("imagesets")
CEGUI.Font.setDefaultResourceGroup("fonts")
CEGUI.Scheme.setDefaultResourceGroup("schemes")
CEGUI.WidgetLookManager.setDefaultResourceGroup("looknfeels")
CEGUI.WindowManager.setDefaultResourceGroup("layouts")
parser = CEGUI.System.getSingleton().getXMLParser()
if parser.isPropertyPresent("SchemaDefaultResourceGroup"):
parser.setProperty("SchemaDefaultResourceGroup", "schemas")
def setupUI(self):
CEGUI.SchemeManager.getSingleton().create("TaharezLook.scheme")
CEGUI.System.getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow")
root = CEGUI.WindowManager.getSingleton().createWindow("DefaultWindow", "Root")
CEGUI.System.getSingleton().setGUISheet(root)
self.wnd = CEGUI.WindowManager.getSingleton().createWindow("TaharezLook/FrameWindow", "Demo Window")
root.addChildWindow(self.wnd)
self.wnd.setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
self.wnd.setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0.8, 0)))
self.wnd.setText("Hello World!")
self.wnd.subscribeEvent(CEGUI.Window.EventWindowUpdated, self, "subscriptionTest")
def subscriptionTest(self, e):
print dir(e)
return True
def run(self):
self.initialiseResources()
self.setupUI()
self.lastFrameTime = glutGet(GLUT_ELAPSED_TIME)
self.updateFPS = 0
glutMainLoop()
def displayFunc(self):
thisTime = glutGet(GLUT_ELAPSED_TIME)
elapsed = (thisTime - self.lastFrameTime) / 1000.0
self.lastFrameTime = thisTime
self.updateFPS = self.updateFPS - elapsed
if self.updateFPS <= 0:
elapsed__ = elapsed
if elapsed__ == 0:
elapsed__ = 1
self.wnd.setText(str(1.0 / (elapsed__)))
self.updateFPS = 5
CEGUI.System.getSingleton().injectTimePulse(elapsed)
# do rendering for this frame.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CEGUI.System.getSingleton().renderGUI()
glutPostRedisplay();
glutSwapBuffers();
def reshapeFunc(self, width, height):
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60.0, width / height, 1.0, 50.0)
glMatrixMode(GL_MODELVIEW)
CEGUI.System.getSingleton().notifyDisplaySizeChanged(CEGUI.Size(width, height))
def mouseMotionFunc(self, x, y):
CEGUI.System.getSingleton().injectMousePosition(x, y)
app = SampleApp()
app.run()
Revise this Paste