TomorrowPlusX
2006.11.17, 04:40 PM
So, now and then a few people have asked for my gui code -- which is pretty flattering to be honest.
So, I'm offering it up. The trouble -- or the advantage depending on your viewpoint -- is it comes with a buncha buncha burning other stuff. The whole framework is called SimpleGameFramework, or SGF for short. It's all the malarky which I found myself copying and pasting into different opengl projects and wishing I had as a single basecode.
First, attributions where they belong:
1) The Cocoa toolkit is based off of OneSadCookie's GameShell. It's not 100% GameShell, by any margin, but that's what I started with.
2) It uses a number of open source 3rd party stuff. SlotSig for signal slot event dispatching, GLEW for opengl extensions checking. And libPNG, since I couldn't find libPNG in /usr/lib or wherever and so I had to statically link it in. Oh, and boost, for their smart pointers.
Second, the stuff SGF offers:
1) A basic GLUT like approach, but for C++ -- e.g., subclass sgf::Application and override display() and step(), and other methods for input, or whatever. You can specify at bootstrap time whether you want it to run in "GameMode" or "ApplicationMode" -- the only real difference is that game mode captures full screen when going fullscreen, and lets you use an emulated mouse ( where SGF draws the mouse ). ApplicationMode is more desktop friendly, and lets you integrate cocoa controls ( you basically treat it as a nib-based Cocoa app ).
2) Some useful basic math/geometry stuff, like vec2, vec3, vec4, mat4, quaternion. An AABB class for bounds, and a frustum class which can check to see if AABBs would be visible. A camera class which generates frustums, and can be easily positioned, change FOV, etc.
3) Texture loading, texture management, as well as FBOs -- you'll note that sgf::FrameBufferObject and sgf::Texture derive from sgf::TextureInterface -- which is pretty convenient.
4) Path management. Look up stuff in the app itself, or in packaged bundles, etc. Useful.
5) the sgf::glsl::Program class which makes it easy to load programs from file or string, including macro substitution before compiling. the sgf::glsl::Uniform<T> class which makes it stupid easy to manage uniforms. And the sgf::glsl::Attribute class which makes it stupid easy to manage vertex attributes. I also have convolution mechanisms whereby you can dynamically gaussian blur a texture on the GPU at runtime. I do this with the reflection in my water demo. This makes me happy.
6) a FilterStack API which makes it easy to run full-screen postprocessing filters using glsl.
7) a classloading mechanism for C++. Works for classes compiled into the executable, as well as classes compiled into bundled frameworks and plugins. You can see its usefulness in the Filters demo app, which uses classloading to load filters from SGF.framework, from a packaged bundle DemoFilters.bundle, and from Filters.app/Contents/MacOS/Filters executable directly.
8) An xml-like-but-simpler file format reader/writer with SAX and DOM access. I modeled the DOM access off of TinyXML's approach where it's really easy to lookup the value of a deeply nested child without needing to check each branch. Very easy to use, and the file format is very easily human readable/writable. There's not much likelyhood you'll use this, but I like it.
9) Simple timers. Easy to use, and whic huse signals to register timeouts.
10) A reasonably useful GUI api. With layout management, basic widgets, and primitive themeing. Well, not really. You can swizzle colors, border/background styles, & fonts, but if you really want to change appearance you have to subclass widgets. Plus, I have a render-to-texture hud subclass which lets you mount a fully functional GUI on a surface in your game world. See the WorldHud demo for how to do this.
11) And bugs! Almost certainly. But writing the demo apps helped me track a lot down. I'm porting my "WorldEngine" to use SGF ( SGF came from WorldEngine's toolkit ) and so far it's smooth. I know of one big bug only -- antialiasing only appears to work on my ATI x1600, this is due to my FilterStack system, which makes a lot of use of glCopyTexSubImage, and apparently that doesn't play well with most gl cards/drivers.
12) Doxygen documentation. I'm no master documenter, and I don't know doxygen's ins and outs, but the documentation is good enough that I keep it open all the time while I use SGF to write apps.
You can download it here: http://zakariya.net/shamyl/etc/SGF.zip
If you find bugs, please let me know. If you find it useful, please let me know!
Finally, you'll need to install boost to compile any of this. The projects look for boost in /usr/local/include/boost. SGF doesn't link against it, but needs the headers.
Some screenshots:
AppMode ( Cocoa GUI )
http://zakariya.net/shamyl/etc/SGF_AppMode.png
Filters ( Loading filters via classloader from various sources )
http://zakariya.net/shamyl/etc/SGF_Filters.png
Text display ( displaying entire Matrix FAQ, yet is Teh Snappy, link because it's wide )
http://zakariya.net/shamyl/etc/SGF_Text.png
Water ( lots of GLSL lovin, as well as real-time gaussian blur of reflection )
http://zakariya.net/shamyl/etc/SGF_Water.png
Interactive GUI displayed on a surface on the world -- same app as "AppMode" above, but in GameMode and with a glow filter.
http://zakariya.net/shamyl/etc/SGF_WorldHud.png
So, I'm offering it up. The trouble -- or the advantage depending on your viewpoint -- is it comes with a buncha buncha burning other stuff. The whole framework is called SimpleGameFramework, or SGF for short. It's all the malarky which I found myself copying and pasting into different opengl projects and wishing I had as a single basecode.
First, attributions where they belong:
1) The Cocoa toolkit is based off of OneSadCookie's GameShell. It's not 100% GameShell, by any margin, but that's what I started with.
2) It uses a number of open source 3rd party stuff. SlotSig for signal slot event dispatching, GLEW for opengl extensions checking. And libPNG, since I couldn't find libPNG in /usr/lib or wherever and so I had to statically link it in. Oh, and boost, for their smart pointers.
Second, the stuff SGF offers:
1) A basic GLUT like approach, but for C++ -- e.g., subclass sgf::Application and override display() and step(), and other methods for input, or whatever. You can specify at bootstrap time whether you want it to run in "GameMode" or "ApplicationMode" -- the only real difference is that game mode captures full screen when going fullscreen, and lets you use an emulated mouse ( where SGF draws the mouse ). ApplicationMode is more desktop friendly, and lets you integrate cocoa controls ( you basically treat it as a nib-based Cocoa app ).
2) Some useful basic math/geometry stuff, like vec2, vec3, vec4, mat4, quaternion. An AABB class for bounds, and a frustum class which can check to see if AABBs would be visible. A camera class which generates frustums, and can be easily positioned, change FOV, etc.
3) Texture loading, texture management, as well as FBOs -- you'll note that sgf::FrameBufferObject and sgf::Texture derive from sgf::TextureInterface -- which is pretty convenient.
4) Path management. Look up stuff in the app itself, or in packaged bundles, etc. Useful.
5) the sgf::glsl::Program class which makes it easy to load programs from file or string, including macro substitution before compiling. the sgf::glsl::Uniform<T> class which makes it stupid easy to manage uniforms. And the sgf::glsl::Attribute class which makes it stupid easy to manage vertex attributes. I also have convolution mechanisms whereby you can dynamically gaussian blur a texture on the GPU at runtime. I do this with the reflection in my water demo. This makes me happy.
6) a FilterStack API which makes it easy to run full-screen postprocessing filters using glsl.
7) a classloading mechanism for C++. Works for classes compiled into the executable, as well as classes compiled into bundled frameworks and plugins. You can see its usefulness in the Filters demo app, which uses classloading to load filters from SGF.framework, from a packaged bundle DemoFilters.bundle, and from Filters.app/Contents/MacOS/Filters executable directly.
8) An xml-like-but-simpler file format reader/writer with SAX and DOM access. I modeled the DOM access off of TinyXML's approach where it's really easy to lookup the value of a deeply nested child without needing to check each branch. Very easy to use, and the file format is very easily human readable/writable. There's not much likelyhood you'll use this, but I like it.
9) Simple timers. Easy to use, and whic huse signals to register timeouts.
10) A reasonably useful GUI api. With layout management, basic widgets, and primitive themeing. Well, not really. You can swizzle colors, border/background styles, & fonts, but if you really want to change appearance you have to subclass widgets. Plus, I have a render-to-texture hud subclass which lets you mount a fully functional GUI on a surface in your game world. See the WorldHud demo for how to do this.
11) And bugs! Almost certainly. But writing the demo apps helped me track a lot down. I'm porting my "WorldEngine" to use SGF ( SGF came from WorldEngine's toolkit ) and so far it's smooth. I know of one big bug only -- antialiasing only appears to work on my ATI x1600, this is due to my FilterStack system, which makes a lot of use of glCopyTexSubImage, and apparently that doesn't play well with most gl cards/drivers.
12) Doxygen documentation. I'm no master documenter, and I don't know doxygen's ins and outs, but the documentation is good enough that I keep it open all the time while I use SGF to write apps.
You can download it here: http://zakariya.net/shamyl/etc/SGF.zip
If you find bugs, please let me know. If you find it useful, please let me know!
Finally, you'll need to install boost to compile any of this. The projects look for boost in /usr/local/include/boost. SGF doesn't link against it, but needs the headers.
Some screenshots:
AppMode ( Cocoa GUI )
http://zakariya.net/shamyl/etc/SGF_AppMode.png
Filters ( Loading filters via classloader from various sources )
http://zakariya.net/shamyl/etc/SGF_Filters.png
Text display ( displaying entire Matrix FAQ, yet is Teh Snappy, link because it's wide )
http://zakariya.net/shamyl/etc/SGF_Text.png
Water ( lots of GLSL lovin, as well as real-time gaussian blur of reflection )
http://zakariya.net/shamyl/etc/SGF_Water.png
Interactive GUI displayed on a surface on the world -- same app as "AppMode" above, but in GameMode and with a glow filter.
http://zakariya.net/shamyl/etc/SGF_WorldHud.png