CDTestFramework, OPCODE, ICE redistributed under the ZLib License, with permission of Pierre Terdiman
Added Bullet SAP/MultiSAP support by Erwin Coumans (BulletSAPCompleteBoxPruningTest.*) AABB tree broadphase by Nathanael Presson (btDbvt.*, DbvtTest.*)
This commit is contained in:
BIN
Extras/CDTestFramework/AntTweakBar/examples/Examples.ncb
Normal file
BIN
Extras/CDTestFramework/AntTweakBar/examples/Examples.ncb
Normal file
Binary file not shown.
65
Extras/CDTestFramework/AntTweakBar/examples/Examples.sln
Normal file
65
Extras/CDTestFramework/AntTweakBar/examples/Examples.sln
Normal file
@@ -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
|
||||
BIN
Extras/CDTestFramework/AntTweakBar/examples/Examples.suo
Normal file
BIN
Extras/CDTestFramework/AntTweakBar/examples/Examples.suo
Normal file
Binary file not shown.
80
Extras/CDTestFramework/AntTweakBar/examples/Makefile
Normal file
80
Extras/CDTestFramework/AntTweakBar/examples/Makefile
Normal file
@@ -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
|
||||
82
Extras/CDTestFramework/AntTweakBar/examples/Makefile.x86_64
Normal file
82
Extras/CDTestFramework/AntTweakBar/examples/Makefile.x86_64
Normal file
@@ -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
|
||||
693
Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.cpp
Normal file
693
Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.cpp
Normal file
@@ -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 <AntTweakBar.h>
|
||||
|
||||
#define GLFW_DLL // use GLFW as a dynamically linked library
|
||||
#include "glfw.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#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; i<maxLights; ++i)
|
||||
{
|
||||
lights[i].Dist0 = 0.5f*(float)rand()/RAND_MAX + 0.55f;
|
||||
lights[i].Angle0 = FLOAT_2PI*((float)rand()/RAND_MAX);
|
||||
lights[i].Height0 = FLOAT_2PI*(float)rand()/RAND_MAX;
|
||||
lights[i].Speed0 = 4.0f*(float)rand()/RAND_MAX - 2.0f;
|
||||
lights[i].Animation = Light::ANIM_BOUNCE;
|
||||
lights[i].Radius = (float)rand()/RAND_MAX+0.05f;
|
||||
lights[i].Color[0] = (float)rand()/RAND_MAX;
|
||||
lights[i].Color[1] = (float)rand()/RAND_MAX;
|
||||
lights[i].Color[2] = (lights[i].Color[0]>lights[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<Scene *>(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<maxLights; ++i) // Add 'maxLights' variables of type lightType; unused lights variables (over NumLights) will hidden by Scene::Update( )
|
||||
{
|
||||
_snprintf(lights[i].Name, 3, "%d", i+1); // Create a name for each light ("1", "2", "3",...)
|
||||
TwAddVarRW(lightsBar, lights[i].Name, lightType, &lights[i], "group='Edit lights'"); // Add a lightType variable and group it into the 'Edit lights' group
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Move lights
|
||||
void Scene::Update(float time)
|
||||
{
|
||||
float horizSpeed, vertSpeed;
|
||||
for(int i=0; i<NumLights; ++i)
|
||||
{
|
||||
// Change light position according to its current animation mode
|
||||
|
||||
if( lights[i].Animation==Light::ANIM_ROTATE || lights[i].Animation==Light::ANIM_COMBINED )
|
||||
horizSpeed = lights[i].Speed0;
|
||||
else
|
||||
horizSpeed = 0;
|
||||
|
||||
if( lights[i].Animation==Light::ANIM_BOUNCE || lights[i].Animation==Light::ANIM_COMBINED )
|
||||
vertSpeed = 1;
|
||||
else
|
||||
vertSpeed = 0;
|
||||
|
||||
lights[i].Pos[0] = lights[i].Dist0 * (float)cos(horizSpeed*time + lights[i].Angle0);
|
||||
lights[i].Pos[1] = (float)fabs(cos(vertSpeed*time + lights[i].Height0));
|
||||
lights[i].Pos[2] = lights[i].Dist0 * (float)sin(horizSpeed*time + lights[i].Angle0);
|
||||
lights[i].Pos[3] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Activate OpenGL lights; hide unused lights in the Lights tweak bar;
|
||||
// and draw the scene. The scene is reflected by the ground plane, so it is
|
||||
// drawn two times: first reflected, and second normal (unreflected).
|
||||
void Scene::Draw()
|
||||
{
|
||||
int i;
|
||||
char def[32]; // definition string used to show/hide tweakable lights
|
||||
for(i=0; i<maxLights; ++i)
|
||||
{
|
||||
strcpy(def, "Lights/");
|
||||
strcat(def, lights[i].Name); // name of the current light
|
||||
if( i<NumLights )
|
||||
{
|
||||
// Lights under NumLights are shown in the Lights tweak bar
|
||||
strcat(def, " show");
|
||||
|
||||
// Tell OpenGL to enable or disable the light
|
||||
if( lights[i].Active )
|
||||
glEnable(GL_LIGHT0+i);
|
||||
else
|
||||
glDisable(GL_LIGHT0+i);
|
||||
|
||||
// Update OpenGL light parameters (for the reflected scene)
|
||||
float reflectPos[4] = { lights[i].Pos[0], -lights[i].Pos[1], lights[i].Pos[2], lights[i].Pos[3] };
|
||||
glLightfv(GL_LIGHT0+i, GL_POSITION, reflectPos);
|
||||
glLightfv(GL_LIGHT0+i, GL_DIFFUSE, lights[i].Color);
|
||||
glLightf(GL_LIGHT0+i, GL_CONSTANT_ATTENUATION, 1);
|
||||
glLightf(GL_LIGHT0+i, GL_LINEAR_ATTENUATION, 0);
|
||||
glLightf(GL_LIGHT0+i, GL_QUADRATIC_ATTENUATION, 1.0f/(lights[i].Radius*lights[i].Radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lights over NumLights are hidden in the Lights tweak bar
|
||||
strcat(def, " hide");
|
||||
|
||||
// Disable the OpenGL light
|
||||
glDisable(GL_LIGHT0+i);
|
||||
|
||||
}
|
||||
|
||||
// Show or hide the light variable in the Lights tweak bar
|
||||
TwDefine(def);
|
||||
}
|
||||
|
||||
// Set global ambient and clear screen and depth buffer
|
||||
float ambient[4] = { Ambient*(BgColor0[0]+BgColor1[0])/2, Ambient*(BgColor0[1]+BgColor1[1])/2, Ambient*(BgColor0[2]+BgColor1[2])/2, 1 };
|
||||
glClearColor(ambient[0], ambient[1], ambient[2], 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
|
||||
|
||||
// Rotate the scene
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glRotatef(RotYAngle, 0, 1, 0);
|
||||
|
||||
// Draw the reflected scene
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (Wireframe ? GL_LINE : GL_FILL));
|
||||
glCullFace(GL_FRONT);
|
||||
glPushMatrix();
|
||||
glScalef(1, -1, 1);
|
||||
glColor3f(1, 1, 1);
|
||||
glCallList(objList);
|
||||
DrawHalos(true);
|
||||
glPopMatrix();
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// clear depth buffer again
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Draw the ground plane (using the Reflection parameter as transparency)
|
||||
glColor4f(1, 1, 1, 1.0f-Reflection);
|
||||
glCallList(groundList);
|
||||
|
||||
// Draw the gradient background (requires to switch to screen-space normalized coordinates)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glDisable(GL_LIGHTING);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glBegin(GL_QUADS);
|
||||
glColor3f(BgColor0[0], BgColor0[1], BgColor0[2]);
|
||||
glVertex3f(-1, -1, 0.9f);
|
||||
glVertex3f(1, -1, 0.9f);
|
||||
glColor3f(BgColor1[0], BgColor1[1], BgColor1[2]);
|
||||
glVertex3f(1, 1, 0.9f);
|
||||
glVertex3f(-1, 1, 0.9f);
|
||||
glEnd();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
// Update light positions for unreflected scene
|
||||
for(i=0; i<NumLights; ++i)
|
||||
glLightfv(GL_LIGHT0+i, GL_POSITION, lights[i].Pos);
|
||||
|
||||
// Draw the unreflected scene
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (Wireframe ? GL_LINE : GL_FILL));
|
||||
glColor3f(1, 1, 1);
|
||||
glCallList(objList);
|
||||
DrawHalos(false);
|
||||
}
|
||||
|
||||
|
||||
// Subroutine used to draw halos around light positions
|
||||
void Scene::DrawHalos(bool reflected)
|
||||
{
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDepthMask(GL_FALSE);
|
||||
float prevAmbient[4];
|
||||
glGetFloatv(GL_LIGHT_MODEL_AMBIENT, prevAmbient);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
if( reflected )
|
||||
glScalef(1, -1 ,1);
|
||||
float black[4] = {0, 0, 0, 1};
|
||||
float cr = (float)cos(FLOAT_2PI*RotYAngle/360.0f);
|
||||
float sr = (float)sin(FLOAT_2PI*RotYAngle/360.0f);
|
||||
for(int i=0; i<NumLights; ++i)
|
||||
{
|
||||
if( lights[i].Active )
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lights[i].Color);
|
||||
else
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black);
|
||||
glPushMatrix();
|
||||
glTranslatef(cr*lights[i].Pos[0]+sr*lights[i].Pos[2], lights[i].Pos[1], -sr*lights[i].Pos[0]+cr*lights[i].Pos[2]);
|
||||
//glScalef(0.5f*lights[i].Radius, 0.5f*lights[i].Radius, 1);
|
||||
glScalef(0.05f, 0.05f, 1);
|
||||
glCallList(haloList);
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, prevAmbient);
|
||||
glDepthMask(GL_TRUE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
// Subroutine used to build the ground plane display list (mesh subdivision is adjustable)
|
||||
void Scene::DrawSubdivPlaneY(float xMin, float xMax, float y, float zMin, float zMax, int xSubdiv, int zSubdiv)
|
||||
{
|
||||
const float FLOAT_EPS = 1.0e-5f;
|
||||
float dx = (xMax-xMin)/xSubdiv;
|
||||
float dz = (zMax-zMin)/zSubdiv;
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(0, -1, 0);
|
||||
for( float z=zMin; z<zMax-FLOAT_EPS; z+=dz )
|
||||
for( float x=xMin; x<xMax-FLOAT_EPS; x+=dx )
|
||||
{
|
||||
glVertex3f(x, y, z);
|
||||
glVertex3f(x, y, z+dz);
|
||||
glVertex3f(x+dx, y, z+dz);
|
||||
glVertex3f(x+dx, y, z);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
// Subroutine used to build objects display list (mesh subdivision is adjustable)
|
||||
void Scene::DrawSubdivCylinderY(float xCenter, float yBottom, float zCenter, float height, float radiusBottom, float radiusTop, int sideSubdiv, int ySubdiv)
|
||||
{
|
||||
float h0, h1, y0, y1, r0, r1, a0, a1, cosa0, sina0, cosa1, sina1;
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(0, 1, 0);
|
||||
for( int j=0; j<ySubdiv; ++j )
|
||||
for( int i=0; i<sideSubdiv; ++i )
|
||||
{
|
||||
h0 = (float)j/ySubdiv;
|
||||
h1 = (float)(j+1)/ySubdiv;
|
||||
y0 = yBottom + h0*height;
|
||||
y1 = yBottom + h1*height;
|
||||
r0 = radiusBottom + h0*(radiusTop-radiusBottom);
|
||||
r1 = radiusBottom + h1*(radiusTop-radiusBottom);
|
||||
a0 = FLOAT_2PI*(float)i/sideSubdiv;
|
||||
a1 = FLOAT_2PI*(float)(i+1)/sideSubdiv;
|
||||
cosa0 = (float)cos(a0);
|
||||
sina0 = (float)sin(a0);
|
||||
cosa1 = (float)cos(a1);
|
||||
sina1 = (float)sin(a1);
|
||||
glNormal3f(cosa0, 0, sina0);
|
||||
glVertex3f(xCenter+r0*cosa0, y0, zCenter+r0*sina0);
|
||||
glNormal3f(cosa0, 0, sina0);
|
||||
glVertex3f(xCenter+r1*cosa0, y1, zCenter+r1*sina0);
|
||||
glNormal3f(cosa1, 0, sina1);
|
||||
glVertex3f(xCenter+r1*cosa1, y1, zCenter+r1*sina1);
|
||||
glNormal3f(cosa1, 0, sina1);
|
||||
glVertex3f(xCenter+r0*cosa1, y0, zCenter+r0*sina1);
|
||||
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
// Subroutine used to build halo display list
|
||||
void Scene::DrawSubdivHaloZ(float x, float y, float z, float radius, int subdiv)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glNormal3f(0, 0, 0);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glVertex3f(x, y, z);
|
||||
for( int i=0; i<=subdiv; ++i )
|
||||
{
|
||||
glColor4f(1, 1, 1, 0);
|
||||
glVertex3f(x+radius*(float)cos(FLOAT_2PI*(float)i/subdiv), x+radius*(float)sin(FLOAT_2PI*(float)i/subdiv), z);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW when a mouse button is clicked
|
||||
void GLFWCALL OnMouseButton(int glfwButton, int glfwAction)
|
||||
{
|
||||
if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) ) // Send event to AntTweakBar
|
||||
{
|
||||
// Event has not been handled by AntTweakBar
|
||||
// Do something if needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW when mouse has moved
|
||||
void GLFWCALL OnMousePos(int mouseX, int mouseY)
|
||||
{
|
||||
if( !TwEventMousePosGLFW(mouseX, mouseY) ) // Send event to AntTweakBar
|
||||
{
|
||||
// Event has not been handled by AntTweakBar
|
||||
// Do something if needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW on mouse wheel event
|
||||
void GLFWCALL OnMouseWheel(int pos)
|
||||
{
|
||||
if( !TwEventMouseWheelGLFW(pos) ) // Send event to AntTweakBar
|
||||
{
|
||||
// Event has not been handled by AntTweakBar
|
||||
// Do something if needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW on key event
|
||||
void GLFWCALL OnKey(int glfwKey, int glfwAction)
|
||||
{
|
||||
if( !TwEventKeyGLFW(glfwKey, glfwAction) ) // Send event to AntTweakBar
|
||||
{
|
||||
// Event has not been handled by AntTweakBar
|
||||
// Do something if needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW on char event
|
||||
void GLFWCALL OnChar(int glfwChar, int glfwAction)
|
||||
{
|
||||
if( !TwEventCharGLFW(glfwChar, glfwAction) ) // Send event to AntTweakBar
|
||||
{
|
||||
// Event has not been handled by AntTweakBar
|
||||
// Do something if needed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLFW when window size changes
|
||||
void GLFWCALL OnWindowSize(int width, int height)
|
||||
{
|
||||
// Set OpenGL viewport and camera
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(40, (double)width/height, 1, 10);
|
||||
gluLookAt(-0.3,1,3.5, -0.3,0,0, 0,1,0);
|
||||
glTranslated(0, -0.3, 0);
|
||||
|
||||
// Send the new window size to AntTweakBar
|
||||
TwWindowSize(width, height);
|
||||
}
|
||||
|
||||
|
||||
// Callback function called when the 'Subdiv' variable value of the main tweak bar has changed.
|
||||
void TW_CALL SetSubdivCB(const void *value, void *clientData)
|
||||
{
|
||||
Scene *scene = static_cast<Scene *>(clientData); // scene pointer is stored in clientData
|
||||
scene->Subdiv = *static_cast<const int *>(value); // copy value to scene->Subdiv
|
||||
scene->Init(false); // re-init scene with the new Subdiv parameter
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by the main tweak bar to get the 'Subdiv' value
|
||||
void TW_CALL GetSubdivCB(void *value, void *clientData)
|
||||
{
|
||||
Scene *scene = static_cast<Scene *>(clientData); // scene pointer is stored in clientData
|
||||
*static_cast<int *>(value) = scene->Subdiv; // copy scene->Subdiv to value
|
||||
}
|
||||
|
||||
|
||||
// Main function
|
||||
int main()
|
||||
{
|
||||
// Intialize GLFW
|
||||
if( !glfwInit() )
|
||||
{
|
||||
// A fatal error occured
|
||||
std::cerr << "GLFW initialization failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a window
|
||||
GLFWvidmode mode;
|
||||
glfwGetDesktopMode(&mode);
|
||||
if( !glfwOpenWindow(800, 600, mode.RedBits, mode.GreenBits, mode.BlueBits, 0, 16, 0, GLFW_WINDOW /* or GLFW_FULLSCREEN */) )
|
||||
{
|
||||
// A fatal error occured
|
||||
std::cerr << "Cannot open GLFW window" << std::endl;
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
glfwEnable(GLFW_MOUSE_CURSOR);
|
||||
glfwEnable(GLFW_KEY_REPEAT);
|
||||
glfwSetWindowTitle("AntTweakBar example: TwAdvanced1");
|
||||
// Set GLFW event callbacks
|
||||
glfwSetWindowSizeCallback(OnWindowSize);
|
||||
glfwSetMouseButtonCallback(OnMouseButton);
|
||||
glfwSetMousePosCallback(OnMousePos);
|
||||
glfwSetMouseWheelCallback(OnMouseWheel);
|
||||
glfwSetKeyCallback(OnKey);
|
||||
glfwSetCharCallback(OnChar);
|
||||
|
||||
// Initialize AntTweakBar
|
||||
if( !TwInit(TW_OPENGL, NULL) )
|
||||
{
|
||||
// A fatal error occured
|
||||
std::cerr << "AntTweakBar initialization failed: " << TwGetLastError() << std::endl;
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize the 3D scene
|
||||
Scene scene;
|
||||
scene.Init(true);
|
||||
|
||||
|
||||
// Create a tweak bar called 'Main' and change its refresh rate and font size
|
||||
TwBar *mainBar = TwNewBar("Main");
|
||||
TwDefine(" Main label='Main TweakBar' refresh=0.5 fontSize=3 ");
|
||||
|
||||
// Add some variables to the Main tweak bar
|
||||
TwAddVarRW(mainBar, "Wireframe", TW_TYPE_BOOLCPP, &scene.Wireframe, " group='Display' key=w "); // 'Wireframe' is put in the group 'Display' (which is then created)
|
||||
TwAddVarRW(mainBar, "BgTop", TW_TYPE_COLOR3F, &scene.BgColor1, " group='Background' "); // 'BgTop' and 'BgBottom' are put in the group 'Background' (which is then created)
|
||||
TwAddVarRW(mainBar, "BgBottom", TW_TYPE_COLOR3F, &scene.BgColor0, " group='Background' ");
|
||||
TwDefine(" Main/Background group='Display' "); // The group 'Background' of bar 'Main' is put in the group 'Display'
|
||||
TwAddVarCB(mainBar, "Subdiv", TW_TYPE_INT32, SetSubdivCB, GetSubdivCB, &scene, " group='Scene' label='Meshs subdivision' min=1 max=50 keyincr=s keyDecr=S ");
|
||||
TwAddVarRW(mainBar, "Ambient", TW_TYPE_FLOAT, &scene.Ambient, " label='Ambient factor' group='Scene' min=0 max=1 step=0.001 keyIncr=a keyDecr=A ");
|
||||
TwAddVarRW(mainBar, "Reflection", TW_TYPE_FLOAT, &scene.Reflection, " label='Reflection factor' group='Scene' min=0 max=1 step=0.001 keyIncr=r keyDecr=R ");
|
||||
|
||||
// Create a new TwType called rotationType associated with the Scene::RotMode enum, and use it
|
||||
TwEnumVal rotationEV[] = { { Scene::ROT_OFF, "Stopped"}, { Scene::ROT_CW, "Clockwise" }, { Scene::ROT_CCW, "Counter-clockwise" } };
|
||||
TwType rotationType = TwDefineEnum( "Rotation Mode", rotationEV, 3 );
|
||||
TwAddVarRW(mainBar, "Rotation", rotationType, &scene.Rotation, " group='Scene' keyIncr=Backspace keyDecr=SHIFT+Backspace ");
|
||||
|
||||
// Add a read-only float variable; its precision is 0 which means that the fractionnal part of the float value will not be displayed
|
||||
TwAddVarRO(mainBar, "RotYAngle", TW_TYPE_FLOAT, &scene.RotYAngle, " group='Scene' label='Rot angle (degree)' precision=0 ");
|
||||
|
||||
// Initialize time
|
||||
float time = (float)glfwGetTime(), dt = 0; // Current time and elapsed time
|
||||
// Main loop (repeated while window is not closed and [ESC] is not pressed)
|
||||
while( glfwGetWindowParam(GLFW_OPENED) && !glfwGetKey(GLFW_KEY_ESC) )
|
||||
{
|
||||
// Compute elapsed time
|
||||
dt = (float)glfwGetTime() - time;
|
||||
if( dt>0.1f )
|
||||
dt = 0.1f;
|
||||
time += dt;
|
||||
|
||||
// Rotate scene
|
||||
if( scene.Rotation==Scene::ROT_CW )
|
||||
scene.RotYAngle -= 5.0f*dt;
|
||||
else if( scene.Rotation==Scene::ROT_CCW )
|
||||
scene.RotYAngle += 5.0f*dt;
|
||||
|
||||
// Move lights
|
||||
scene.Update(time);
|
||||
|
||||
// Draw scene
|
||||
scene.Draw();
|
||||
|
||||
// Draw tweak bars
|
||||
TwDraw();
|
||||
|
||||
// Present frame buffer
|
||||
glfwSwapBuffers();
|
||||
}
|
||||
|
||||
// Terminate AntTweakBar and GLFW
|
||||
TwTerminate();
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
142
Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.vcproj
Normal file
142
Extras/CDTestFramework/AntTweakBar/examples/TwAdvanced1.vcproj
Normal file
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwAdvanced1"
|
||||
ProjectGUID="{008D1CEC-1586-4C89-B524-DF15D9605163}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="glfwdll.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../lib/debug,../lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glfw\lib\win32\glfw.dll xcopy /y /f c:\sdk\glfw\lib\win32\glfw.dll debug
|
||||
if exist ..\lib\AntTweakBar.dll xcopy /y /f ..\lib\AntTweakBar.dll debug
|
||||
if exist ..\lib\debug\AntTweakBar.dll xcopy /y /f ..\lib\debug\AntTweakBar.dll debug
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="glfwdll.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../lib"
|
||||
GenerateDebugInformation="FALSE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
SetChecksum="TRUE"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glfw\lib\win32\glfw.dll xcopy /y /f c:\sdk\glfw\lib\win32\glfw.dll bin
|
||||
if exist ..\lib\AntTweakBar.dll xcopy /y /f ..\lib\AntTweakBar.dll bin
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="TwAdvanced1.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
53
Extras/CDTestFramework/AntTweakBar/examples/TwCopyDLL.vcproj
Normal file
53
Extras/CDTestFramework/AntTweakBar/examples/TwCopyDLL.vcproj
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwCopyDLL"
|
||||
ProjectGUID="{AB180E0E-0EFA-4AD4-8F08-4492D144D963}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="10"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="if exist ..\lib\debug\AntTweakBar.dll ( xcopy /y /f ..\lib\debug\AntTweakBar.dll debug ) else ( xcopy /y /f ..\lib\AntTweakBar.dll debug )
|
||||
"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="10"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine="xcopy /y /f ..\lib\AntTweakBar.dll bin"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
228
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleDX9.cpp
Normal file
228
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleDX9.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// @file TwSimpleDX9.c
|
||||
// @brief A simple example that uses AntTweakBar with DirectX9
|
||||
//
|
||||
// AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar
|
||||
// DirectX: http://msdn.microsoft.com/directx
|
||||
//
|
||||
// @author Philippe Decaudin - http://www.antisphere.com
|
||||
// @date 2006/05/20
|
||||
//
|
||||
// note: TAB=4
|
||||
//
|
||||
// Compilation:
|
||||
// http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twsimpledx9
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <AntTweakBar.h>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <dxerr9.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
// Direct3D structures
|
||||
IDirect3D9 * g_D3D = NULL;
|
||||
IDirect3DDevice9 * g_D3DDev = NULL;
|
||||
D3DPRESENT_PARAMETERS g_D3Dpp;
|
||||
|
||||
|
||||
// D3D states initialization function
|
||||
void InitD3D()
|
||||
{
|
||||
// Set D3D matrices
|
||||
D3DMATRIX matId = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
|
||||
g_D3DDev->SetTransform(D3DTS_WORLD, &matId);
|
||||
g_D3DDev->SetTransform(D3DTS_VIEW, &matId);
|
||||
D3DMATRIX matProj = { (float)g_D3Dpp.BackBufferHeight/g_D3Dpp.BackBufferWidth,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
|
||||
g_D3DDev->SetTransform(D3DTS_PROJECTION, &matProj);
|
||||
|
||||
// Disable lighting and culling
|
||||
g_D3DDev->SetRenderState( D3DRS_LIGHTING, FALSE );
|
||||
g_D3DDev->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
|
||||
}
|
||||
|
||||
|
||||
// Win32 MessageProc callback
|
||||
LRESULT CALLBACK MessageProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Send event message to AntTweakBar
|
||||
if( TwEventWin32(wnd, msg, wParam, lParam) )
|
||||
return 0; // Event has been handled by AntTweakBar
|
||||
|
||||
switch( msg )
|
||||
{
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
case WM_SIZE: // Window size has been changed
|
||||
// reset D3D device
|
||||
if( g_D3DDev )
|
||||
{
|
||||
g_D3Dpp.BackBufferWidth = LOWORD(lParam);
|
||||
g_D3Dpp.BackBufferHeight = HIWORD(lParam);
|
||||
if( g_D3Dpp.BackBufferWidth>0 && g_D3Dpp.BackBufferHeight>0 )
|
||||
{
|
||||
g_D3DDev->Reset(&g_D3Dpp);
|
||||
InitD3D(); // re-initialize D3D states
|
||||
}
|
||||
// TwWindowSize has been called by TwEventWin32, so it is not necessary to call it again here.
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return DefWindowProc(wnd, msg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main
|
||||
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow)
|
||||
{
|
||||
// Register our window class
|
||||
WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_CLASSDC, MessageProc, 0L, 0L, instance, NULL, NULL, NULL, NULL, "TwDX9", NULL };
|
||||
RegisterClassEx(&wcex);
|
||||
|
||||
// Create a window
|
||||
RECT rect = { 0, 0, 640, 480 };
|
||||
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||
HWND wnd = CreateWindow("TwDX9", "AntTweakBar simple example using DirectX9", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right-rect.left, rect.bottom-rect.top, NULL, NULL, instance, NULL);
|
||||
if( !wnd )
|
||||
{
|
||||
MessageBox(NULL, "Cannot create window", "Error", MB_OK|MB_ICONERROR);
|
||||
return FALSE;
|
||||
}
|
||||
ShowWindow(wnd, cmdShow);
|
||||
UpdateWindow(wnd);
|
||||
|
||||
|
||||
// Initialize Direct3D
|
||||
g_D3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if( !g_D3D )
|
||||
{
|
||||
MessageBox(wnd, "Cannot initialize DirectX", "Error", MB_OK|MB_ICONERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Create a Direct3D device
|
||||
ZeroMemory( &g_D3Dpp, sizeof(D3DPRESENT_PARAMETERS) );
|
||||
g_D3Dpp.Windowed = TRUE;
|
||||
g_D3Dpp.BackBufferCount = 1;
|
||||
g_D3Dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
|
||||
g_D3Dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||
g_D3Dpp.EnableAutoDepthStencil = TRUE;
|
||||
g_D3Dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
||||
g_D3Dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
HRESULT hr = g_D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_MIXED_VERTEXPROCESSING, &g_D3Dpp, &g_D3DDev);
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
DXTRACE_ERR_MSGBOX("Cannot create DirectX device", hr);
|
||||
g_D3D->Release();
|
||||
g_D3D = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// This example draws a moving strip;
|
||||
// create a buffer of vertices for the strip
|
||||
struct Vertex
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
};
|
||||
Vertex vertices[2002];
|
||||
int numSec = 100; // number of strip sections
|
||||
float color[] = { 1, 0, 0 }; // strip color
|
||||
unsigned int bgColor = D3DCOLOR_ARGB(255, 40, 255, 200); // background color
|
||||
|
||||
// Init some D3D states
|
||||
InitD3D();
|
||||
|
||||
// Initialize AntTweakBar
|
||||
// (note that the Direct3D device pointer must be passed to TwInit)
|
||||
if( !TwInit(TW_DIRECT3D9, g_D3DDev) )
|
||||
{
|
||||
MessageBox(wnd, TwGetLastError(), "Cannot initialize AntTweakBar", MB_OK|MB_ICONERROR);
|
||||
g_D3DDev->Release();
|
||||
g_D3DDev = NULL;
|
||||
g_D3D->Release();
|
||||
g_D3D = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// Create a tweak bar
|
||||
TwBar *bar = TwNewBar("TweakBar");
|
||||
|
||||
// Add 'numSec' to 'bar': it is a modifiable (RW) variable of type TW_TYPE_INT32. Its shortcuts are [s] and [S].
|
||||
TwAddVarRW(bar, "NumSec", TW_TYPE_INT32, &numSec, " label='Strip length' min=1 max=1000 keyIncr=s keyDecr=S ");
|
||||
// Add 'color' to 'bar': it is a modifable variable of type TW_TYPE_COLOR3F (3 floats color)
|
||||
TwAddVarRW(bar, "Color", TW_TYPE_COLOR3F, &color, " label='Strip color' ");
|
||||
// Add 'bgColor' to 'bar': it is a modifable variable of type TW_TYPE_COLOR32 (32 bits color)
|
||||
TwAddVarRW(bar, "BgColor", TW_TYPE_COLOR32, &bgColor, " label='Background color' ");
|
||||
// Add 'width' and 'height' to 'bar': they are read-only (RO) variables of type TW_TYPE_INT32.
|
||||
TwAddVarRO(bar, "Width", TW_TYPE_INT32, &g_D3Dpp.BackBufferWidth, " label='wnd width' ");
|
||||
TwAddVarRO(bar, "Height", TW_TYPE_INT32, &g_D3Dpp.BackBufferHeight, " label='wnd height' ");
|
||||
|
||||
|
||||
// Main loop
|
||||
bool quit = false;
|
||||
while( !quit )
|
||||
{
|
||||
// Clear screen and begin draw
|
||||
g_D3DDev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, bgColor, 1.0f, 0);
|
||||
g_D3DDev->BeginScene();
|
||||
|
||||
// Draw scene
|
||||
float s, t = (float)GetTickCount()/1000.0f;
|
||||
for( int i=0; i<=numSec; ++i ) // update vertices
|
||||
{
|
||||
s = (float)i/100;
|
||||
vertices[2*i+0].x = 0.2f+0.5f*cosf(2.0f*s+5.0f*t);
|
||||
vertices[2*i+1].x = vertices[2*i+0].x + (0.25f+0.1f*cosf(s+t));
|
||||
vertices[2*i+0].y = vertices[2*i+1].y = 0.7f*(0.7f+0.3f*sinf(s+t))*sinf(1.5f*s+3.0f*t);
|
||||
vertices[2*i+0].z = vertices[2*i+1].z = 0;
|
||||
s = (float)i/numSec;
|
||||
vertices[2*i+0].color = vertices[2*i+1].color = D3DCOLOR_XRGB((int)(255*color[0]*s), (int)(255*color[1]*s), (int)(255*color[2]*s));
|
||||
}
|
||||
g_D3DDev->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE);
|
||||
g_D3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2*numSec, vertices, sizeof(Vertex)); // draw strip
|
||||
|
||||
// Draw tweak bars
|
||||
TwDraw();
|
||||
|
||||
// End draw
|
||||
g_D3DDev->EndScene();
|
||||
|
||||
// Present frame buffer
|
||||
g_D3DDev->Present(NULL, NULL, NULL, NULL);
|
||||
|
||||
// Process windows messages
|
||||
MSG msg;
|
||||
while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
|
||||
{
|
||||
if( msg.message==WM_QUIT )
|
||||
quit = true;
|
||||
else if( !TranslateAccelerator(msg.hwnd, NULL, &msg) )
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
} // End of main loop
|
||||
|
||||
|
||||
// Terminate AntTweakBar
|
||||
TwTerminate();
|
||||
|
||||
// Release Direct3D
|
||||
g_D3DDev->Release();
|
||||
g_D3DDev = NULL;
|
||||
g_D3D->Release();
|
||||
g_D3D = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
138
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleDX9.vcproj
Normal file
138
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleDX9.vcproj
Normal file
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwSimpleDX9"
|
||||
ProjectGUID="{6B414E54-701C-4ED3-9034-F5CD7BFC3451}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3d9.lib dxerr9.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../lib/debug,../lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
StringPooling="TRUE"
|
||||
ExceptionHandling="FALSE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="2"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3d9.lib dxerr9.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../lib"
|
||||
GenerateDebugInformation="FALSE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
SetChecksum="TRUE"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="TwSimpleDX9.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
200
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLFW.c
Normal file
200
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLFW.c
Normal file
@@ -0,0 +1,200 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// @file TwSimpleGLFW.c
|
||||
// @brief A simple example that uses AntTweakBar with
|
||||
// OpenGL and the GLFW windowing system.
|
||||
//
|
||||
// AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar
|
||||
// OpenGL: http://www.opengl.org
|
||||
// GLFW: http://glfw.sourceforge.net
|
||||
//
|
||||
// @author Philippe Decaudin - http://www.antisphere.com
|
||||
// @date 2006/05/20
|
||||
//
|
||||
// note: TAB=4
|
||||
//
|
||||
// Compilation:
|
||||
// http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twsimpleglfw
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <AntTweakBar.h>
|
||||
|
||||
#define GLFW_DLL
|
||||
#include "glfw.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Callback function called by GLFW when window size changes
|
||||
void GLFWCALL WindowSizeCB(int width, int height)
|
||||
{
|
||||
// Set OpenGL viewport and camera
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(40, (double)width/height, 1, 10);
|
||||
gluLookAt(-1,0,3, 0,0,0, 0,1,0);
|
||||
|
||||
// Send the new window size to AntTweakBar
|
||||
TwWindowSize(width, height);
|
||||
}
|
||||
|
||||
|
||||
// This example program draws a possibly transparent cube
|
||||
void DrawModel(int wireframe)
|
||||
{
|
||||
int pass, numPass;
|
||||
|
||||
// Enable OpenGL transparency and light (could have been done once at init)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHT0); // use default light diffuse and position
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glLineWidth(3.0);
|
||||
|
||||
if( wireframe )
|
||||
{
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_LIGHTING);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
numPass = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
numPass = 2;
|
||||
}
|
||||
|
||||
for( pass=0; pass<numPass; ++pass )
|
||||
{
|
||||
// Since the material could be transparent, we draw the convex model in 2 passes:
|
||||
// first its back faces, and second its front faces.
|
||||
glCullFace( (pass==0) ? GL_FRONT : GL_BACK );
|
||||
|
||||
// Draw the model (a cube)
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(0,0,-1); glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(1,1,0); glVertex3f(1,0,0); // front face
|
||||
glNormal3f(0,0,+1); glVertex3f(0,0,1); glVertex3f(1,0,1); glVertex3f(1,1,1); glVertex3f(0,1,1); // back face
|
||||
glNormal3f(-1,0,0); glVertex3f(0,0,0); glVertex3f(0,0,1); glVertex3f(0,1,1); glVertex3f(0,1,0); // left face
|
||||
glNormal3f(+1,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(1,1,1); glVertex3f(1,0,1); // right face
|
||||
glNormal3f(0,-1,0); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,0,1); glVertex3f(0,0,1); // bottom face
|
||||
glNormal3f(0,+1,0); glVertex3f(0,1,0); glVertex3f(0,1,1); glVertex3f(1,1,1); glVertex3f(1,1,0); // top face
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main
|
||||
int main()
|
||||
{
|
||||
GLFWvidmode mode; // GLFW video mode
|
||||
TwBar *bar; // Pointer to a tweak bar
|
||||
|
||||
double time = 0, dt;// Current time and enlapsed time
|
||||
double turn = 0; // Model turn counter
|
||||
double speed = 0.1; // Model rotation speed
|
||||
int wire = 0; // Draw model in wireframe?
|
||||
float bgColor[] = { 0.1f, 0.2f, 0.4f }; // Background color
|
||||
unsigned char cubeColor[] = { 255, 0, 0, 255 }; // Model color (32bits RGBA)
|
||||
|
||||
// Intialize GLFW
|
||||
if( !glfwInit() )
|
||||
{
|
||||
// A fatal error occured
|
||||
fprintf(stderr, "GLFW initialization failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a window
|
||||
glfwGetDesktopMode(&mode);
|
||||
if( !glfwOpenWindow(640, 480, mode.RedBits, mode.GreenBits, mode.BlueBits, 0, 16, 0, GLFW_WINDOW /* or GLFW_FULLSCREEN */) )
|
||||
{
|
||||
// A fatal error occured
|
||||
fprintf(stderr, "Cannot open GLFW window\n");
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
glfwEnable(GLFW_MOUSE_CURSOR);
|
||||
glfwEnable(GLFW_KEY_REPEAT);
|
||||
glfwSetWindowTitle("AntTweakBar simple example using GLFW");
|
||||
|
||||
// Initialize AntTweakBar
|
||||
if( !TwInit(TW_OPENGL, NULL) )
|
||||
{
|
||||
// A fatal error occured
|
||||
fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
|
||||
glfwTerminate();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a tweak bar
|
||||
bar = TwNewBar("TweakBar");
|
||||
|
||||
// Add 'speed' to 'bar': it is a modifable (RW) variable of type TW_TYPE_DOUBLE. Its key shortcuts are [s] and [S].
|
||||
TwAddVarRW(bar, "speed", TW_TYPE_DOUBLE, &speed, " label='Rot speed (tr/sec)' min=0 max=2 step=0.01 keyIncr=s keyDecr=S ");
|
||||
// Add 'wire' to 'bar': it is a modifable variable of type TW_TYPE_BOOL32 (32 bits boolean). Its key shortcut is [w].
|
||||
TwAddVarRW(bar, "wire", TW_TYPE_BOOL32, &wire, " label='Wireframe mode' key=w ");
|
||||
// Add 'time' to 'bar': it is a read-only (RO) variable of type TW_TYPE_DOUBLE, with 1 precision digit
|
||||
TwAddVarRO(bar, "time", TW_TYPE_DOUBLE, &time, " label='Time (sec)' precision=1 ");
|
||||
// Add 'bgColor' to 'bar': it is a modifable variable of type TW_TYPE_COLOR3F (3 floats color)
|
||||
TwAddVarRW(bar, "bgColor", TW_TYPE_COLOR3F, &bgColor, " label='Background color' ");
|
||||
// Add 'cubeColor' to 'bar': it is a modifable variable of type TW_TYPE_COLOR32 (32 bits color) with alpha
|
||||
TwAddVarRW(bar, "cubeColor", TW_TYPE_COLOR32, &cubeColor, " label='Cube color' alpha ");
|
||||
|
||||
// Set GLFW event callbacks
|
||||
// - Redirect window size changes to the callback function WindowSizeCB
|
||||
glfwSetWindowSizeCallback(WindowSizeCB);
|
||||
// - Directly redirect GLFW mouse button events to AntTweakBar
|
||||
glfwSetMouseButtonCallback((GLFWmousebuttonfun)TwEventMouseButtonGLFW);
|
||||
// - Directly redirect GLFW mouse position events to AntTweakBar
|
||||
glfwSetMousePosCallback((GLFWmouseposfun)TwEventMousePosGLFW);
|
||||
// - Directly redirect GLFW mouse wheel events to AntTweakBar
|
||||
glfwSetMouseWheelCallback((GLFWmousewheelfun)TwEventMouseWheelGLFW);
|
||||
// - Directly redirect GLFW key events to AntTweakBar
|
||||
glfwSetKeyCallback((GLFWkeyfun)TwEventKeyGLFW);
|
||||
// - Directly redirect GLFW char events to AntTweakBar
|
||||
glfwSetCharCallback((GLFWcharfun)TwEventCharGLFW);
|
||||
// - Redirect window size changes to the callback function WindowSizeCB
|
||||
|
||||
// Initialize time
|
||||
time = glfwGetTime();
|
||||
// Main loop (repeated while window is not closed and [ESC] is not pressed)
|
||||
while( glfwGetWindowParam(GLFW_OPENED) && !glfwGetKey(GLFW_KEY_ESC) )
|
||||
{
|
||||
// Clear frame buffer using bgColor
|
||||
glClearColor(bgColor[0], bgColor[1], bgColor[2], 1);
|
||||
glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
// Rotate model
|
||||
dt = glfwGetTime() - time;
|
||||
time += dt;
|
||||
turn += speed*dt;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glRotated(360.0*turn, 0.4, 1, 0.2);
|
||||
glTranslated(-0.5, -0.5, -0.5);
|
||||
|
||||
// Set color and draw model
|
||||
glColor4ubv(cubeColor);
|
||||
DrawModel(wire);
|
||||
|
||||
// Draw tweak bars
|
||||
TwDraw();
|
||||
|
||||
// Present frame buffer
|
||||
glfwSwapBuffers();
|
||||
}
|
||||
|
||||
// Terminate AntTweakBar and GLFW
|
||||
TwTerminate();
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
137
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLFW.vcproj
Normal file
137
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLFW.vcproj
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwSimpleGLFW"
|
||||
ProjectGUID="{29C096AF-172E-4A36-A1FE-E15B259D6834}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="glfwdll.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../lib/debug,../lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glfw\lib\win32\glfw.dll xcopy /y /f c:\sdk\glfw\lib\win32\glfw.dll debug"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="glfwdll.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../lib"
|
||||
GenerateDebugInformation="FALSE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
SetChecksum="TRUE"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glfw\lib\win32\glfw.dll xcopy /y /f c:\sdk\glfw\lib\win32\glfw.dll bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="TwSimpleGLFW.c">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
194
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLUT.c
Normal file
194
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLUT.c
Normal file
@@ -0,0 +1,194 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// @file TwSimpleGLUT.c
|
||||
// @brief A simple example that uses AntTweakBar with OpenGL and GLUT.
|
||||
//
|
||||
// AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar
|
||||
// OpenGL: http://www.opengl.org
|
||||
// GLUT: http://opengl.org/resources/libraries/glut
|
||||
//
|
||||
// @author Philippe Decaudin - http://www.antisphere.com
|
||||
// @date 2006/05/20
|
||||
//
|
||||
// note: TAB=4
|
||||
//
|
||||
// Compilation:
|
||||
// http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twsimpleglut
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <AntTweakBar.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
// This example displays one of the following shapes
|
||||
typedef enum { SHAPE_TEAPOT=1, SHAPE_TORUS, SHAPE_CONE } Shape;
|
||||
#define NUM_SHAPES 3
|
||||
Shape g_CurrentShape = SHAPE_TORUS;
|
||||
// Shapes scale
|
||||
float g_Zoom = 1.0f;
|
||||
// Shapes material
|
||||
float g_MatAmbient[] = { 0.5f, 0.0f, 0.0f, 1.0f };
|
||||
float g_MatDiffuse[] = { 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
// Light parameter
|
||||
float g_LightMultiplier = 1.0f;
|
||||
|
||||
|
||||
// Callback function called by GLUT to render screen
|
||||
void Display(void)
|
||||
{
|
||||
float angle = (float)glutGet(GLUT_ELAPSED_TIME)/10.0f;
|
||||
float v[4]; // will be used to set light paramters
|
||||
|
||||
// Clear frame buffer
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
||||
// Set light
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
v[0] = v[1] = v[2] = g_LightMultiplier*0.4f; v[3] = 1.0f;
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, v);
|
||||
v[0] = v[1] = v[2] = g_LightMultiplier*0.8f; v[3] = 1.0f;
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, v);
|
||||
v[0] = v[1] = v[2] = 1.0f; v[3] = 0.0f;
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, v);
|
||||
|
||||
// Set material
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, g_MatAmbient);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, g_MatDiffuse);
|
||||
|
||||
// Rotate and draw shape
|
||||
glPushMatrix();
|
||||
glTranslatef(0.5f, -0.3f, 0.0f);
|
||||
glRotatef(angle, 1.0f, 5.0f, 0.0f);
|
||||
glScalef(g_Zoom, g_Zoom, g_Zoom);
|
||||
glCallList(g_CurrentShape);
|
||||
glPopMatrix();
|
||||
|
||||
// Draw tweak bars
|
||||
TwDraw();
|
||||
|
||||
// Present frame buffer
|
||||
glutSwapBuffers();
|
||||
|
||||
// Recall Display at next frame
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
// Callback function called by GLUT when window size changes
|
||||
void Reshape(int width, int height)
|
||||
{
|
||||
// Set OpenGL viewport and camera
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(40, (double)width/height, 1, 10);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0,0,5, 0,0,0, 0,1,0);
|
||||
glTranslatef(0, 0.6f, -1);
|
||||
|
||||
// Send the new window size to AntTweakBar
|
||||
TwWindowSize(width, height);
|
||||
}
|
||||
|
||||
|
||||
// Function called at exit
|
||||
void Terminate(void)
|
||||
{
|
||||
glDeleteLists(SHAPE_TEAPOT, NUM_SHAPES);
|
||||
|
||||
TwTerminate();
|
||||
}
|
||||
|
||||
|
||||
// Main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TwBar *bar; // Pointer to a tweak bar
|
||||
|
||||
// Initialize AntTweakBar
|
||||
// (note that AntTweakBar could also be intialize after GLUT, no matter)
|
||||
if( !TwInit(TW_OPENGL, NULL) )
|
||||
{
|
||||
// A fatal error occured
|
||||
fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize GLUT
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
|
||||
glutInitWindowSize(640, 480);
|
||||
glutCreateWindow("AntTweakBar simple example using GLUT");
|
||||
glutCreateMenu(NULL);
|
||||
|
||||
// Set GLUT callbacks
|
||||
glutDisplayFunc(Display);
|
||||
glutReshapeFunc(Reshape);
|
||||
atexit(Terminate); // Called after glutMainLoop ends
|
||||
|
||||
// Set GLUT event callbacks
|
||||
// - Directly redirect GLUT mouse button events to AntTweakBar
|
||||
glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
|
||||
// - Directly redirect GLUT mouse motion events to AntTweakBar
|
||||
glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
|
||||
// - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
|
||||
glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
|
||||
// - Directly redirect GLUT key events to AntTweakBar
|
||||
glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
|
||||
// - Directly redirect GLUT special key events to AntTweakBar
|
||||
glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT);
|
||||
// - Send 'glutGetModifers' function pointer to AntTweakBar;
|
||||
// required because the GLUT key event functions do not report key modifiers states.
|
||||
TwGLUTModifiersFunc(glutGetModifiers);
|
||||
|
||||
// Create some 3D objects (stored in display lists)
|
||||
glNewList(SHAPE_TEAPOT, GL_COMPILE);
|
||||
glutSolidTeapot(1.0);
|
||||
glEndList();
|
||||
glNewList(SHAPE_TORUS, GL_COMPILE);
|
||||
glutSolidTorus(0.3, 1.0, 16, 32);
|
||||
glEndList();
|
||||
glNewList(SHAPE_CONE, GL_COMPILE);
|
||||
glutSolidCone(1.0, 1.5, 64, 4);
|
||||
glEndList();
|
||||
|
||||
// Create a tweak bar
|
||||
bar = TwNewBar("TweakBar");
|
||||
// Add 'g_Zoom' to 'bar': it is a modifable (RW) variable of type TW_TYPE_FLOAT. Its key shortcuts are [z] and [Z].
|
||||
TwAddVarRW(bar, "Zoom", TW_TYPE_FLOAT, &g_Zoom, " min=0.01 max=2.5 step=0.01 keyIncr=z keyDecr=Z ");
|
||||
// Add 'g_LightMultiplier' to 'bar': it is a variable of type TW_TYPE_FLOAT. Its key shortcuts are [+] and [-].
|
||||
TwAddVarRW(bar, "Multiplier", TW_TYPE_FLOAT, &g_LightMultiplier, " label='Light booster' min=0.1 max=4 step=0.02 keyIncr='+' keyDecr='-' ");
|
||||
// Add 'g_MatAmbient' to 'bar': it is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored). It is inserted into a group named 'Material'.
|
||||
TwAddVarRW(bar, "Ambient", TW_TYPE_COLOR3F, &g_MatAmbient, " group='Material' ");
|
||||
// Add 'g_MatDiffuse' to 'bar': it is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored). It is inserted into group 'Material'.
|
||||
TwAddVarRW(bar, "Diffuse", TW_TYPE_COLOR3F, &g_MatDiffuse, " group='Material' ");
|
||||
// Add the enum variable 'g_CurrentShape' to 'bar'
|
||||
// (before adding an enum variable, its enum type must be declared to AntTweakBar as follow)
|
||||
{
|
||||
// ShapeEV associates Shape enum values with labels that will be displayed instead of enum values
|
||||
TwEnumVal shapeEV[NUM_SHAPES] = { {SHAPE_TEAPOT, "Teapot"}, {SHAPE_TORUS, "Torus"}, {SHAPE_CONE, "Cone"} };
|
||||
// Create a type for the enum shapeEV
|
||||
TwType shapeType = TwDefineEnum("ShapeType", shapeEV, NUM_SHAPES);
|
||||
// add 'g_CurrentShape' to 'bar': it is a variable of type ShapeType. Its key shortcuts are [<] and [>].
|
||||
TwAddVarRW(bar, "Shape", shapeType, &g_CurrentShape, " keyIncr='<' keyDecr='>' ");
|
||||
}
|
||||
|
||||
// Call the GLUT main loop
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
141
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLUT.vcproj
Normal file
141
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleGLUT.vcproj
Normal file
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwSimpleGLUT"
|
||||
ProjectGUID="{CC6C3AFD-5DD9-498F-9184-C53E663C2ABF}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include;C:\SDK\glut"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../lib/debug;../lib;C:\SDK\glut\lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(InputName).pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glut\lib\glut32.dll xcopy /y /f c:\sdk\glut\lib\glut32.dll debug"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="../include;C:\SDK\glut"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
ExceptionHandling="FALSE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="FALSE"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../lib;C:\SDK\glut\lib"
|
||||
GenerateDebugInformation="FALSE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
SetChecksum="TRUE"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\glut\lib\glut32.dll xcopy /y /f c:\sdk\glut\lib\glut32.dll bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="TwSimpleGLUT.c">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
216
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleSDL.c
Normal file
216
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleSDL.c
Normal file
@@ -0,0 +1,216 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// @file TwSimpleSDL.c
|
||||
// @brief A simple example that uses AntTweakBar with OpenGL and SDL.
|
||||
//
|
||||
// AntTweakBar: http://www.antisphere.com/Wiki/tools:anttweakbar
|
||||
// OpenGL: http://www.opengl.org
|
||||
// SDL: http://www.libsdl.org
|
||||
//
|
||||
// @author Philippe Decaudin - http://www.antisphere.com
|
||||
// @date 2006/05/20
|
||||
//
|
||||
// note: TAB=4
|
||||
//
|
||||
// Compilation:
|
||||
// http://www.antisphere.com/Wiki/tools:anttweakbar:examples#twsimplesdl
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <AntTweakBar.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h> // required by gl.h
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
// SDL redefines main
|
||||
#ifdef main
|
||||
# undef main
|
||||
#endif
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
const SDL_VideoInfo* video = NULL;
|
||||
int width = 640, height = 480;
|
||||
int bpp, flags;
|
||||
int quit = 0;
|
||||
TwBar *bar;
|
||||
int n, numCubes = 30;
|
||||
float color0[] = { 1.0f, 0.5f, 0.0f };
|
||||
float color1[] = { 0.5f, 1.0f, 0.0f };
|
||||
double ka = 5.3, kb = 1.7, kc = 4.1;
|
||||
|
||||
// Initialize SDL, then get the current video mode and use it to create a SDL window.
|
||||
if( SDL_Init(SDL_INIT_VIDEO)<0 )
|
||||
{
|
||||
fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
}
|
||||
video = SDL_GetVideoInfo();
|
||||
if( !video )
|
||||
{
|
||||
fprintf(stderr, "Video query failed: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
}
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
//SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
bpp = video->vfmt->BitsPerPixel;
|
||||
flags = SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE;
|
||||
//flags |= SDL_FULLSCREEN;
|
||||
if( !SDL_SetVideoMode(width, height, bpp, flags) )
|
||||
{
|
||||
fprintf(stderr, "Video mode set failed: %s", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
}
|
||||
SDL_WM_SetCaption("AntTweakBar simple example using SDL", "AntTweakBar+SDL");
|
||||
// Enable SDL unicode and key-repeat
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
// Set OpenGL viewport and states
|
||||
glViewport(0, 0, width, height);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0); // use default light diffuse and position
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
|
||||
// Initialize AntTweakBar
|
||||
TwInit(TW_OPENGL, NULL);
|
||||
// Tell the window size to AntTweakBar
|
||||
TwWindowSize(width, height);
|
||||
|
||||
// Create a tweak bar
|
||||
bar = TwNewBar("TweakBar");
|
||||
|
||||
// Add 'width' and 'height' to 'bar': they are read-only (RO) variables of type TW_TYPE_INT32.
|
||||
TwAddVarRO(bar, "Width", TW_TYPE_INT32, &width, " label='Wnd width (pixels)' ");
|
||||
TwAddVarRO(bar, "Height", TW_TYPE_INT32, &height, " label='Wnd height (pixels)' ");
|
||||
// Add 'quit' to 'bar': it is a modifiable (RW) variable of type TW_TYPE_BOOL32 (boolean stored in a 32 bits integer). Its shortcut is [ESC].
|
||||
TwAddVarRW(bar, "Quit", TW_TYPE_BOOL32, &quit, " label='Quit?' true='+' false='-' key='ESC' ");
|
||||
// Add 'numCurves' to 'bar': it is a modifiable variable of type TW_TYPE_INT32. Its shortcuts are [c] and [C].
|
||||
TwAddVarRW(bar, "NumCubes", TW_TYPE_INT32, &numCubes, " label='Number of cubes' min=1 max=100 keyIncr=c keyDecr=C ");
|
||||
// Add 'ka', 'kb and 'kc' to 'bar': they are modifiable variables of type TW_TYPE_DOUBLE
|
||||
TwAddVarRW(bar, "ka", TW_TYPE_DOUBLE, &ka, " label='X path coeff' keyIncr=1 keyDecr=CTRL+1 min=-10 max=10 step=0.01 ");
|
||||
TwAddVarRW(bar, "kb", TW_TYPE_DOUBLE, &kb, " label='Y path coeff' keyIncr=2 keyDecr=CTRL+2 min=-10 max=10 step=0.01 ");
|
||||
TwAddVarRW(bar, "kc", TW_TYPE_DOUBLE, &kc, " label='Z path coeff' keyIncr=3 keyDecr=CTRL+3 min=-10 max=10 step=0.01 ");
|
||||
// Add 'color0' and 'color1' to 'bar': they are modifable variables of type TW_TYPE_COLOR3F (3 floats color)
|
||||
TwAddVarRW(bar, "color0", TW_TYPE_COLOR3F, &color0, " label='Start color' ");
|
||||
TwAddVarRW(bar, "color1", TW_TYPE_COLOR3F, &color1, " label='End color' ");
|
||||
|
||||
// Main loop:
|
||||
// - Draw some cubes
|
||||
// - Process events
|
||||
while( !quit )
|
||||
{
|
||||
SDL_Event event;
|
||||
int handled;
|
||||
|
||||
// Clear screen
|
||||
glClearColor(0.6f, 0.95f, 1.0f, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Set OpenGL camera
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(40, (double)width/height, 1, 10);
|
||||
gluLookAt(0,0,3, 0,0,0, 0,1,0);
|
||||
|
||||
// Draw cubes
|
||||
for( n=0; n<numCubes; ++n )
|
||||
{
|
||||
double t = 0.05*n - (double)SDL_GetTicks()/2000.0;
|
||||
double r = 5.0*n + (double)SDL_GetTicks()/10.0;
|
||||
float c = (float)n/numCubes;
|
||||
|
||||
// Set cube position
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslated(0.4+0.6*cos(ka*t), 0.6*cos(kb*t), 0.6*sin(kc*t));
|
||||
glRotated(r, 0.2, 0.7, 0.2);
|
||||
glScaled(0.1, 0.1, 0.1);
|
||||
glTranslated(-0.5, -0.5, -0.5);
|
||||
|
||||
// Set cube color
|
||||
glColor3f((1.0f-c)*color0[0]+c*color1[0], (1.0f-c)*color0[1]+c*color1[1], (1.0f-c)*color0[2]+c*color1[2]);
|
||||
|
||||
// Draw cube
|
||||
glBegin(GL_QUADS);
|
||||
glNormal3f(0,0,-1); glVertex3f(0,0,0); glVertex3f(0,1,0); glVertex3f(1,1,0); glVertex3f(1,0,0); // front face
|
||||
glNormal3f(0,0,+1); glVertex3f(0,0,1); glVertex3f(1,0,1); glVertex3f(1,1,1); glVertex3f(0,1,1); // back face
|
||||
glNormal3f(-1,0,0); glVertex3f(0,0,0); glVertex3f(0,0,1); glVertex3f(0,1,1); glVertex3f(0,1,0); // left face
|
||||
glNormal3f(+1,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(1,1,1); glVertex3f(1,0,1); // right face
|
||||
glNormal3f(0,-1,0); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,0,1); glVertex3f(0,0,1); // bottom face
|
||||
glNormal3f(0,+1,0); glVertex3f(0,1,0); glVertex3f(0,1,1); glVertex3f(1,1,1); glVertex3f(1,1,0); // top face
|
||||
glEnd();
|
||||
}
|
||||
|
||||
// Draw tweak bars
|
||||
TwDraw();
|
||||
|
||||
// Present frame buffer
|
||||
SDL_GL_SwapBuffers();
|
||||
|
||||
// Process incoming events
|
||||
while( SDL_PollEvent(&event) )
|
||||
{
|
||||
// Send event to AntTweakBar
|
||||
handled = TwEventSDL(&event);
|
||||
|
||||
// If event has not been handled by AntTweakBar, process it
|
||||
if( !handled )
|
||||
{
|
||||
switch( event.type )
|
||||
{
|
||||
case SDL_QUIT: // Window is closed
|
||||
quit = 1;
|
||||
break;
|
||||
case SDL_VIDEORESIZE: // Window size has changed
|
||||
// Resize SDL video mode
|
||||
width = event.resize.w;
|
||||
height = event.resize.h;
|
||||
if( !SDL_SetVideoMode(width, height, bpp, flags) )
|
||||
fprintf(stderr, "WARNING: Video mode set failed: %s", SDL_GetError());
|
||||
// Resize OpenGL viewport
|
||||
glViewport(0, 0, width, height);
|
||||
// Restore OpenGL states (SDL seems to lost them)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
// TwWindowSize has been called by TwEventSDL, so it is not necessary to call it again here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // End of main loop
|
||||
|
||||
// Terminate AntTweakBar
|
||||
TwTerminate();
|
||||
|
||||
// Terminate SDL
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
178
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleSDL.vcproj
Normal file
178
Extras/CDTestFramework/AntTweakBar/examples/TwSimpleSDL.vcproj
Normal file
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="TwSimpleSDL"
|
||||
ProjectGUID="{3B516919-D0DA-43CE-820E-8306368F605B}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="bin"
|
||||
IntermediateDirectory="bin"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
GlobalOptimizations="TRUE"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForWindowsApplication="TRUE"
|
||||
AdditionalIncludeDirectories="../include;c:/sdk/sdl/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
ObjectFile="$(IntDir)/"
|
||||
ProgramDataBaseFileName="$(IntDir)/vc70.pdb"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
IgnoreImportLibrary="FALSE"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="SDL.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../lib;c:/sdk/sdl/lib"
|
||||
IgnoreAllDefaultLibraries="FALSE"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
ProgramDatabaseFile=""
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
SetChecksum="TRUE"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName="$(OutDir)/TwTestSDL.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\sdl\lib\sdl.dll xcopy /y /f c:\sdk\sdl\lib\sdl.dll bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="debug"
|
||||
IntermediateDirectory="debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include,c:/sdk/sdl/include"
|
||||
PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(IntDir)/"
|
||||
ObjectFile="$(IntDir)/"
|
||||
ProgramDataBaseFileName="$(IntDir)/vc70.pdb"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="SDL.lib opengl32.lib glu32.lib"
|
||||
OutputFile="$(OutDir)/$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../lib/debug;../lib;c:/sdk/sdl/lib"
|
||||
IgnoreAllDefaultLibraries="FALSE"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
|
||||
SubSystem="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName="$(OutDir)/TwTestSDL.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist c:\sdk\sdl\lib\sdl.dll xcopy /y /f c:\sdk\sdl\lib\sdl.dll .\debug"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="TwSimpleSDL.c">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
482
Extras/CDTestFramework/AntTweakBar/examples/glfw.h
Normal file
482
Extras/CDTestFramework/AntTweakBar/examples/glfw.h
Normal file
@@ -0,0 +1,482 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: glfw.h
|
||||
// API version: 2.5
|
||||
// Author: Marcus Geelnard (marcus.geelnard at home.se)
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2005 Marcus Geelnard
|
||||
//
|
||||
// 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 but is not required.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Marcus Geelnard
|
||||
// marcus.geelnard at home.se
|
||||
//------------------------------------------------------------------------
|
||||
// $Id: glfw.h,v 1.16 2005/03/14 20:52:51 marcus256 Exp $
|
||||
//========================================================================
|
||||
|
||||
#ifndef __glfw_h_
|
||||
#define __glfw_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global definitions
|
||||
//========================================================================
|
||||
|
||||
// We need a NULL pointer from time to time
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif // NULL
|
||||
|
||||
|
||||
// ------------------- BEGIN SYSTEM/COMPILER SPECIFIC --------------------
|
||||
|
||||
// Please report any probles that you find with your compiler, which may
|
||||
// be solved in this section! There are several compilers that I have not
|
||||
// been able to test this file with yet.
|
||||
|
||||
// First: If we are we on Windows, we want a single define for it (_WIN32)
|
||||
// (Note: For Cygwin the compiler flag -mwin32 should be used, but to
|
||||
// make sure that things run smoothly for Cygwin users, we add __CYGWIN__
|
||||
// to the list of "valid Win32 identifiers", which removes the need for
|
||||
// -mwin32)
|
||||
#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
|
||||
#define _WIN32
|
||||
#endif // _WIN32
|
||||
|
||||
// In order for extension support to be portable, we need to define an
|
||||
// OpenGL function call method. We use the keyword APIENTRY, which is
|
||||
// defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
|
||||
#ifndef APIENTRY
|
||||
#ifdef _WIN32
|
||||
#define APIENTRY __stdcall
|
||||
#else
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#define GL_APIENTRY_DEFINED
|
||||
#endif // APIENTRY
|
||||
|
||||
|
||||
// The following three defines are here solely to make some Windows-based
|
||||
// <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
|
||||
// it has the major drawback of severely polluting our namespace.
|
||||
|
||||
// Under Windows, we need WINGDIAPI defined
|
||||
#if !defined(WINGDIAPI) && defined(_WIN32)
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
|
||||
// Microsoft Visual C++, Borland C++ Builder and Pelles C
|
||||
#define WINGDIAPI __declspec(dllimport)
|
||||
#elif defined(__LCC__)
|
||||
// LCC-Win32
|
||||
#define WINGDIAPI __stdcall
|
||||
#else
|
||||
// Others (e.g. MinGW, Cygwin)
|
||||
#define WINGDIAPI extern
|
||||
#endif
|
||||
#define GL_WINGDIAPI_DEFINED
|
||||
#endif // WINGDIAPI
|
||||
|
||||
// Some <GL/glu.h> files also need CALLBACK defined
|
||||
#if !defined(CALLBACK) && defined(_WIN32)
|
||||
#if defined(_MSC_VER)
|
||||
// Microsoft Visual C++
|
||||
#if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
|
||||
#define CALLBACK __stdcall
|
||||
#else
|
||||
#define CALLBACK
|
||||
#endif
|
||||
#else
|
||||
// Other Windows compilers
|
||||
#define CALLBACK __stdcall
|
||||
#endif
|
||||
#define GLU_CALLBACK_DEFINED
|
||||
#endif // CALLBACK
|
||||
|
||||
// Microsoft Visual C++, Borland C++ and Pelles C <GL/glu.h> needs wchar_t
|
||||
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)) && !defined(_WCHAR_T_DEFINED)
|
||||
typedef unsigned short wchar_t;
|
||||
#define _WCHAR_T_DEFINED
|
||||
#endif // _WCHAR_T_DEFINED
|
||||
|
||||
|
||||
// ---------------- GLFW related system specific defines -----------------
|
||||
|
||||
#if defined(_WIN32) && defined(GLFW_BUILD_DLL)
|
||||
|
||||
// We are building a Win32 DLL
|
||||
#define GLFWAPI __declspec(dllexport)
|
||||
#define GLFWAPIENTRY __stdcall
|
||||
#define GLFWCALL __stdcall
|
||||
|
||||
#elif defined(_WIN32) && defined(GLFW_DLL)
|
||||
|
||||
// We are calling a Win32 DLL
|
||||
#if defined(__LCC__)
|
||||
#define GLFWAPI extern
|
||||
#else
|
||||
#define GLFWAPI __declspec(dllimport)
|
||||
#endif
|
||||
#define GLFWAPIENTRY __stdcall
|
||||
#define GLFWCALL __stdcall
|
||||
|
||||
#else
|
||||
|
||||
// We are either building/calling a static lib or we are non-win32
|
||||
#define GLFWAPIENTRY
|
||||
#define GLFWAPI
|
||||
#define GLFWCALL
|
||||
|
||||
#endif
|
||||
|
||||
// -------------------- END SYSTEM/COMPILER SPECIFIC ---------------------
|
||||
|
||||
// Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
|
||||
// convenient for the user to only have to include <GL/glfw.h>. This also
|
||||
// solves the problem with Windows <GL/gl.h> and <GL/glu.h> needing some
|
||||
// special defines which normally requires the user to include <windows.h>
|
||||
// (which is not a nice solution for portable programs).
|
||||
#if defined(__APPLE_CC__)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
|
||||
//========================================================================
|
||||
// GLFW version
|
||||
//========================================================================
|
||||
|
||||
#define GLFW_VERSION_MAJOR 2
|
||||
#define GLFW_VERSION_MINOR 5
|
||||
#define GLFW_VERSION_REVISION 0
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Input handling definitions
|
||||
//========================================================================
|
||||
|
||||
// Key and button state/action definitions
|
||||
#define GLFW_RELEASE 0
|
||||
#define GLFW_PRESS 1
|
||||
|
||||
// Keyboard key definitions: 8-bit ISO-8859-1 (Latin 1) encoding is used
|
||||
// for printable keys (such as A-Z, 0-9 etc), and values above 256
|
||||
// represent special (non-printable) keys (e.g. F1, Page Up etc).
|
||||
#define GLFW_KEY_UNKNOWN -1
|
||||
#define GLFW_KEY_SPACE 32
|
||||
#define GLFW_KEY_SPECIAL 256
|
||||
#define GLFW_KEY_ESC (GLFW_KEY_SPECIAL+1)
|
||||
#define GLFW_KEY_F1 (GLFW_KEY_SPECIAL+2)
|
||||
#define GLFW_KEY_F2 (GLFW_KEY_SPECIAL+3)
|
||||
#define GLFW_KEY_F3 (GLFW_KEY_SPECIAL+4)
|
||||
#define GLFW_KEY_F4 (GLFW_KEY_SPECIAL+5)
|
||||
#define GLFW_KEY_F5 (GLFW_KEY_SPECIAL+6)
|
||||
#define GLFW_KEY_F6 (GLFW_KEY_SPECIAL+7)
|
||||
#define GLFW_KEY_F7 (GLFW_KEY_SPECIAL+8)
|
||||
#define GLFW_KEY_F8 (GLFW_KEY_SPECIAL+9)
|
||||
#define GLFW_KEY_F9 (GLFW_KEY_SPECIAL+10)
|
||||
#define GLFW_KEY_F10 (GLFW_KEY_SPECIAL+11)
|
||||
#define GLFW_KEY_F11 (GLFW_KEY_SPECIAL+12)
|
||||
#define GLFW_KEY_F12 (GLFW_KEY_SPECIAL+13)
|
||||
#define GLFW_KEY_F13 (GLFW_KEY_SPECIAL+14)
|
||||
#define GLFW_KEY_F14 (GLFW_KEY_SPECIAL+15)
|
||||
#define GLFW_KEY_F15 (GLFW_KEY_SPECIAL+16)
|
||||
#define GLFW_KEY_F16 (GLFW_KEY_SPECIAL+17)
|
||||
#define GLFW_KEY_F17 (GLFW_KEY_SPECIAL+18)
|
||||
#define GLFW_KEY_F18 (GLFW_KEY_SPECIAL+19)
|
||||
#define GLFW_KEY_F19 (GLFW_KEY_SPECIAL+20)
|
||||
#define GLFW_KEY_F20 (GLFW_KEY_SPECIAL+21)
|
||||
#define GLFW_KEY_F21 (GLFW_KEY_SPECIAL+22)
|
||||
#define GLFW_KEY_F22 (GLFW_KEY_SPECIAL+23)
|
||||
#define GLFW_KEY_F23 (GLFW_KEY_SPECIAL+24)
|
||||
#define GLFW_KEY_F24 (GLFW_KEY_SPECIAL+25)
|
||||
#define GLFW_KEY_F25 (GLFW_KEY_SPECIAL+26)
|
||||
#define GLFW_KEY_UP (GLFW_KEY_SPECIAL+27)
|
||||
#define GLFW_KEY_DOWN (GLFW_KEY_SPECIAL+28)
|
||||
#define GLFW_KEY_LEFT (GLFW_KEY_SPECIAL+29)
|
||||
#define GLFW_KEY_RIGHT (GLFW_KEY_SPECIAL+30)
|
||||
#define GLFW_KEY_LSHIFT (GLFW_KEY_SPECIAL+31)
|
||||
#define GLFW_KEY_RSHIFT (GLFW_KEY_SPECIAL+32)
|
||||
#define GLFW_KEY_LCTRL (GLFW_KEY_SPECIAL+33)
|
||||
#define GLFW_KEY_RCTRL (GLFW_KEY_SPECIAL+34)
|
||||
#define GLFW_KEY_LALT (GLFW_KEY_SPECIAL+35)
|
||||
#define GLFW_KEY_RALT (GLFW_KEY_SPECIAL+36)
|
||||
#define GLFW_KEY_TAB (GLFW_KEY_SPECIAL+37)
|
||||
#define GLFW_KEY_ENTER (GLFW_KEY_SPECIAL+38)
|
||||
#define GLFW_KEY_BACKSPACE (GLFW_KEY_SPECIAL+39)
|
||||
#define GLFW_KEY_INSERT (GLFW_KEY_SPECIAL+40)
|
||||
#define GLFW_KEY_DEL (GLFW_KEY_SPECIAL+41)
|
||||
#define GLFW_KEY_PAGEUP (GLFW_KEY_SPECIAL+42)
|
||||
#define GLFW_KEY_PAGEDOWN (GLFW_KEY_SPECIAL+43)
|
||||
#define GLFW_KEY_HOME (GLFW_KEY_SPECIAL+44)
|
||||
#define GLFW_KEY_END (GLFW_KEY_SPECIAL+45)
|
||||
#define GLFW_KEY_KP_0 (GLFW_KEY_SPECIAL+46)
|
||||
#define GLFW_KEY_KP_1 (GLFW_KEY_SPECIAL+47)
|
||||
#define GLFW_KEY_KP_2 (GLFW_KEY_SPECIAL+48)
|
||||
#define GLFW_KEY_KP_3 (GLFW_KEY_SPECIAL+49)
|
||||
#define GLFW_KEY_KP_4 (GLFW_KEY_SPECIAL+50)
|
||||
#define GLFW_KEY_KP_5 (GLFW_KEY_SPECIAL+51)
|
||||
#define GLFW_KEY_KP_6 (GLFW_KEY_SPECIAL+52)
|
||||
#define GLFW_KEY_KP_7 (GLFW_KEY_SPECIAL+53)
|
||||
#define GLFW_KEY_KP_8 (GLFW_KEY_SPECIAL+54)
|
||||
#define GLFW_KEY_KP_9 (GLFW_KEY_SPECIAL+55)
|
||||
#define GLFW_KEY_KP_DIVIDE (GLFW_KEY_SPECIAL+56)
|
||||
#define GLFW_KEY_KP_MULTIPLY (GLFW_KEY_SPECIAL+57)
|
||||
#define GLFW_KEY_KP_SUBTRACT (GLFW_KEY_SPECIAL+58)
|
||||
#define GLFW_KEY_KP_ADD (GLFW_KEY_SPECIAL+59)
|
||||
#define GLFW_KEY_KP_DECIMAL (GLFW_KEY_SPECIAL+60)
|
||||
#define GLFW_KEY_KP_EQUAL (GLFW_KEY_SPECIAL+61)
|
||||
#define GLFW_KEY_KP_ENTER (GLFW_KEY_SPECIAL+62)
|
||||
#define GLFW_KEY_LAST GLFW_KEY_KP_ENTER
|
||||
|
||||
// Mouse button definitions
|
||||
#define GLFW_MOUSE_BUTTON_1 0
|
||||
#define GLFW_MOUSE_BUTTON_2 1
|
||||
#define GLFW_MOUSE_BUTTON_3 2
|
||||
#define GLFW_MOUSE_BUTTON_4 3
|
||||
#define GLFW_MOUSE_BUTTON_5 4
|
||||
#define GLFW_MOUSE_BUTTON_6 5
|
||||
#define GLFW_MOUSE_BUTTON_7 6
|
||||
#define GLFW_MOUSE_BUTTON_8 7
|
||||
#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
|
||||
|
||||
// Mouse button aliases
|
||||
#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
|
||||
#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
|
||||
#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
|
||||
|
||||
|
||||
// Joystick identifiers
|
||||
#define GLFW_JOYSTICK_1 0
|
||||
#define GLFW_JOYSTICK_2 1
|
||||
#define GLFW_JOYSTICK_3 2
|
||||
#define GLFW_JOYSTICK_4 3
|
||||
#define GLFW_JOYSTICK_5 4
|
||||
#define GLFW_JOYSTICK_6 5
|
||||
#define GLFW_JOYSTICK_7 6
|
||||
#define GLFW_JOYSTICK_8 7
|
||||
#define GLFW_JOYSTICK_9 8
|
||||
#define GLFW_JOYSTICK_10 9
|
||||
#define GLFW_JOYSTICK_11 10
|
||||
#define GLFW_JOYSTICK_12 11
|
||||
#define GLFW_JOYSTICK_13 12
|
||||
#define GLFW_JOYSTICK_14 13
|
||||
#define GLFW_JOYSTICK_15 14
|
||||
#define GLFW_JOYSTICK_16 15
|
||||
#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Other definitions
|
||||
//========================================================================
|
||||
|
||||
// glfwOpenWindow modes
|
||||
#define GLFW_WINDOW 0x00010001
|
||||
#define GLFW_FULLSCREEN 0x00010002
|
||||
|
||||
// glfwGetWindowParam tokens
|
||||
#define GLFW_OPENED 0x00020001
|
||||
#define GLFW_ACTIVE 0x00020002
|
||||
#define GLFW_ICONIFIED 0x00020003
|
||||
#define GLFW_ACCELERATED 0x00020004
|
||||
#define GLFW_RED_BITS 0x00020005
|
||||
#define GLFW_GREEN_BITS 0x00020006
|
||||
#define GLFW_BLUE_BITS 0x00020007
|
||||
#define GLFW_ALPHA_BITS 0x00020008
|
||||
#define GLFW_DEPTH_BITS 0x00020009
|
||||
#define GLFW_STENCIL_BITS 0x0002000A
|
||||
|
||||
// The following constants are used for both glfwGetWindowParam
|
||||
// and glfwOpenWindowHint
|
||||
#define GLFW_REFRESH_RATE 0x0002000B
|
||||
#define GLFW_ACCUM_RED_BITS 0x0002000C
|
||||
#define GLFW_ACCUM_GREEN_BITS 0x0002000D
|
||||
#define GLFW_ACCUM_BLUE_BITS 0x0002000E
|
||||
#define GLFW_ACCUM_ALPHA_BITS 0x0002000F
|
||||
#define GLFW_AUX_BUFFERS 0x00020010
|
||||
#define GLFW_STEREO 0x00020011
|
||||
|
||||
// glfwEnable/glfwDisable tokens
|
||||
#define GLFW_MOUSE_CURSOR 0x00030001
|
||||
#define GLFW_STICKY_KEYS 0x00030002
|
||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
|
||||
#define GLFW_SYSTEM_KEYS 0x00030004
|
||||
#define GLFW_KEY_REPEAT 0x00030005
|
||||
#define GLFW_AUTO_POLL_EVENTS 0x00030006
|
||||
|
||||
// glfwWaitThread wait modes
|
||||
#define GLFW_WAIT 0x00040001
|
||||
#define GLFW_NOWAIT 0x00040002
|
||||
|
||||
// glfwGetJoystickParam tokens
|
||||
#define GLFW_PRESENT 0x00050001
|
||||
#define GLFW_AXES 0x00050002
|
||||
#define GLFW_BUTTONS 0x00050003
|
||||
|
||||
// glfwReadImage/glfwLoadTexture2D flags
|
||||
#define GLFW_NO_RESCALE_BIT 0x00000001 // Only for glfwReadImage
|
||||
#define GLFW_ORIGIN_UL_BIT 0x00000002
|
||||
#define GLFW_BUILD_MIPMAPS_BIT 0x00000004 // Only for glfwLoadTexture2D
|
||||
#define GLFW_ALPHA_MAP_BIT 0x00000008
|
||||
|
||||
// Time spans longer than this (seconds) are considered to be infinity
|
||||
#define GLFW_INFINITY 100000.0
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Typedefs
|
||||
//========================================================================
|
||||
|
||||
// The video mode structure used by glfwGetVideoModes()
|
||||
typedef struct {
|
||||
int Width, Height;
|
||||
int RedBits, BlueBits, GreenBits;
|
||||
} GLFWvidmode;
|
||||
|
||||
// Image/texture information
|
||||
typedef struct {
|
||||
int Width, Height;
|
||||
int Format;
|
||||
int BytesPerPixel;
|
||||
unsigned char *Data;
|
||||
} GLFWimage;
|
||||
|
||||
// Thread ID
|
||||
typedef int GLFWthread;
|
||||
|
||||
// Mutex object
|
||||
typedef void * GLFWmutex;
|
||||
|
||||
// Condition variable object
|
||||
typedef void * GLFWcond;
|
||||
|
||||
// Function pointer types
|
||||
typedef void (GLFWCALL * GLFWwindowsizefun)(int,int);
|
||||
typedef int (GLFWCALL * GLFWwindowclosefun)(void);
|
||||
typedef void (GLFWCALL * GLFWwindowrefreshfun)(void);
|
||||
typedef void (GLFWCALL * GLFWmousebuttonfun)(int,int);
|
||||
typedef void (GLFWCALL * GLFWmouseposfun)(int,int);
|
||||
typedef void (GLFWCALL * GLFWmousewheelfun)(int);
|
||||
typedef void (GLFWCALL * GLFWkeyfun)(int,int);
|
||||
typedef void (GLFWCALL * GLFWcharfun)(int,int);
|
||||
typedef void (GLFWCALL * GLFWthreadfun)(void *);
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Prototypes
|
||||
//========================================================================
|
||||
|
||||
// GLFW initialization, termination and version querying
|
||||
GLFWAPI int GLFWAPIENTRY glfwInit( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwTerminate( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwGetVersion( int *major, int *minor, int *rev );
|
||||
|
||||
// Window handling
|
||||
GLFWAPI int GLFWAPIENTRY glfwOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode );
|
||||
GLFWAPI void GLFWAPIENTRY glfwOpenWindowHint( int target, int hint );
|
||||
GLFWAPI void GLFWAPIENTRY glfwCloseWindow( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowTitle( const char *title );
|
||||
GLFWAPI void GLFWAPIENTRY glfwGetWindowSize( int *width, int *height );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowSize( int width, int height );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowPos( int x, int y );
|
||||
GLFWAPI void GLFWAPIENTRY glfwIconifyWindow( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwRestoreWindow( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSwapBuffers( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSwapInterval( int interval );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetWindowParam( int param );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun );
|
||||
|
||||
// Video mode functions
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetVideoModes( GLFWvidmode *list, int maxcount );
|
||||
GLFWAPI void GLFWAPIENTRY glfwGetDesktopMode( GLFWvidmode *mode );
|
||||
|
||||
// Input handling
|
||||
GLFWAPI void GLFWAPIENTRY glfwPollEvents( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwWaitEvents( void );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetKey( int key );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetMouseButton( int button );
|
||||
GLFWAPI void GLFWAPIENTRY glfwGetMousePos( int *xpos, int *ypos );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetMousePos( int xpos, int ypos );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetMouseWheel( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetMouseWheel( int pos );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetKeyCallback( GLFWkeyfun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetCharCallback( GLFWcharfun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetMousePosCallback( GLFWmouseposfun cbfun );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun );
|
||||
|
||||
// Joystick input
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetJoystickParam( int joy, int param );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetJoystickPos( int joy, float *pos, int numaxes );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons );
|
||||
|
||||
// Time
|
||||
GLFWAPI double GLFWAPIENTRY glfwGetTime( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSetTime( double time );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSleep( double time );
|
||||
|
||||
// Extension support
|
||||
GLFWAPI int GLFWAPIENTRY glfwExtensionSupported( const char *extension );
|
||||
GLFWAPI void* GLFWAPIENTRY glfwGetProcAddress( const char *procname );
|
||||
GLFWAPI void GLFWAPIENTRY glfwGetGLVersion( int *major, int *minor, int *rev );
|
||||
|
||||
// Threading support
|
||||
GLFWAPI GLFWthread GLFWAPIENTRY glfwCreateThread( GLFWthreadfun fun, void *arg );
|
||||
GLFWAPI void GLFWAPIENTRY glfwDestroyThread( GLFWthread ID );
|
||||
GLFWAPI int GLFWAPIENTRY glfwWaitThread( GLFWthread ID, int waitmode );
|
||||
GLFWAPI GLFWthread GLFWAPIENTRY glfwGetThreadID( void );
|
||||
GLFWAPI GLFWmutex GLFWAPIENTRY glfwCreateMutex( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwDestroyMutex( GLFWmutex mutex );
|
||||
GLFWAPI void GLFWAPIENTRY glfwLockMutex( GLFWmutex mutex );
|
||||
GLFWAPI void GLFWAPIENTRY glfwUnlockMutex( GLFWmutex mutex );
|
||||
GLFWAPI GLFWcond GLFWAPIENTRY glfwCreateCond( void );
|
||||
GLFWAPI void GLFWAPIENTRY glfwDestroyCond( GLFWcond cond );
|
||||
GLFWAPI void GLFWAPIENTRY glfwWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout );
|
||||
GLFWAPI void GLFWAPIENTRY glfwSignalCond( GLFWcond cond );
|
||||
GLFWAPI void GLFWAPIENTRY glfwBroadcastCond( GLFWcond cond );
|
||||
GLFWAPI int GLFWAPIENTRY glfwGetNumberOfProcessors( void );
|
||||
|
||||
// Enable/disable functions
|
||||
GLFWAPI void GLFWAPIENTRY glfwEnable( int token );
|
||||
GLFWAPI void GLFWAPIENTRY glfwDisable( int token );
|
||||
|
||||
// Image/texture I/O support
|
||||
GLFWAPI int GLFWAPIENTRY glfwReadImage( const char *name, GLFWimage *img, int flags );
|
||||
GLFWAPI void GLFWAPIENTRY glfwFreeImage( GLFWimage *img );
|
||||
GLFWAPI int GLFWAPIENTRY glfwLoadTexture2D( const char *name, int flags );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __glfw_h_
|
||||
BIN
Extras/CDTestFramework/AntTweakBar/examples/glfwdll.lib
Normal file
BIN
Extras/CDTestFramework/AntTweakBar/examples/glfwdll.lib
Normal file
Binary file not shown.
Reference in New Issue
Block a user