[solved] OpenGL example - ok running remotely, but ...
Posted: Fri Mar 04, 2011 04:15
update: Solved; needed reshape,display callbacks, and usual glut event processing (see post below).
I've managed to build the CEGUI 0.75 from source (on a puppy linux 4.31 devx system), and get the Samples running (all the ones I've tried, at any rate).
After going through the "Using CEGUI with GLUT" tutorial (with modifications from various CEGUI Beginner's Guides) I have manged to get the (glut teapot) gui_loop.cpp example running and displaying TextDemo.layout nicely with TaharezLook.scheme over the teapot; the CEGUI window movable, all responding beautifully!
However, this was run from a remote ssh (tunneling; not using direct rendering) ... When I ran it from the system itself (no tunneling, no ssh, but run locally), I was quite surprised to see the glut teapot - but no CEGUI window. (No error messages or other indications anything was amiss either.) CEGUI.log and code snippets follow.
CEGUI.log excerpt
gui_loop.cpp program adapted from tutorial example
http://www.cegui.org.uk/wiki/index.php/Using_CEGUI_with_GLUT
(skipping functions that are identical to ones in Using_CEGUI_with_GLUT example)
I have that user headspace error feeling. I'm betting someone here will quickly spot what I've done wrong.
(Once I get this going it might be nice to update the Using_CEGUI_with_GLUT tutorial with the missing/changed v0.75 bits.)
Cheers,
Doug
I've managed to build the CEGUI 0.75 from source (on a puppy linux 4.31 devx system), and get the Samples running (all the ones I've tried, at any rate).
After going through the "Using CEGUI with GLUT" tutorial (with modifications from various CEGUI Beginner's Guides) I have manged to get the (glut teapot) gui_loop.cpp example running and displaying TextDemo.layout nicely with TaharezLook.scheme over the teapot; the CEGUI window movable, all responding beautifully!
However, this was run from a remote ssh (tunneling; not using direct rendering) ... When I ran it from the system itself (no tunneling, no ssh, but run locally), I was quite surprised to see the glut teapot - but no CEGUI window. (No error messages or other indications anything was amiss either.) CEGUI.log and code snippets follow.
CEGUI.log excerpt
Code: Select all
04/03/2011 03:31:57 (Std) ********************************************************************************
04/03/2011 03:31:57 (Std) * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
04/03/2011 03:31:57 (Std) ********************************************************************************
04/03/2011 03:31:57 (Std) ---- Version 0.7.5 (Build: Feb 25 2011 GNU/Linux g++ 4.2.2 32 bit) ----
04/03/2011 03:31:57 (Std) ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer
module. TextureTarget support is not available :( No glBlendFuncSeparate(EXT) support. ----
04/03/2011 03:31:57 (Std) ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI --
--
04/03/2011 03:31:57 (Std) ---- Image Codec module is: FreeImageCodec - FreeImage based image codec ----
04/03/2011 03:31:57 (Std) ---- Scripting module is: None ----
04/03/2011 03:31:57 (Std) ********************************************************************************
04/03/2011 03:31:57 (Std) * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
04/03/2011 03:31:57 (Std) ********************************************************************************
gui_loop.cpp program adapted from tutorial example
http://www.cegui.org.uk/wiki/index.php/Using_CEGUI_with_GLUT
Code: Select all
#include <cstdlib>
#include <GL/freeglut.h>
#include "CEGUI.h"
#include "CEGUIOpenGL.h"
#include "CEGUIOpenGLRenderer.h"
using namespace CEGUI;
/*****************************************************************************/
/*** same as: http://www.cegui.org.uk/wiki/index.php/Using_CEGUI_with_GLUT ***/
(skipping functions that are identical to ones in Using_CEGUI_with_GLUT example)
Code: Select all
/*** end same as http://www.cegui.org.uk/wiki/index.php/Using_CEGUI_with_GLUT ***/
/********************************************************************************/
// A barebones GLUT application
int main( int argc, char **argv)
{
// Create our OpenGL Window
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA );
glutInitWindowSize(640, 480);
window_id = glutCreateWindow("GLUT Loop");
// Bootstrap CEGUI::System with an OpenGLRenderer object that uses the
// current GL viewport, the DefaultResourceProvider, and the default
// ImageCodec.
CEGUI::OpenGLRenderer& myRenderer = CEGUI::OpenGLRenderer::bootstrapSystem();
// set the default resource groups to be used
// initialise the required dirs for the DefaultResourceProvider
CEGUI::DefaultResourceProvider* rp =
static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());
const char* dataPathPrefix = "./datafiles";
char resourcePath[PATH_MAX];
// for each resource type, set a resource group directory
sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
rp->setResourceGroupDirectory("schemes", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
rp->setResourceGroupDirectory("imagesets", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
rp->setResourceGroupDirectory("fonts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
rp->setResourceGroupDirectory("layouts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
rp->setResourceGroupDirectory("looknfeels", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
rp->setResourceGroupDirectory("lua_scripts", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "xml_schemas/");
rp->setResourceGroupDirectory("schemas", resourcePath);
sprintf(resourcePath, "%s/%s", dataPathPrefix, "animations/");
rp->setResourceGroupDirectory("animations", resourcePath);
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
CEGUI::AnimationManager::setDefaultResourceGroup("animations");
// setup default group for validation schemas
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))
parser->setProperty("SchemaDefaultResourceGroup", "schemas");
// create (load) the TaharezLook scheme file
// (this auto-loads the TaharezLook looknfeel and imageset files)
CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );
// create (load) a font.
CEGUI::FontManager::getSingleton().create( "DejaVuSans-10.font" );
Window* myRoot = WindowManager::getSingleton().loadWindowLayout( "TextDemo.layout");
System::getSingleton().setGUISheet( myRoot );
// Set some input handlers
glutKeyboardFunc(myKeyboardFunc); // key pressed
glutKeyboardUpFunc(myKeyboardUpFunc); // key released
glutSpecialFunc(mySpecialFunc); // special key pressed
glutSpecialUpFunc(mySpecialUpFunc); // special key released
glutMouseFunc(myMouseFunc); // any mouse button press or release
glutPassiveMotionFunc(myPassiveMotionFunc); // mouse movement with no buttons held
glutMotionFunc(myMotionFunc); // mouse movement with any button held
// clearing this queue actually makes sure it's created(!) // ??
myRenderer.getDefaultRenderingRoot().clearGeometry(CEGUI::RQ_OVERLAY);
myRenderer.enableExtraStateSettings(true); // ??
while( keep_running )
{
glutMainLoopEvent();
render();
glFlush();
CEGUI::System::getSingleton().renderGUI();
glutSwapBuffers();
}
glutDestroyWindow(window_id); // Exit gracefully
return 0;
}
void render()
{
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutWireTeapot( 0.5 );
}
I have that user headspace error feeling. I'm betting someone here will quickly spot what I've done wrong.
(Once I get this going it might be nice to update the Using_CEGUI_with_GLUT tutorial with the missing/changed v0.75 bits.)
Cheers,
Doug