Valid
	XHTML 1.1! Valid CSS!
Created 2004-06-01   Modified 2009-04-11
Chelton Evans

proj graphicslib home

Intro
Discussion
    Efficiency
    Example
Source
History
TODO

Source

Files

Makefile
OpenGLtemplated.h
OpenGLtemplatedtest.cpp
OpenGLtemplatedtest.h
colorfunction.h
gobj.cpp
gobj.h
gobjbase.cpp
gobjbase.h
gobjdebug.h
gobjdebug01.cpp
gobjdebug01.h
gobjdebug01macrofunctions.h
gobjdebug01test.cpp
gobjdebug01test.h
gobjtest.cpp
gobjtest.h
graphicsImmediateDeferred.cpp
graphicsImmediateDeferred.h
graphicsImmediateDeferredSwitch.cpp
graphicsImmediateDeferredSwitch.h
graphicsImmediateDeferredTest.cpp
graphicsImmediateDeferredTest.h
graphmisc.cpp
graphmisc.h
graphmisctest.cpp
graphmisctest.h
main.cpp
menusystem.cpp
menusystem.h
menusystemtest.cpp
menusystemtest.h
myglutgui.cpp
myglutgui.h
pointsdisplay.h
pointsgraph.cpp
pointsgraph.h
pointsgraphtimeD2.cpp
pointsgraphtimeD2.h
pointsurface.cpp
pointsurface.h
pointsurfacetest.cpp
pointsurfacetest.h
primitivewindow.cpp
primitivewindow.h
test05.cpp
test05.h
test06.cpp
test06.h
test07.cpp
test07.h
textoverlay.cpp
textoverlay.h
triangleindexed.h
triangles3Tdisplay.h
triangles3Tdisplaymulticolored.h
triangles3Tdisplaytest.cpp
triangles3Tdisplaytest.h
windowscaleD2.cpp
windowscaleD2.h
windowscaleD2test.cpp
windowscaleD2test.h

gobjlog.txt
projcompile.txt
settings.txt
temp.txt
tempdoc.txt
testscript001.txt
unittestsreport.txt

Doxygen

main.cpp
Makefile
OpenGLinitialisation
OpenGLtemplatedtest
camera
colorfunction
framerate
glColor3T
glColor3Tv
glColor4T
glColor4Tv
glNormal3T
glNormal3Tv
glTranslateT
glVertex2T
glVertex2Tv
glVertex3T
glVertex3Tv
glVertex4T
glVertex4Tv
gltextmsg
gobj
gobjContainer
gobjContainerPrePost
gobjContainerSwitch
gobjContainerdeque
gobjGlobal
gobjMyArrow
gobjMyBitmapCharacter
gobjMyCircle
gobjMyCircleDraw
gobjMyDiskDraw
gobjMySphereDraw
gobjMyTranslateDraw
gobjQuadric
gobjSwitch
gobjcallback
gobjcallbackcontainer
gobjdebug01
gobjdebug01list
gobjdebug01test
gobjglBegin
gobjglBlendFunc
gobjglCallList
gobjglClear
gobjglClearAccum
gobjglClearColor
gobjglClearDepth
gobjglClearIndex
gobjglClearStencil
gobjglClipPlane
gobjglColor3d
gobjglColor3f
gobjglColor3ub
gobjglColor4d
gobjglColor4f
gobjglColor4ub
gobjglDepthRange
gobjglDisable
gobjglEnable
gobjglEnd
gobjglEndList
gobjglFlush
gobjglGenLists
gobjglLineStipple
gobjglLoadIdentity
gobjglLoadMatrixd
gobjglLoadMatrixf
gobjglMatrixMode
gobjglMultMatrixd
gobjglMultMatrixf
gobjglNewList
gobjglNormal3f
gobjglOrtho
gobjglPopAttrib
gobjglPopMatrix
gobjglPushAttrib
gobjglPushMatrix
gobjglRasterPos2f
gobjglRasterPos2i
gobjglRasterPos3f
gobjglRotated
gobjglRotatef
gobjglTranslated
gobjglTranslatef
gobjglVertex2d
gobjglVertex2f
gobjglVertex3d
gobjglVertex3f
gobjglViewport
gobjgluCylinder
gobjgluDeleteQuadric
gobjgluDisk
gobjgluNewQuadric
gobjgluOrtho2D
gobjgluPartialDisk
gobjgluPerspective
gobjgluQuadricNormals
gobjgluQuadricOrientation
gobjgluQuadricTexture
gobjgluSphere
gobjglutSolidCone
gobjglutSolidCube
gobjglutSolidDodecahedron
gobjglutSolidSphere
gobjglutSolidTeapot
gobjglutSolidTorus
gobjglutWireCone
gobjglutWireCube
gobjglutWireDodecahedron
gobjglutWireSphere
gobjglutWireTeapot
gobjglutWireTorus
gobjtest
graphicsImmediateDeferred
graphicsImmediateDeferredSwitch
graphicsImmediateDeferredTest
graphicsImmediateDeferredTestTri
graphicsImmediateDeferredTestg02
graphmisc
graphmisctest
gridsquare
menusystem
menusystemOneShot
menusystemtest
myLightingTurnOff
myRotate
myaxes
myglCapability
myglMode
myglPushAttrib
myglPushMatrix
myglPushMatrixMode
myglutgui
namefont
pointsdisplay2D
pointsdisplay3D
pointsgraph
pointsgraphtime
pointsgraphtimeD2
pointsurface
pointsurfaceParallelogram
pointsurfaceSphere
pointsurfacetest
primitiveWindow
test05
test06
test07
textoverlay
triangleindexed
triangleindexedN
triangleindexedNref
triangleindexedref
triangles3Tdisplay
triangles3TdisplayCpertriangle
triangles3TdisplayN
triangles3TdisplayNC
triangles3TdisplayNCpertriangle
triangles3Tdisplaymulticolored
triangles3Tdisplaytest
windowscaleD2
windowscaleD2test

Intro

I wanted an object oriented graphics library. So I started making OpenGL function calls into objects, and placing them on a global stack. This technique is very generic and can turn a procedure based API into a fully object orientated environment.

This has resulted in a very flexible and powerful graphics library. See gobj.h. A container class made making a scenegraph easy so by remembering where the objects are in a stack by indexing into the stack parameters can be changed, new geometry added and deleted, ... So this data structure is both a stack and trees in a stack.

All the code produced with this library is essentailly OpenGL. So it does not re interpret graphics and can be easily updated for the next version of OpenGL. The same technique could have been used on other graphics libraries.

The motivation is to give the programmer complete control and OOP is needed to do this. You can easily write your own graphics objects. You can employ advanced memory management strategies, upteenth versions of smart pointers. Stack based programming is amazing.

Discussion

Efficiency

Having each function call wrapped in an object is expensive. However there is nothing to stop you writing a geometric object in the standard OpenGL way and puting that code with many OpenGL calls as a gobj. This is a standard technique used in OOP anyway.

You can also compile the graphics into display lists. The versatility of the stack was why I liked it most. I do not like seeing hard coded function calls in code because the code is always time consuming to modify or change, indeed code written this way is built never to change.

Another strategy I am persuing is to use templates to eliminate virtual function calls. This is inherently hard but as computers get faster the difference between virtual and non-virtual function calls gets greater. And I really want C++ to compete with C so it truely does what C does and is OO too.

To me OOP makes me a much more productive programmer. So while writing a OpenGL function into an object is expensive the positive is an increase in programming freedom. If I encounter a problem where the graphics are too slow I rewrite the object. For example in displaying tessellations I have two graphics containers, one for static geometry and the other for dynamic geometry. In this case the static geometry does change, but less frequently so its updated only when a change occures. The point is that a technique to address the bottleneck is more important if it can solve the bottleneck.

Example

I needed graphics of a mesh that was changing over time. So if I put it on the global stack I would face the problem of not being able to easily delete it and remake the mesh.

By using a gobjContainer object - name the object dynamicgraphics variable, and placing it on the stack instead of all the other graphics then only this container needs to be re-emptied and renewed. This is done by keeping a pointer to the container either directly, or an integer index to the container from the stack base and providing you do not delete any elements below its valid.

So while its good to have this new container, how do I have code that uses it? For example the way I currently write graphics is to write to the global graphics container gobjContainer::global because every class assumes its existence. I do not want to tie any other containers to the classes where possible.

Again using stack processing solves this. Before you call the target code which will write to the global graphics container record the containers size. Call the target code. Clean the dynamicgraphics variable by calling nuke. Then move the newely created graphics from the global graphics container restoring it to its size prior to the target call.

As people will point out there are better ways to do this update. Well this is an OO environment so whatever you want you can write yourself. I'm not stopping you.

History

TODO

Graphics Callbacks

Immediate drawing,

class hat { 
  void myshape()
  {
    glColor3f(1.0,0.0,0.0); ...
...

// main program
  hat h1;
  gobjpush( gobjcallbackcreatenew(h1,&hat::myshape) ); 
  } };