diff --git a/Extras/CDTestFramework/AntTweakBar/ChangeLog.txt b/Extras/CDTestFramework/AntTweakBar/ChangeLog.txt new file mode 100644 index 000000000..3277df751 --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/ChangeLog.txt @@ -0,0 +1,23 @@ +--- AntTweakBar library changes --- + +- Version 1.04 + OpenGL: Vertex buffer object state and Vertex/fragment program and object states are now reset and restored by TwDraw (thanks to Dylan and Siva for pointing this out). + +- Version 1.03 (2006/10/28) + Medium font is now antialiased. + Now also compiles on 64 bits x86 platform; use Makefile.x86_64 (thanks to Herling). + Slight changes to avoid visual 8 secure crt warnings. + Correct behaviour if min/max values are not defined. + Modif to avoid looping to max value when reaching zero with unsigned types. + Min/max/step commands for type TW_TYPE_CHAR now read ascii codes (not characters). + Add FPU precision control (because DirectX changes it). + Fix problem that occurs when the lib is initialized/unitialized more than once (thanks Lukasz for reporting it). + Distribution follows Savannah's recommendations. + +- Version 1.02 (2006/09/27) + Library sources released. + +- Version 1.01 (2006/09/14) + First official release. + + \ No newline at end of file diff --git a/Extras/CDTestFramework/AntTweakBar/Clean.bat b/Extras/CDTestFramework/AntTweakBar/Clean.bat new file mode 100644 index 000000000..34d2a4f51 --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/Clean.bat @@ -0,0 +1,19 @@ +RMDIR /S /Q src\debug +RMDIR /S /Q src\release +CD src +DEL *.ncb *.aps *.o *.bak +DEL /A:h *.suo +CD .. +RMDIR /S /Q lib\debug +RMDIR /S /Q examples\debug +CD examples +DEL *.ncb *.aps *.o *.bak +DEL /A:h *.suo +DEL /S BuildLog.htm +DEL bin\*.obj +DEL bin\*.idb +CD .. + +PAUSE + + diff --git a/Extras/CDTestFramework/AntTweakBar/License.txt b/Extras/CDTestFramework/AntTweakBar/License.txt new file mode 100644 index 000000000..0e3f29370 --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/License.txt @@ -0,0 +1,23 @@ +--- AntTweakBar license --- + +Copyright © 2005, 2006 Philippe Decaudin + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from +the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim +that you wrote the original software. If you use this software in a product, +an acknowledgment in the product documentation would be appreciated. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + + +http://www.antisphere.com diff --git a/Extras/CDTestFramework/AntTweakBar/Readme.txt b/Extras/CDTestFramework/AntTweakBar/Readme.txt new file mode 100644 index 000000000..87c46cb9b --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/Readme.txt @@ -0,0 +1,15 @@ +--- AntTweakBar development library --- + + +AntTweakBar is a small and easy-to-use C/C++ library that allows programmers +to quickly add a light and intuitive GUI into OpenGL and DirectX based +graphic programs to interactively tweak them. + +This package includes the development version of the AntTweakBar library +for GNU/Linux and Windows, + some program examples (sources + binaries). + +For installation and documentation please refer to: +http://www.antisphere.com/Wiki/tools:anttweakbar + + +Philippe Decaudin - http://www.antisphere.com - 2006/05/20 diff --git a/Extras/CDTestFramework/AntTweakBar/examples/Examples.ncb b/Extras/CDTestFramework/AntTweakBar/examples/Examples.ncb new file mode 100644 index 000000000..57e218451 Binary files /dev/null and b/Extras/CDTestFramework/AntTweakBar/examples/Examples.ncb differ diff --git a/Extras/CDTestFramework/AntTweakBar/examples/Examples.sln b/Extras/CDTestFramework/AntTweakBar/examples/Examples.sln new file mode 100644 index 000000000..6502f91ff --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/examples/Examples.sln @@ -0,0 +1,65 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwCopyDLL", "TwCopyDLL.vcproj", "{AB180E0E-0EFA-4AD4-8F08-4492D144D963}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwSimpleGLFW", "TwSimpleGLFW.vcproj", "{29C096AF-172E-4A36-A1FE-E15B259D6834}" + ProjectSection(ProjectDependencies) = postProject + {AB180E0E-0EFA-4AD4-8F08-4492D144D963} = {AB180E0E-0EFA-4AD4-8F08-4492D144D963} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwSimpleGLUT", "TwSimpleGLUT.vcproj", "{CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}" + ProjectSection(ProjectDependencies) = postProject + {AB180E0E-0EFA-4AD4-8F08-4492D144D963} = {AB180E0E-0EFA-4AD4-8F08-4492D144D963} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwSimpleSDL", "TwSimpleSDL.vcproj", "{3B516919-D0DA-43CE-820E-8306368F605B}" + ProjectSection(ProjectDependencies) = postProject + {AB180E0E-0EFA-4AD4-8F08-4492D144D963} = {AB180E0E-0EFA-4AD4-8F08-4492D144D963} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwSimpleDX9", "TwSimpleDX9.vcproj", "{6B414E54-701C-4ED3-9034-F5CD7BFC3451}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwAdvanced1", "TwAdvanced1.vcproj", "{008D1CEC-1586-4C89-B524-DF15D9605163}" + ProjectSection(ProjectDependencies) = postProject + {AB180E0E-0EFA-4AD4-8F08-4492D144D963} = {AB180E0E-0EFA-4AD4-8F08-4492D144D963} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {AB180E0E-0EFA-4AD4-8F08-4492D144D963}.Debug.ActiveCfg = Debug|Win32 + {AB180E0E-0EFA-4AD4-8F08-4492D144D963}.Debug.Build.0 = Debug|Win32 + {AB180E0E-0EFA-4AD4-8F08-4492D144D963}.Release.ActiveCfg = Release|Win32 + {AB180E0E-0EFA-4AD4-8F08-4492D144D963}.Release.Build.0 = Release|Win32 + {29C096AF-172E-4A36-A1FE-E15B259D6834}.Debug.ActiveCfg = Debug|Win32 + {29C096AF-172E-4A36-A1FE-E15B259D6834}.Debug.Build.0 = Debug|Win32 + {29C096AF-172E-4A36-A1FE-E15B259D6834}.Release.ActiveCfg = Release|Win32 + {29C096AF-172E-4A36-A1FE-E15B259D6834}.Release.Build.0 = Release|Win32 + {CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}.Debug.ActiveCfg = Debug|Win32 + {CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}.Debug.Build.0 = Debug|Win32 + {CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}.Release.ActiveCfg = Release|Win32 + {CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}.Release.Build.0 = Release|Win32 + {3B516919-D0DA-43CE-820E-8306368F605B}.Debug.ActiveCfg = Debug|Win32 + {3B516919-D0DA-43CE-820E-8306368F605B}.Debug.Build.0 = Debug|Win32 + {3B516919-D0DA-43CE-820E-8306368F605B}.Release.ActiveCfg = Release|Win32 + {3B516919-D0DA-43CE-820E-8306368F605B}.Release.Build.0 = Release|Win32 + {6B414E54-701C-4ED3-9034-F5CD7BFC3451}.Debug.ActiveCfg = Debug|Win32 + {6B414E54-701C-4ED3-9034-F5CD7BFC3451}.Debug.Build.0 = Debug|Win32 + {6B414E54-701C-4ED3-9034-F5CD7BFC3451}.Release.ActiveCfg = Release|Win32 + {6B414E54-701C-4ED3-9034-F5CD7BFC3451}.Release.Build.0 = Release|Win32 + {008D1CEC-1586-4C89-B524-DF15D9605163}.Debug.ActiveCfg = Debug|Win32 + {008D1CEC-1586-4C89-B524-DF15D9605163}.Debug.Build.0 = Debug|Win32 + {008D1CEC-1586-4C89-B524-DF15D9605163}.Release.ActiveCfg = Release|Win32 + {008D1CEC-1586-4C89-B524-DF15D9605163}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Extras/CDTestFramework/AntTweakBar/examples/Examples.suo b/Extras/CDTestFramework/AntTweakBar/examples/Examples.suo new file mode 100644 index 000000000..0a6131804 Binary files /dev/null and b/Extras/CDTestFramework/AntTweakBar/examples/Examples.suo differ diff --git a/Extras/CDTestFramework/AntTweakBar/examples/Makefile b/Extras/CDTestFramework/AntTweakBar/examples/Makefile new file mode 100644 index 000000000..46cda3eac --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/examples/Makefile @@ -0,0 +1,80 @@ +####### Compiler, tools and options + +#---- MinGW +#MINGWFLAGS = -mno-cygwin + + +#---- Release +CXXCFG = -O3 +LFLAGS = -L../lib +OUT_DIR = bin +#---- Debug +#CXXCFG = -g -D_DEBUG +#LFLAGS = -Wl -L../lib/debug +#OUT_DIR = debug + + +CXX = gcc +#CXXFLAGS = $(CXXCFG) $(MINGWFLAGS) -pipe -Wall -ffast-math -fPIC -fno-strength-reduce -mcpu=pentiumpro -march=i586 +CXXFLAGS = $(CXXCFG) -Wall -mcpu=i386 -march=i386 +INCPATH = -I../include -I/usr/local/include -I/usr/X11R6/include -I/usr/include +LIBS = -L/usr/X11R6/lib -lAntTweakBar -lGL -lGLU -lX11 -lXxf86vm -lXext -lXmu -lpthread -lm + +DEL_FILE = rm -f +DEL_DIR = rmdir +NO_STDERR = 2> /dev/null +EXP_PATH = "export LD_LIBRARY_PATH=\"../../lib:$(LD_LIBRARY_PATH)\"" + + +####### Files + + +SRC_FILES = TwSimpleGLFW.c TwSimpleGLUT.c TwSimpleSDL.c TwAdvanced1.cpp + + +####### Build rules + + +#first: depend all +first: all + +all: Makefile $(SRC_FILES) + + @echo "===== Build TwSimpleGLFW ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleGLFW.c $(LFLAGS) -lglfw $(LIBS) -o $(OUT_DIR)/TwSimpleGLFW.out + @echo "$(EXP_PATH) ; ./TwSimpleGLFW.out" > $(OUT_DIR)/TwSimpleGLFW + + @echo "===== Build TwSimpleGLUT ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleGLUT.c $(LFLAGS) -lglut $(LIBS) -o $(OUT_DIR)/TwSimpleGLUT.out + @echo "$(EXP_PATH) ; ./TwSimpleGLUT.out" > $(OUT_DIR)/TwSimpleGLUT + + @echo "===== Build TwSimpleSDL ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleSDL.c $(LFLAGS) -lSDL $(LIBS) -o $(OUT_DIR)/TwSimpleSDL.out + @echo "$(EXP_PATH) ; ./TwSimpleSDL.out" > $(OUT_DIR)/TwSimpleSDL + + @echo "===== Build TwAdvanced1 ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwAdvanced1.cpp $(LFLAGS) -lglfw $(LIBS) -o $(OUT_DIR)/TwAdvanced1.out + @echo "$(EXP_PATH) ; ./TwAdvanced1.out" > $(OUT_DIR)/TwAdvanced1 + +# append dependencies to this Makefile +#depend: +# @echo "===== Make dependencies =====" +# makedepend -Y +# makedepend -a -Y -- $(CXXFLAGS) $(INCPATH) -- $(SRC_FILES) $(NO_STDERR) + + +# clean temporary files +clean: + @echo "===== Clean =====" + -$(DEL_FILE) *.o + -$(DEL_FILE) *~ core *.core *.stackdump + -$(DEL_FILE) debug/* + -$(DEL_DIR) debug + + +####### DEPENDENCIES + +TwSimpleGLFW.o: ../include/AntTweakBar.h +TwSimpleGLUT.o: ../include/AntTweakBar.h +TwSimpleSDL.o: ../include/AntTweakBar.h +TwAdvanced1.o: ../include/AntTweakBar.h diff --git a/Extras/CDTestFramework/AntTweakBar/examples/Makefile.x86_64 b/Extras/CDTestFramework/AntTweakBar/examples/Makefile.x86_64 new file mode 100644 index 000000000..067e1bbe2 --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/examples/Makefile.x86_64 @@ -0,0 +1,82 @@ +####### Compiler, tools and options + +#---- MinGW +#MINGWFLAGS = -mno-cygwin + + +#---- Release +CXXCFG = -O3 +LFLAGS = -L../lib +OUT_DIR = bin +#---- Debug +#CXXCFG = -g -D_DEBUG +#LFLAGS = -Wl -L./debug +#OUT_DIR = debug + + +CXX = gcc +#CXXFLAGS = $(CXXCFG) $(MINGWFLAGS) -pipe -Wall -ffast-math -fpic -fno-strength-reduce -mcpu=pentiumpro -march=i586 +#CXXFLAGS = $(CXXCFG) -Wall -mcpu=i386 -march=i386 +CXXFLAGS = $(CXXCFG) -Wall +INCPATH = -I../include -I/usr/local/include -I/usr/X11R6/include -I/usr/include +#LIBS = -L/usr/X11R6/lib -lAntTweakBar -lGL -lGLU -lX11 -lXxf86vm -lXext -lXmu -lpthread -lm +LIBS = -L/usr/lib64 -lAntTweakBar -lglfw -lGL -lGLU -lX11 -lXxf86vm -lXext -lXmu -lpthread -lm + +DEL_FILE = rm -f +DEL_DIR = rmdir +NO_STDERR = 2> /dev/null +EXP_PATH = "export LD_LIBRARY_PATH=\"../../lib:$(LD_LIBRARY_PATH)\"" + + +####### Files + + +SRC_FILES = TwSimpleGLFW.c TwSimpleGLUT.c TwSimpleSDL.c TwAdvanced1.cpp + + +####### Build rules + + +#first: depend all +first: all + +all: Makefile $(SRC_FILES) + + @echo "===== Build TwSimpleGLFW ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleGLFW.c $(LFLAGS) -lglfw $(LIBS) -o $(OUT_DIR)/TwSimpleGLFW.out + @echo "$(EXP_PATH) ; ./TwSimpleGLFW.out" > $(OUT_DIR)/TwSimpleGLFW + + @echo "===== Build TwSimpleGLUT ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleGLUT.c $(LFLAGS) -lglut $(LIBS) -o $(OUT_DIR)/TwSimpleGLUT.out + @echo "$(EXP_PATH) ; ./TwSimpleGLUT.out" > $(OUT_DIR)/TwSimpleGLUT + + @echo "===== Build TwSimpleSDL ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwSimpleSDL.c $(LFLAGS) -lSDL $(LIBS) -o $(OUT_DIR)/TwSimpleSDL.out + @echo "$(EXP_PATH) ; ./TwSimpleSDL.out" > $(OUT_DIR)/TwSimpleSDL + + @echo "===== Build TwAdvanced1 ====" + $(CXX) $(CXXFLAGS) $(INCPATH) TwAdvanced1.cpp $(LFLAGS) -lglfw $(LIBS) -o $(OUT_DIR)/TwAdvanced1.out + @echo "$(EXP_PATH) ; ./TwAdvanced1.out" > $(OUT_DIR)/TwAdvanced1 + +# append dependencies to this Makefile +#depend: +# @echo "===== Make dependencies =====" +# makedepend -Y +# makedepend -a -Y -- $(CXXFLAGS) $(INCPATH) -- $(SRC_FILES) $(NO_STDERR) + + +# clean temporary files +clean: + @echo "===== Clean =====" + -$(DEL_FILE) *.o + -$(DEL_FILE) *~ core *.core *.stackdump + -$(DEL_FILE) debug/* + -$(DEL_DIR) debug + + +####### DEPENDENCIES + +TwSimpleGLFW.o: ../include/AntTweakBar.h +TwSimpleGLUT.o: ../include/AntTweakBar.h +TwSimpleSDL.o: ../include/AntTweakBar.h +TwAdvanced1.o: ../include/AntTweakBar.h diff --git a/Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.cpp b/Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.cpp new file mode 100644 index 000000000..70e6ac58e --- /dev/null +++ b/Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.cpp @@ -0,0 +1,693 @@ +// --------------------------------------------------------------------------- +// +// @file TwAdvanced1.cpp +// @brief An example showing many features of AntTweakBar. +// It also uses OpenGL and GLFW windowing system +// but could be easily adapted to other frameworks. +// +// AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar +// OpenGL: http://www.opengl.org +// GLFW: http://glfw.sourceforge.net +// +// +// This example draws a simple scene that can be re-tesselated +// interactively, and illuminated dynamically by an adjustable +// number of moving lights. +// +// +// @author Philippe Decaudin - http://www.antisphere.com +// @date 2006/05/20 +// +// note: TAB=4 +// +// Compilation: +// http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twadvanced1 +// +// --------------------------------------------------------------------------- + +#include + +#define GLFW_DLL // use GLFW as a dynamically linked library +#include "glfw.h" + +#include +#include +#ifndef _WIN32 +# define _snprintf snprintf +#endif +const float FLOAT_2PI = 6.283185307f; // 2*PI + + +// Light structure: embed light parameters +struct Light +{ + bool Active; // light On or Off + float Pos[4]; // light position (in homogeneous coordinates, ie. Pos[4]=1) + float Color[4]; // light color (no alpha, ie. Color[4]=1) + float Radius; // radius of the light influence area + float Dist0, Angle0, Height0, Speed0; // light initial cylindrical coordinates and speed + char Name[4]; // light short name (will be named "1", "2", "3",...) + enum AnimMode { ANIM_FIXED, ANIM_BOUNCE, ANIM_ROTATE, ANIM_COMBINED }; + AnimMode Animation; // light animation mode +}; + + +// Class that describes the scene and its methods +class Scene +{ +public: + bool Wireframe; // draw scene in wireframe or filled + int Subdiv; // number of subdivisions used to tesselate the scene + int NumLights; // number of dynamic lights + float BgColor0[3], BgColor1[3]; // top and bottom background colors + float Ambient; // scene ambient factor + float Reflection; // ground plane reflection factor (0=no reflection, 1=full reflection) + float RotYAngle; // rotation angle of the scene around its Y axis (in degree) + enum RotMode { ROT_OFF, ROT_CW, ROT_CCW }; + RotMode Rotation; // scene rotation mode (off, clockwise, counter-clockwise) + + Scene(); // constructor + ~Scene(); // destructor + void Init(bool changeLightPos); // (re)intialize the scene + void Draw(); // draw scene + void Update(float time); // move lights + +private: + void CreateBar(); // create a tweak bar for lights + // Some drawing subroutines + void DrawSubdivPlaneY(float xMin, float xMax, float y, float zMin, float zMax, int xSubdiv, int zSubdiv); + void DrawSubdivCylinderY(float xCenter, float yBottom, float zCenter, float height, float radiusBottom, float radiusTop, int sideSubdiv, int ySubdiv); + void DrawSubdivHaloZ(float x, float y, float z, float radius, int subdiv); + void DrawHalos(bool reflected); + + GLuint objList, groundList, haloList; // OpenGL display list IDs + int maxLights; // maximum number of dynamic lights allowed by the graphic card + Light * lights; // array of lights + TwBar * lightsBar; // pointer to the tweak bar for lights created by CreateBar() +}; + + +// Constructor +Scene::Scene() +{ + // Set scene members. + // The scene will be created by Scene::Init( ) + Wireframe = false; + Subdiv = 20; + NumLights = 0; + BgColor0[0] = 0.9f; + BgColor0[1] = 0.0f; + BgColor0[2] = 0.0f; + BgColor1[0] = 0.6f; + BgColor1[1] = 0.6f; + BgColor1[2] = 0.6f; + Ambient = 0.3f; + Reflection = 0.5f; + RotYAngle = 0; + Rotation = ROT_CCW; + objList = 0; + groundList = 0; + haloList = 0; + maxLights = 0; + lights = NULL; + lightsBar = NULL; +} + + +// Destructor +Scene::~Scene() +{ + // delete all lights + if( lights ) + delete[] lights; +} + + +// Create the scene, and (re)initialize lights if changeLights is true +void Scene::Init(bool changeLights) +{ + // Get the max number of lights allowed by the graphic card + glGetIntegerv(GL_MAX_LIGHTS, &maxLights); + if( maxLights>16 ) + maxLights = 16; + + // Create the lights array + if( lights==NULL && maxLights>0 ) + { + lights = new Light[maxLights]; + NumLights = maxLights/2; // default number of lights + if( NumLights==0 ) + NumLights = 1; + changeLights = true; // force lights initialization + + // Create a tweak bar for lights + CreateBar(); + } + + // (Re)initialize lights if needed (uses random values) + if( changeLights ) + for(int i=0; ilights[i].Color[1]) ? 1.0f-lights[i].Color[1] : 1.0f-lights[i].Color[0]; + lights[i].Color[3] = 1; + lights[i].Active = true; + } + + // Initialize some OpenGL states + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glEnable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LIGHTING); + glEnable(GL_CULL_FACE); + glEnable(GL_NORMALIZE); + glEnable(GL_COLOR_MATERIAL); + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); + + // Create objects display list using the current Subdiv parameter to control the tesselation + if( objList>0 ) + glDeleteLists(objList, 1); // delete previously created display list + objList = glGenLists(1); + glNewList(objList, GL_COMPILE); + DrawSubdivCylinderY(-0.9f, 0, -0.9f, 1.4f, 0.15f, 0.12f, Subdiv/2+8, Subdiv); + DrawSubdivCylinderY(+0.9f, 0, -0.9f, 1.4f, 0.15f, 0.12f, Subdiv/2+8, Subdiv); + DrawSubdivCylinderY(+0.9f, 0, +0.9f, 1.4f, 0.15f, 0.12f, Subdiv/2+8, Subdiv); + DrawSubdivCylinderY(-0.9f, 0, +0.9f, 1.4f, 0.15f, 0.12f, Subdiv/2+8, Subdiv); + DrawSubdivCylinderY(0, 0, 0, 0.4f, 0.5f, 0.3f, Subdiv+16, Subdiv/8+1); + DrawSubdivCylinderY(0, 0.4f, 0, 0.05f, 0.3f, 0.0f, Subdiv+16, Subdiv/16+1); + glEndList(); + + // Create ground display list + if( groundList>0 ) + glDeleteLists(groundList, 1); // delete previously created display list + groundList = glGenLists(1); + glNewList(groundList, GL_COMPILE); + DrawSubdivPlaneY(-1.2f, 1.2f, 0, -1.2f, 1.2f, (3*Subdiv)/2, (3*Subdiv)/2); + glEndList(); + + // Create display list to draw light halos + if( haloList>0 ) + glDeleteLists(haloList, 1); // delete previously created display list + haloList = glGenLists(1); + glNewList(haloList, GL_COMPILE); + DrawSubdivHaloZ(0, 0, 0, 1, 32); + glEndList(); +} + + +// Callback function associated to the 'Change lights' button of the lights tweak bar. +void TW_CALL ReinitCB(void *clientData) +{ + Scene *scene = static_cast(clientData); // scene pointer is stored in clientData + scene->Init(true); // re-initialize the scene +} + + +// Create a tweak bar for lights. +// New enum type and struct type are defined and used by this bar. +void Scene::CreateBar() +{ + // Create a new tweak bar and change its label + lightsBar = TwNewBar("Lights"); + TwDefine(" Lights label='Lights TweakBar' "); + + // Add a variable of type int to control the number of lights + TwAddVarRW(lightsBar, "NumLights", TW_TYPE_INT32, &NumLights, " label='Number of lights' keyIncr=l keyDecr=L "); + // Set the NumLights min value (=0) and max value (depends on the user graphic card) + char def[256]; + _snprintf(def, 255, "Lights/NumLights min=0 max=%d", maxLights); + TwDefine(def); // min and max are defined using a defintion string + + // Add a button to re-initialize the lights; this button calls the ReinitCB callback function + TwAddButton(lightsBar, "Reinit", ReinitCB, this, " label='Change lights' key=RETURN "); + + // Define a new enum type for the tweak bar + TwEnumVal modeEV[] = // array used to describe the Scene::AnimMode enum values + { + { Light::ANIM_FIXED, "Fixed" }, + { Light::ANIM_BOUNCE, "Bounce" }, + { Light::ANIM_ROTATE, "Rotate" }, + { Light::ANIM_COMBINED, "Combined" } + }; + TwType modeType = TwDefineEnum("Mode", modeEV, 4); // create a new TwType associated to the enum defined by the modeEV array + + // Define a new struct type: light variables are embeded in this structure + TwStructMember lightMembers[] = // array used to describe tweakable variables of the Light structure + { + { "Active", TW_TYPE_BOOLCPP, offsetof(Light, Active), "" }, // Light::Active is a C++ boolean value + { "Color", TW_TYPE_COLOR4F, offsetof(Light, Color), "noalpha" }, // Light::Color is represented by 4 floats, but alpha channel should be ignored + { "Radius", TW_TYPE_FLOAT, offsetof(Light, Radius), "min=0 max=4 step=0.02" }, + { "Animation", modeType, offsetof(Light, Animation), "" }, // use the enum 'modeType' created before to tweak the Light::Animation variable + { "Speed", TW_TYPE_FLOAT, offsetof(Light, Speed0), "readonly" } // Light::Speed is made read-only + }; + TwType lightType = TwDefineStruct("Light", lightMembers, 5, sizeof(Light), NULL, NULL); // create a new TwType associated to the struct defined by the lightMembers array + + // Use the newly created 'lightType' to add variables associated with lights + for(int i=0; i