Thread: [Saggui-svn] SF.net SVN: saggui: [470] trunk/examples/xml
Status: Beta
Brought to you by:
juvinious
From: <sag...@li...> - 2007-09-01 14:42:44
|
Revision: 470 http://saggui.svn.sourceforge.net/saggui/?rev=470&view=rev Author: juvinious Date: 2007-09-01 07:42:39 -0700 (Sat, 01 Sep 2007) Log Message: ----------- Added other xml demos Modified Paths: -------------- trunk/examples/xml/CMakeLists.txt Added Paths: ----------- trunk/examples/xml/src/allegrogl.cpp trunk/examples/xml/src/openlayer.cpp trunk/examples/xml/src/sdl.cpp trunk/examples/xml/src/sdlgl.cpp Modified: trunk/examples/xml/CMakeLists.txt =================================================================== --- trunk/examples/xml/CMakeLists.txt 2007-08-31 14:48:53 UTC (rev 469) +++ trunk/examples/xml/CMakeLists.txt 2007-09-01 14:42:39 UTC (rev 470) @@ -29,3 +29,31 @@ target_link_libraries(xml-allegro saggui-xml saggui-alleg saggui) add_dependencies(xml-allegro saggui-xml saggui-alleg saggui) endif(ENABLE_ALLEGRO) + +if(ENABLE_ALLEGROGL) + include_directories(${ALLEGRO_INCLUDE_DIR}) + add_executable(xml-allegrogl src/allegrogl.cpp) + target_link_libraries(xml-allegrogl saggui-xml saggui-agl saggui-alleg saggui) + add_dependencies(xml-allegrogl saggui-xml saggui-agl saggui-alleg saggui) +endif(ENABLE_ALLEGROGL) + +if(ENABLE_OPENLAYER) + include_directories(${ALLEGRO_INCLUDE_DIR} ${ALLEGROGL_INCLUDE_DIR} ${OPENLAYER_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) + add_executable(xml-openlayer src/openlayer.cpp) + target_link_libraries(xml-openlayer saggui-xml saggui-ol saggui-agl saggui-alleg saggui) + add_dependencies(xml-openlayer saggui-xml saggui-ol saggui-agl saggui-alleg saggui) +endif(ENABLE_OPENLAYER) + +if(ENABLE_SDL) + include_directories(${SDL_INCLUDE_DIR}) + add_executable(xml-sdl src/sdl.cpp) + target_link_libraries(xml-sdl saggui-xml saggui-sdl saggui) + add_dependencies(xml-sdl saggui-xml saggui-sdl saggui) +endif(ENABLE_SDL) + +if(ENABLE_SDLGL) + include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) + add_executable(xml-sdlgl src/sdlgl.cpp) + target_link_libraries(xml-sdlgl saggui-xml saggui-sdlgl saggui-sdl saggui) + add_dependencies(xml-sdlgl saggui-xml saggui-sdlgl saggui-sdl saggui) +endif(ENABLE_SDLGL) Copied: trunk/examples/xml/src/allegrogl.cpp (from rev 469, trunk/examples/xml/src/allegro.cpp) =================================================================== --- trunk/examples/xml/src/allegrogl.cpp (rev 0) +++ trunk/examples/xml/src/allegrogl.cpp 2007-09-01 14:42:39 UTC (rev 470) @@ -0,0 +1,145 @@ +/* +SAGGUI (Simplified All Gaming Graphical User Interface) +Copyright (c) 2005-2007, Miguel A. Gavidia +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the "SAGGUI" nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <saggui_agl.h> +#include <saggui.h> +#include <saggui_xml.h> + +using namespace saggui; + +int main() +{ + resourceManager::registerBackend<AGL_SAGGUI>(); + + guiManager::setup("agl"); + + // Create a timer to regulate the logic loop + guiTimer timer, fpsTimer; + int fps=0,fpsCounter =0; + + // Some Variables + bool fullscreen = false; + bool buffered = true; + bool quit = false; + + // Set the resolution of the demo + if(!guiManager::setupScreen(640,480,32,fullscreen, buffered)) + { + std::cout << "Couldn't create display\n"; + return 1; + } + + xmlEngine xml; + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + + listBox *bleh = dynamic_cast<listBox *>(xml.find("list")); + if(bleh)std::cout << "selected item: " << bleh->selectedItem() << "\n"; + + // Main loop + while(!quit){ + + bool draw=false; + while (timer.msecs() >= 1000/60) + { + draw = true; + if(keyInputManager::keyState(keys::ESC)) + { + quit=true; + draw=false; + break; + } + + if(keyInputManager::keyState(keys::NUM_1,true)) + { + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + break; + } + + guiManager::update(); + + timer.reset(); + } + + if(draw) + { + if(fpsTimer.secs()<=1)fpsCounter++; + + allegro_gl_set_allegro_mode(); + + + guiManager::getSystemBuffer()->clearBmp(rgba::BLACK); + resourceManager::getFont()->render(10,10,rgba::WHITE,guiManager::getSystemBuffer(),0,"FPS: %d",fps); + resourceManager::getFont()->render(10,30,rgba::WHITE,guiManager::getSystemBuffer(),0,"Press 1 to reload xml file"); + + guiManager::renderWindows(); + + + + allegro_gl_unset_allegro_mode(); + allegro_gl_flip(); + + } + + if(fpsTimer.secs()>=1) + { + fpsTimer.reset(); + fps=fpsCounter; + fpsCounter=0; + } + while((timer.msecs())==0)timer.sleep(1); + + } + + return 0; +} +END_OF_MAIN() + Copied: trunk/examples/xml/src/openlayer.cpp (from rev 469, trunk/examples/xml/src/allegro.cpp) =================================================================== --- trunk/examples/xml/src/openlayer.cpp (rev 0) +++ trunk/examples/xml/src/openlayer.cpp 2007-09-01 14:42:39 UTC (rev 470) @@ -0,0 +1,139 @@ +/* +SAGGUI (Simplified All Gaming Graphical User Interface) +Copyright (c) 2005-2007, Miguel A. Gavidia +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the "SAGGUI" nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <saggui_ol.h> +#include <saggui.h> +#include <saggui_xml.h> + +using namespace saggui; + +int main() +{ + resourceManager::registerBackend<OPENLAYER_SAGGUI>(); + + guiManager::setup("ol"); + + // Create a timer to regulate the logic loop + guiTimer timer, fpsTimer; + int fps=0,fpsCounter =0; + + // Some Variables + bool fullscreen = false; + bool buffered = true; + bool quit = false; + + // Set the resolution of the demo + if(!guiManager::setupScreen(640,480,32,fullscreen, buffered)) + { + std::cout << "Couldn't create display\n"; + return 1; + } + + xmlEngine xml; + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + + listBox *bleh = dynamic_cast<listBox *>(xml.find("list")); + if(bleh)std::cout << "selected item: " << bleh->selectedItem() << "\n"; + + // Main loop + while(!quit){ + + bool draw=false; + while (timer.msecs() >= 1000/60) + { + draw = true; + if(keyInputManager::keyState(keys::ESC)) + { + quit=true; + draw=false; + break; + } + + if(keyInputManager::keyState(keys::NUM_1,true)) + { + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + break; + } + + guiManager::update(); + + timer.reset(); + } + + if(draw) + { + if(fpsTimer.secs()<=1)fpsCounter++; + + guiManager::getSystemBuffer()->clearBmp(rgba::BLACK); + resourceManager::getFont()->render(10,10,rgba::WHITE,guiManager::getSystemBuffer(),0,"FPS: %d",fps); + resourceManager::getFont()->render(10,30,rgba::WHITE,guiManager::getSystemBuffer(),0,"Press 1 to reload xml file"); + + guiManager::renderWindows(); + + + + } + + if(fpsTimer.secs()>=1) + { + fpsTimer.reset(); + fps=fpsCounter; + fpsCounter=0; + } + while((timer.msecs())==0)timer.sleep(1); + + } + + return 0; +} +END_OF_MAIN() + Copied: trunk/examples/xml/src/sdl.cpp (from rev 469, trunk/examples/xml/src/allegro.cpp) =================================================================== --- trunk/examples/xml/src/sdl.cpp (rev 0) +++ trunk/examples/xml/src/sdl.cpp 2007-09-01 14:42:39 UTC (rev 470) @@ -0,0 +1,139 @@ +/* +SAGGUI (Simplified All Gaming Graphical User Interface) +Copyright (c) 2005-2007, Miguel A. Gavidia +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the "SAGGUI" nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <saggui_sdl.h> +#include <saggui.h> +#include <saggui_xml.h> + +using namespace saggui; + +int main() +{ + resourceManager::registerBackend<SDL_SAGGUI>(); + + guiManager::setup("sdl"); + + // Create a timer to regulate the logic loop + guiTimer timer, fpsTimer; + int fps=0,fpsCounter =0; + + // Some Variables + bool fullscreen = false; + bool buffered = true; + bool quit = false; + + // Set the resolution of the demo + if(!guiManager::setupScreen(640,480,32,fullscreen, buffered)) + { + std::cout << "Couldn't create display\n"; + return 1; + } + + xmlEngine xml; + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + + listBox *bleh = dynamic_cast<listBox *>(xml.find("list")); + if(bleh)std::cout << "selected item: " << bleh->selectedItem() << "\n"; + + // Main loop + while(!quit){ + + bool draw=false; + while (timer.msecs() >= 1000/60) + { + draw = true; + if(keyInputManager::keyState(keys::ESC)) + { + quit=true; + draw=false; + break; + } + + if(keyInputManager::keyState(keys::NUM_1,true)) + { + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + break; + } + + guiManager::update(); + + timer.reset(); + } + + if(draw) + { + if(fpsTimer.secs()<=1)fpsCounter++; + + guiManager::getSystemBuffer()->clearBmp(rgba::BLACK); + resourceManager::getFont()->render(10,10,rgba::WHITE,guiManager::getSystemBuffer(),0,"FPS: %d",fps); + resourceManager::getFont()->render(10,30,rgba::WHITE,guiManager::getSystemBuffer(),0,"Press 1 to reload xml file"); + + guiManager::renderWindows(); + + + + } + + if(fpsTimer.secs()>=1) + { + fpsTimer.reset(); + fps=fpsCounter; + fpsCounter=0; + } + while((timer.msecs())==0)timer.sleep(1); + + } + + SDL_Quit(); + return 0; +} + Added: trunk/examples/xml/src/sdlgl.cpp =================================================================== --- trunk/examples/xml/src/sdlgl.cpp (rev 0) +++ trunk/examples/xml/src/sdlgl.cpp 2007-09-01 14:42:39 UTC (rev 470) @@ -0,0 +1,213 @@ +/* +SAGGUI (Simplified All Gaming Graphical User Interface) +Copyright (c) 2005-2007, Miguel A. Gavidia +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the "SAGGUI" nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <saggui_sdlgl.h> +#include <saggui.h> +#include <saggui_xml.h> + +using namespace saggui; + +void beginDraw() +{ + glPushAttrib( + GL_COLOR_BUFFER_BIT | + GL_CURRENT_BIT | + GL_DEPTH_BUFFER_BIT | + GL_ENABLE_BIT | + GL_FOG_BIT | + GL_LIGHTING_BIT | + GL_LINE_BIT | + GL_POINT_BIT | + GL_POLYGON_BIT | + GL_SCISSOR_BIT | + GL_STENCIL_BUFFER_BIT | + GL_TEXTURE_BIT | + GL_TRANSFORM_BIT | + GL_POINT_BIT | + GL_LINE_BIT + ); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glOrtho(0.0, (double)640, (double)480, 0.0, -1.0, 1.0); + + glDisable(GL_LIGHTING); + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + + glEnable(GL_SCISSOR_TEST); + glPointSize(1.0); + glLineWidth(1.0); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); +} + +void endDraw() +{ + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + + glPopAttrib(); + +} + +int main() +{ + resourceManager::registerBackend<SDLGL_SAGGUI>(); + + guiManager::setup("sdl"); + + // Create a timer to regulate the logic loop + guiTimer timer, fpsTimer; + int fps=0,fpsCounter =0; + + // Some Variables + bool fullscreen = false; + bool buffered = true; + bool quit = false; + + // Set the resolution of the demo + if(!guiManager::setupScreen(640,480,32,fullscreen, buffered)) + { + std::cout << "Couldn't create display\n"; + return 1; + } + glMatrixMode(GL_PROJECTION); // projection transforms + glLoadIdentity(); // reset the matrix + glOrtho (0.0, 640, 480, 0.0, -1.0, 1.0); // 2D mode - 640x480 with a Z of -1 to 1 + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + xmlEngine xml; + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + + listBox *bleh = dynamic_cast<listBox *>(xml.find("list")); + if(bleh)std::cout << "selected item: " << bleh->selectedItem() << "\n"; + + // Main loop + while(!quit){ + + bool draw=false; + while (timer.msecs() >= 1000/60) + { + draw = true; + if(keyInputManager::keyState(keys::ESC)) + { + quit=true; + draw=false; + break; + } + + if(keyInputManager::keyState(keys::NUM_1,true)) + { + try + { + xml.load("test.xml"); + } + catch(const sagguiException &e) + { + std::cout << "Couldn't load xml file! Reason: " + e.getReason() + "\n"; + } + break; + } + + guiManager::update(); + + timer.reset(); + } + + if(draw) + { + if(fpsTimer.secs()<=1)fpsCounter++; + beginDraw(); + + guiManager::getSystemBuffer()->clearBmp(rgba::BLACK); + resourceManager::getFont()->render(10,10,rgba::WHITE,guiManager::getSystemBuffer(),0,"FPS: %d",fps); + resourceManager::getFont()->render(10,30,rgba::WHITE,guiManager::getSystemBuffer(),0,"Press 1 to reload xml file"); + + guiManager::renderWindows(); + + + + glFinish(); + SDL_GL_SwapBuffers(); + + endDraw(); + + } + + if(fpsTimer.secs()>=1) + { + fpsTimer.reset(); + fps=fpsCounter; + fpsCounter=0; + } + while((timer.msecs())==0)timer.sleep(1); + + } + + SDL_Quit(); + return 0; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |