├── README.TXT
├── build
├── codeblocks.unix
│ ├── DEMOGL.cbp
│ ├── DEMOGL.layout
│ ├── OpenGL.workspace
│ └── log.txt
├── codelite.unix
│ ├── DEMOGL.mk
│ ├── DEMOGL.project
│ └── OpenGL.workspace
└── gmake.unix
│ ├── DEMOGL.make
│ └── Makefile
└── src
├── anttweakbar
├── AntPerfTimer.h
├── AntTweakBar.h
├── AntTweakBar.rc
├── AntTweakBar.sln
├── AntTweakBar.vcproj
├── LoadOGL.cpp
├── LoadOGL.h
├── LoadOGLCore.cpp
├── LoadOGLCore.h
├── MiniGLUT.h
├── TwBar.cpp
├── TwBar.h
├── TwColors.cpp
├── TwColors.h
├── TwEventGLUT.c
├── TwEventWin.c
├── TwEventX11.c
├── TwFonts.cpp
├── TwFonts.h
├── TwGraph.h
├── TwMgr.cpp
├── TwMgr.h
├── TwOpenGL.cpp
├── TwOpenGL.h
├── TwOpenGLCore.cpp
├── TwOpenGLCore.h
├── TwPrecomp.cpp
├── TwPrecomp.h
├── res
│ ├── FontChars.txt
│ ├── FontFixed1.pgm
│ ├── FontLargeAA.pgm
│ ├── FontNormal.pgm
│ ├── FontNormalAA.pgm
│ ├── FontSmall.pgm
│ ├── TwXCursors.h
│ ├── cur00000.cur
│ ├── cur00001.cur
│ ├── cur00002.cur
│ ├── cur00003.cur
│ ├── cur00004.cur
│ ├── cur00005.cur
│ ├── cur00006.cur
│ ├── cur00007.cur
│ ├── cur00008.cur
│ ├── cur00009.cur
│ ├── cur00010.cur
│ ├── cur00011.cur
│ ├── cur00012.cur
│ ├── cur00013.cur
│ ├── curs00.pbm
│ ├── curs01.pbm
│ ├── curs02.pbm
│ ├── curs03.pbm
│ ├── curs04.pbm
│ ├── curs05.pbm
│ ├── curs06.pbm
│ ├── curs07.pbm
│ ├── curs08.pbm
│ ├── curs09.pbm
│ ├── curs10.pbm
│ ├── curs11.pbm
│ ├── curs12.pbm
│ ├── curs13.pbm
│ ├── mask00.pbm
│ ├── mask01.pbm
│ ├── mask02.pbm
│ ├── mask03.pbm
│ ├── mask04.pbm
│ ├── mask05.pbm
│ ├── mask06.pbm
│ ├── mask07.pbm
│ ├── mask08.pbm
│ ├── mask09.pbm
│ ├── mask10.pbm
│ ├── mask11.pbm
│ ├── mask12.pbm
│ └── mask13.pbm
└── resource.h
├── callbacks.cpp
├── callbacks.hpp
├── debug.cpp
├── debug.hpp
├── freeglut
├── GL
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── freeglut.h
│ ├── freeglut_ext.h
│ ├── freeglut_std.h
│ └── glut.h
├── freeglut_callbacks.c
├── freeglut_cursor.c
├── freeglut_display.c
├── freeglut_ext.c
├── freeglut_font.c
├── freeglut_font_data.c
├── freeglut_gamemode.c
├── freeglut_geometry.c
├── freeglut_glutfont_definitions.c
├── freeglut_init.c
├── freeglut_input_devices.c
├── freeglut_internal.h
├── freeglut_joystick.c
├── freeglut_main.c
├── freeglut_menu.c
├── freeglut_misc.c
├── freeglut_overlay.c
├── freeglut_spaceball.c
├── freeglut_state.c
├── freeglut_stroke_mono_roman.c
├── freeglut_stroke_roman.c
├── freeglut_structure.c
├── freeglut_teapot.c
├── freeglut_teapot_data.h
├── freeglut_videoresize.c
├── freeglut_window.c
├── freeglut_xinput.c
└── templates
│ ├── cpp_template
│ └── header_template
├── gl3w
├── GL3
│ ├── gl3.h
│ └── gl3w.h
└── gl3w.c
├── glu.cpp
├── glu.hpp
├── main.cpp
├── math
├── Affine.cpp
├── Algebra.hpp
├── Matrix2x2.cpp
├── Matrix3x3.cpp
├── Matrix4x4.cpp
├── Projection.cpp
├── Transform.hpp
├── Vector2.cpp
├── Vector3.cpp
└── Vector4.cpp
├── scripts
├── premake4.lua
└── release.lua
└── shaders
├── cornell.glsl
└── ssgi.glsl
/README.TXT:
--------------------------------------------------------------------------------
1 | OpenGL demonstration project
2 | ----------------------------------------
3 |
4 | Work in progress
5 |
6 | Ubuntu dependencies
7 | - libxi-dev libx11-dev
8 |
--------------------------------------------------------------------------------
/build/codeblocks.unix/DEMOGL.cbp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
--------------------------------------------------------------------------------
/build/codeblocks.unix/DEMOGL.layout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/build/codeblocks.unix/OpenGL.workspace:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/build/codeblocks.unix/log.txt:
--------------------------------------------------------------------------------
1 | Feb 4 2013:17:25:41
2 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
3 | > Creating dummy window...
4 | > Platform information:
5 | > GL_VENDOR NVIDIA Corporation
6 | > GL_RENDERER Quadro 6000/PCIe/SSE2
7 | > GL_VERSION 4.3.0 NVIDIA 313.09
8 | > GL_SHADING_LANGUAGE_VERSION 4.30 NVIDIA via Cg compiler
9 | > Creating requested window...
10 | > Initializing resources...
11 | > GL_ARB_debug_output enabled.
12 | > Loading program file "cornell.glsl"...
13 | > Loading program file "ssgi.glsl"...
14 | > Running...
15 | > GL_ARB_debug_output:
16 | Program/shader state performance warning: Fragment Shader is going to be recompiled because the shader key based on GL state mismatches..
17 | > Loading program file "cornell.glsl"...
18 | > Loading program file "ssgi.glsl"...
19 | > GL_ARB_debug_output:
20 | Program/shader state performance warning: Fragment Shader is going to be recompiled because the shader key based on GL state mismatches..
21 | > Loading program file "cornell.glsl"...
22 | > Loading program file "ssgi.glsl"...
23 | > GL_ARB_debug_output:
24 | Program/shader state performance warning: Fragment Shader is going to be recompiled because the shader key based on GL state mismatches..
25 | > GL_ARB_debug_output:
26 | Buffer performance warning: Buffer object 1 (bound to GL_UNIFORM_BUFFER (0), and GL_UNIFORM_BUFFER_EXT, usage hint is GL_STATIC_DRAW) is being copied/moved from VIDEO memory to SYSTEM HEAP memory..
27 | > Cleaning up...
28 |
--------------------------------------------------------------------------------
/build/codelite.unix/DEMOGL.project:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | None
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | None
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/build/codelite.unix/OpenGL.workspace:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/build/gmake.unix/Makefile:
--------------------------------------------------------------------------------
1 | # GNU Make solution makefile autogenerated by Premake
2 | # Type "make help" for usage help
3 |
4 | ifndef config
5 | config=debug
6 | endif
7 | export config
8 |
9 | PROJECTS := DEMOGL
10 |
11 | .PHONY: all clean help $(PROJECTS)
12 |
13 | all: $(PROJECTS)
14 |
15 | DEMOGL:
16 | @echo "==== Building DEMOGL ($(config)) ===="
17 | @${MAKE} --no-print-directory -C . -f DEMOGL.make
18 |
19 | clean:
20 | @${MAKE} --no-print-directory -C . -f DEMOGL.make clean
21 |
22 | help:
23 | @echo "Usage: make [config=name] [target]"
24 | @echo ""
25 | @echo "CONFIGURATIONS:"
26 | @echo " debug"
27 | @echo " release"
28 | @echo ""
29 | @echo "TARGETS:"
30 | @echo " all (default)"
31 | @echo " clean"
32 | @echo " DEMOGL"
33 | @echo ""
34 | @echo "For more information, see http://industriousone.com/premake/quick-start"
35 |
--------------------------------------------------------------------------------
/src/anttweakbar/AntPerfTimer.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file AntPerfTimer.h
4 | // @brief A performance (precision) timer for benchs
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // note: No cpp file is needed, everything is defined in this header
10 | //
11 | // ---------------------------------------------------------------------------
12 |
13 | #if !defined ANT_PERF_TIMER_INCLUDED
14 | #define ANT_PERF_TIMER_INCLUDED
15 |
16 | #ifndef __cplusplus
17 | # error This is a C++ header
18 | #endif // __cplusplus
19 |
20 |
21 | #if defined(WIN32) || defined(WIN64) || defined(_WIN32) || defined(_WIN64)
22 |
23 | #include
24 | #include
25 |
26 | struct PerfTimer
27 | {
28 | inline PerfTimer() { if( !QueryPerformanceFrequency(&Freq) ) MessageBox(NULL, _T("Precision timer not supported"), _T("Problem"), MB_ICONEXCLAMATION); Reset(); }
29 | inline void Reset() { QueryPerformanceCounter(&Start); }
30 | inline double GetTime() { if( QueryPerformanceCounter(&End) ) return ((double)End.QuadPart - (double)Start.QuadPart)/((double)Freq.QuadPart); else return 0; }
31 | protected:
32 | LARGE_INTEGER Start, End, Freq;
33 | };
34 |
35 | #else // !_WIN (-> LINUX)
36 |
37 | #include
38 | #include
39 |
40 | struct PerfTimer
41 | {
42 | inline PerfTimer() { Reset(); }
43 | inline void Reset() { gettimeofday(&Start, &TZ); }
44 | inline double GetTime() { gettimeofday(&End,&TZ);
45 | double t1 = (double)Start.tv_sec + (double)Start.tv_usec/(1000*1000);
46 | double t2 = (double)End.tv_sec + (double)End.tv_usec/(1000*1000);
47 | return t2-t1; }
48 | protected:
49 | struct timeval Start, End;
50 | struct timezone TZ;
51 | };
52 |
53 | #endif // _WIN
54 |
55 |
56 | #endif // ANT_PERF_TIMER_INCLUDED
57 |
--------------------------------------------------------------------------------
/src/anttweakbar/AntTweakBar.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jdupuy/ssgi/1e44048af63779d49bd250b73386841edbfc98ea/src/anttweakbar/AntTweakBar.rc
--------------------------------------------------------------------------------
/src/anttweakbar/AntTweakBar.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 10.00
2 | # Visual C++ Express 2008
3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AntTweakBar", "AntTweakBar.vcproj", "{B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}"
4 | EndProject
5 | Global
6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
7 | Debug|Win32 = Debug|Win32
8 | Debug|x64 = Debug|x64
9 | Release|Win32 = Release|Win32
10 | Release|x64 = Release|x64
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Debug|Win32.ActiveCfg = Debug|Win32
14 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Debug|Win32.Build.0 = Debug|Win32
15 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Debug|x64.ActiveCfg = Debug|x64
16 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Debug|x64.Build.0 = Debug|x64
17 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Release|Win32.ActiveCfg = Release|Win32
18 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Release|Win32.Build.0 = Release|Win32
19 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Release|x64.ActiveCfg = Release|x64
20 | {B99E1FA1-C30A-45F2-9D57-9E9C21B2DF42}.Release|x64.Build.0 = Release|x64
21 | EndGlobalSection
22 | GlobalSection(SolutionProperties) = preSolution
23 | HideSolutionNode = FALSE
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/src/anttweakbar/MiniGLUT.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file MiniGLUT.h
4 | // @brief A subset of GLUT definitions needed to compile helper functions
5 | // implemented in TwEventGLUT.c
6 | //
7 | // notes: - Private header
8 | // - AntTweakBar.dll does not need to link with GLUT,
9 | // it just needs some definitions for its helper functions.
10 | // - This header is provided to avoid the need of having GLUT
11 | // installed to recompile AntTweakBar.
12 | // - Do not use this header in your own programs, better use the
13 | // GLUT.h header from the actual GLUT library SDK :
14 | // http://opengl.org/resources/libraries/glut
15 | //
16 | // ---------------------------------------------------------------------------
17 |
18 | #if !defined MINI_GLUT_INCLUDED
19 | #define MINI_GLUT_INCLUDED
20 |
21 | #if defined(_WIN32) || defined(_WIN64)
22 | # define WIN32_LEAN_AND_MEAN
23 | # include // needed by gl.h
24 | # define GLUT_CALL __stdcall
25 | # define GLUT_CALLBACK __cdecl
26 | # define GLUT_API __declspec(dllimport)
27 | #else
28 | # define GLUT_CALL
29 | # define GLUT_CALLBACK
30 | # define GLUT_API extern
31 | #endif
32 |
33 | #if defined(_MACOSX)
34 | # include
35 | # include
36 | #else
37 | # include // must be included after windows.h
38 | # include
39 | #endif
40 |
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 |
45 |
46 | // Mouse buttons
47 | #define GLUT_LEFT_BUTTON 0
48 | #define GLUT_MIDDLE_BUTTON 1
49 | #define GLUT_RIGHT_BUTTON 2
50 |
51 | // Mouse button state
52 | #define GLUT_DOWN 0
53 | #define GLUT_UP 1
54 |
55 | // glutGetModifiers return mask
56 | #define GLUT_ACTIVE_SHIFT 1
57 | #define GLUT_ACTIVE_CTRL 2
58 | #define GLUT_ACTIVE_ALT 4
59 |
60 | // function keys
61 | #define GLUT_KEY_F1 1
62 | #define GLUT_KEY_F2 2
63 | #define GLUT_KEY_F3 3
64 | #define GLUT_KEY_F4 4
65 | #define GLUT_KEY_F5 5
66 | #define GLUT_KEY_F6 6
67 | #define GLUT_KEY_F7 7
68 | #define GLUT_KEY_F8 8
69 | #define GLUT_KEY_F9 9
70 | #define GLUT_KEY_F10 10
71 | #define GLUT_KEY_F11 11
72 | #define GLUT_KEY_F12 12
73 |
74 | // directional keys
75 | #define GLUT_KEY_LEFT 100
76 | #define GLUT_KEY_UP 101
77 | #define GLUT_KEY_RIGHT 102
78 | #define GLUT_KEY_DOWN 103
79 | #define GLUT_KEY_PAGE_UP 104
80 | #define GLUT_KEY_PAGE_DOWN 105
81 | #define GLUT_KEY_HOME 106
82 | #define GLUT_KEY_END 107
83 | #define GLUT_KEY_INSERT 108
84 |
85 | // display mode bit masks
86 | #define GLUT_RGB 0
87 | #define GLUT_RGBA GLUT_RGB
88 | #define GLUT_INDEX 1
89 | #define GLUT_SINGLE 0
90 | #define GLUT_DOUBLE 2
91 | #define GLUT_ACCUM 4
92 | #define GLUT_ALPHA 8
93 | #define GLUT_DEPTH 16
94 | #define GLUT_STENCIL 32
95 |
96 | // timer
97 | #define GLUT_ELAPSED_TIME ((GLenum) 700)
98 |
99 |
100 | // functions subset
101 | GLUT_API void GLUT_CALL glutInit(int *argcp, char **argv);
102 | GLUT_API void GLUT_CALL glutInitDisplayMode(unsigned int mode);
103 | GLUT_API int GLUT_CALL glutCreateWindow(const char *title);
104 | GLUT_API int GLUT_CALL glutGetWindow(void);
105 | GLUT_API void GLUT_CALL glutSetWindow(int win);
106 | GLUT_API int GLUT_CALL glutCreateSubWindow(int win, int x, int y, int width, int height);
107 | GLUT_API int GLUT_CALL glutGet(GLenum type);
108 | GLUT_API void GLUT_CALL glutSwapBuffers();
109 | GLUT_API void GLUT_CALL glutPostRedisplay();
110 | GLUT_API void GLUT_CALL glutInitWindowPosition(int x, int y);
111 | GLUT_API void GLUT_CALL glutInitWindowSize(int width, int height);
112 | GLUT_API void GLUT_CALL glutPositionWindow(int x, int y);
113 | GLUT_API void GLUT_CALL glutReshapeWindow(int width, int height);
114 | GLUT_API void GLUT_CALL glutMainLoop();
115 | GLUT_API int GLUT_CALL glutCreateMenu(void (GLUT_CALLBACK *func)(int));
116 | GLUT_API void GLUT_CALL glutDisplayFunc(void (GLUT_CALLBACK *func)(void));
117 | GLUT_API void GLUT_CALL glutReshapeFunc(void (GLUT_CALLBACK *func)(int width, int height));
118 | GLUT_API void GLUT_CALL glutKeyboardFunc(void (GLUT_CALLBACK *func)(unsigned char key, int x, int y));
119 | GLUT_API void GLUT_CALL glutMouseFunc(void (GLUT_CALLBACK *func)(int button, int state, int x, int y));
120 | GLUT_API void GLUT_CALL glutMotionFunc(void (GLUT_CALLBACK *func)(int x, int y));
121 | GLUT_API void GLUT_CALL glutPassiveMotionFunc(void (GLUT_CALLBACK *func)(int x, int y));
122 | GLUT_API void GLUT_CALL glutSpecialFunc(void (GLUT_CALLBACK *func)(int key, int x, int y));
123 | GLUT_API int GLUT_CALL glutGetModifiers(void);
124 | GLUT_API void GLUT_CALL glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
125 | GLUT_API void GLUT_CALL glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
126 | GLUT_API void GLUT_CALL glutSolidTeapot(GLdouble size);
127 |
128 | // GLUT exit problem workaround (see glut.h)
129 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(GLUT_DISABLE_ATEXIT_HACK)
130 | extern void __cdecl exit(int);
131 | GLUT_API void GLUT_CALL __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
132 | static void GLUT_CALL glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
133 | #define glutInit glutInit_ATEXIT_HACK
134 | #endif
135 |
136 |
137 | #ifdef __cplusplus
138 | }
139 | #endif
140 |
141 | #endif // !defined MINI_GLUT_INCLUDED
142 |
143 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwColors.cpp:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwColors.cpp
4 | // @author Philippe Decaudin - http://www.antisphere.com
5 | // @license This file is part of the AntTweakBar library.
6 | // For conditions of distribution and use, see License.txt
7 | //
8 | // ---------------------------------------------------------------------------
9 |
10 |
11 | #include "TwPrecomp.h"
12 | #include "TwColors.h"
13 |
14 |
15 | void ColorRGBToHLSf(float _R, float _G, float _B, float *_Hue, float *_Light, float *_Saturation)
16 | {
17 | // Compute HLS from RGB. The r,g,b triplet is between [0,1],
18 | // hue is between [0,360], light and saturation are [0,1].
19 |
20 | float rnorm, gnorm, bnorm, minval, maxval, msum, mdiff, r, g, b;
21 | r = g = b = 0;
22 | if(_R>0) r = _R; if(r>1) r = 1;
23 | if(_G>0) g = _G; if(g>1) g = 1;
24 | if(_B>0) b = _B; if(b>1) b = 1;
25 |
26 | minval = r;
27 | if(gmaxval) maxval = g;
31 | if(b>maxval) maxval = b;
32 |
33 | rnorm = gnorm = bnorm = 0;
34 | mdiff = maxval - minval;
35 | msum = maxval + minval;
36 | float l = 0.5f * msum;
37 | if(_Light)
38 | *_Light = l;
39 | if(maxval!=minval)
40 | {
41 | rnorm = (maxval - r)/mdiff;
42 | gnorm = (maxval - g)/mdiff;
43 | bnorm = (maxval - b)/mdiff;
44 | }
45 | else
46 | {
47 | if(_Saturation)
48 | *_Saturation = 0;
49 | if(_Hue)
50 | *_Hue = 0;
51 | return;
52 | }
53 |
54 | if(_Saturation)
55 | {
56 | if(l<0.5f)
57 | *_Saturation = mdiff/msum;
58 | else
59 | *_Saturation = mdiff/(2.0f - msum);
60 | }
61 |
62 | if(_Hue)
63 | {
64 | if(r==maxval)
65 | *_Hue = 60.0f * (6.0f + bnorm - gnorm);
66 | else if(g==maxval)
67 | *_Hue = 60.0f * (2.0f + rnorm - bnorm);
68 | else
69 | *_Hue = 60.0f * (4.0f + gnorm - rnorm);
70 |
71 | if(*_Hue>360.0f)
72 | *_Hue -= 360.0f;
73 | }
74 | }
75 |
76 |
77 | void ColorRGBToHLSi(int _R, int _G, int _B, int *_Hue, int *_Light, int *_Saturation)
78 | {
79 | float h, l, s;
80 | ColorRGBToHLSf((1.0f/255.0f)*float(_R), (1.0f/255.0f)*float(_G), (1.0f/255.0f)*float(_B), &h, &l, &s);
81 | if(_Hue) *_Hue = (int)TClamp(h*(256.0f/360.0f), 0.0f, 255.0f);
82 | if(_Light) *_Light = (int)TClamp(l*256.0f, 0.0f, 255.0f);
83 | if(_Saturation) *_Saturation= (int)TClamp(s*256.0f, 0.0f, 255.0f);
84 | }
85 |
86 |
87 | void ColorHLSToRGBf(float _Hue, float _Light, float _Saturation, float *_R, float *_G, float *_B)
88 | {
89 | // Compute RGB from HLS. The light and saturation are between [0,1]
90 | // and hue is between [0,360]. The returned r,g,b triplet is between [0,1].
91 |
92 | // a local auxiliary function
93 | struct CLocal
94 | {
95 | static float HLSToRGB(float _Rn1, float _Rn2, float _Huei)
96 | {
97 | float hue = _Huei;
98 | if(hue>360) hue = hue - 360;
99 | if(hue<0) hue = hue + 360;
100 | if(hue<60 ) return _Rn1 + (_Rn2-_Rn1)*hue/60;
101 | if(hue<180) return _Rn2;
102 | if(hue<240) return _Rn1 + (_Rn2-_Rn1)*(240-hue)/60;
103 | return _Rn1;
104 | }
105 | };
106 |
107 | float rh, rl, rs, rm1, rm2;
108 | rh = rl = rs = 0;
109 | if(_Hue>0) rh = _Hue; if(rh>360) rh = 360;
110 | if(_Light>0) rl = _Light; if(rl>1) rl = 1;
111 | if(_Saturation>0) rs = _Saturation; if(rs>1) rs = 1;
112 |
113 | if(rl<=0.5f)
114 | rm2 = rl*(1.0f + rs);
115 | else
116 | rm2 = rl + rs - rl*rs;
117 | rm1 = 2.0f*rl - rm2;
118 |
119 | if(!rs)
120 | {
121 | if(_R) *_R = rl;
122 | if(_G) *_G = rl;
123 | if(_B) *_B = rl;
124 | }
125 | else
126 | {
127 | if(_R) *_R = CLocal::HLSToRGB(rm1, rm2, rh+120);
128 | if(_G) *_G = CLocal::HLSToRGB(rm1, rm2, rh);
129 | if(_B) *_B = CLocal::HLSToRGB(rm1, rm2, rh-120);
130 | }
131 | }
132 |
133 |
134 | void ColorHLSToRGBi(int _Hue, int _Light, int _Saturation, int *_R, int *_G, int *_B)
135 | {
136 | float r, g, b;
137 | ColorHLSToRGBf((360.0f/255.0f)*float(_Hue), (1.0f/255.0f)*float(_Light), (1.0f/255.0f)*float(_Saturation), &r, &g, &b);
138 | if(_R) *_R = (int)TClamp(r*256.0f, 0.0f, 255.0f);
139 | if(_G) *_G = (int)TClamp(g*256.0f, 0.0f, 255.0f);
140 | if(_B) *_B = (int)TClamp(b*256.0f, 0.0f, 255.0f);
141 | }
142 |
143 |
144 | color32 ColorBlend(color32 _Color1, color32 _Color2, float _S)
145 | {
146 | float a1, r1, g1, b1, a2, r2, g2, b2;
147 | Color32ToARGBf(_Color1, &a1, &r1, &g1, &b1);
148 | Color32ToARGBf(_Color2, &a2, &r2, &g2, &b2);
149 | float t = 1.0f-_S;
150 | return Color32FromARGBf(t*a1+_S*a2, t*r1+_S*r2, t*g1+_S*g2, t*b1+_S*b2);
151 | }
152 |
153 |
154 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwColors.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwColors.h
4 | // @brief Color conversions
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // note: Private header
10 | //
11 | // ---------------------------------------------------------------------------
12 |
13 |
14 | #if !defined ANT_TW_COLORS_INCLUDED
15 | #define ANT_TW_COLORS_INCLUDED
16 |
17 |
18 | // ---------------------------------------------------------------------------
19 |
20 |
21 | typedef unsigned int color32;
22 |
23 |
24 | const color32 COLOR32_BLACK = 0xff000000; // Black
25 | const color32 COLOR32_WHITE = 0xffffffff; // White
26 | const color32 COLOR32_ZERO = 0x00000000; // Zero
27 | const color32 COLOR32_RED = 0xffff0000; // Red
28 | const color32 COLOR32_GREEN = 0xff00ff00; // Green
29 | const color32 COLOR32_BLUE = 0xff0000ff; // Blue
30 |
31 |
32 | template inline const _T& TClamp(const _T& _X, const _T& _Limit1, const _T& _Limit2)
33 | {
34 | if( _Limit1<_Limit2 )
35 | return (_X<=_Limit1) ? _Limit1 : ( (_X>=_Limit2) ? _Limit2 : _X );
36 | else
37 | return (_X<=_Limit2) ? _Limit2 : ( (_X>=_Limit1) ? _Limit1 : _X );
38 | }
39 |
40 | inline color32 Color32FromARGBi(int _A, int _R, int _G, int _B)
41 | {
42 | return (((color32)TClamp(_A, 0, 255))<<24) | (((color32)TClamp(_R, 0, 255))<<16) | (((color32)TClamp(_G, 0, 255))<<8) | ((color32)TClamp(_B, 0, 255));
43 | }
44 |
45 | inline color32 Color32FromARGBf(float _A, float _R, float _G, float _B)
46 | {
47 | return (((color32)TClamp(_A*256.0f, 0.0f, 255.0f))<<24) | (((color32)TClamp(_R*256.0f, 0.0f, 255.0f))<<16) | (((color32)TClamp(_G*256.0f, 0.0f, 255.0f))<<8) | ((color32)TClamp(_B*256.0f, 0.0f, 255.0f));
48 | }
49 |
50 | inline void Color32ToARGBi(color32 _Color, int *_A, int *_R, int *_G, int *_B)
51 | {
52 | if(_A) *_A = (_Color>>24)&0xff;
53 | if(_R) *_R = (_Color>>16)&0xff;
54 | if(_G) *_G = (_Color>>8)&0xff;
55 | if(_B) *_B = _Color&0xff;
56 | }
57 |
58 | inline void Color32ToARGBf(color32 _Color, float *_A, float *_R, float *_G, float *_B)
59 | {
60 | if(_A) *_A = (1.0f/255.0f)*float((_Color>>24)&0xff);
61 | if(_R) *_R = (1.0f/255.0f)*float((_Color>>16)&0xff);
62 | if(_G) *_G = (1.0f/255.0f)*float((_Color>>8)&0xff);
63 | if(_B) *_B = (1.0f/255.0f)*float(_Color&0xff);
64 | }
65 |
66 | void ColorRGBToHLSf(float _R, float _G, float _B, float *_Hue, float *_Light, float *_Saturation);
67 |
68 | void ColorRGBToHLSi(int _R, int _G, int _B, int *_Hue, int *_Light, int *_Saturation);
69 |
70 | void ColorHLSToRGBf(float _Hue, float _Light, float _Saturation, float *_R, float *_G, float *_B);
71 |
72 | void ColorHLSToRGBi(int _Hue, int _Light, int _Saturation, int *_R, int *_G, int *_B);
73 |
74 | color32 ColorBlend(color32 _Color1, color32 _Color2, float _S);
75 |
76 |
77 | // ---------------------------------------------------------------------------
78 |
79 |
80 | #endif // !defined ANT_TW_COLORS_INCLUDED
81 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwEventGLUT.c:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwEventGLUT.c
4 | // @brief Helper:
5 | // translate and re-send mouse and keyboard events
6 | // from GLUT event callbacks to AntTweakBar
7 | //
8 | // @author Philippe Decaudin - http://www.antisphere.com
9 | // @date 2006/05/10
10 | // @license This file is part of the AntTweakBar library.
11 | // For conditions of distribution and use, see License.txt
12 | //
13 | // ---------------------------------------------------------------------------
14 |
15 |
16 | #define GLUT_NO_LIB_PRAGMA // we do not want to force linkage with glut
17 | #ifdef _MSC_VER
18 | # pragma warning(disable: 4505) // glut generates 'unreferenced function' warnings
19 | # pragma warning(disable: 4100) // unreferenced parameter
20 | #endif // _MSC_VER
21 |
22 | // #include
23 | #include "MiniGLUT.h" // a subset of glut.h needed to compile TwEventGLUT.c
24 | // note: AntTweakBar.dll does not need to link with GLUT,
25 | // it just needs some definitions for its helper functions.
26 |
27 | #include
28 |
29 |
30 | int TW_GLUT_CALL TwEventMouseButtonGLUT(int glutButton, int glutState, int mouseX, int mouseY)
31 | {
32 | TwMouseAction action = (glutState==GLUT_DOWN) ? TW_MOUSE_PRESSED : TW_MOUSE_RELEASED;
33 |
34 | TwMouseMotion(mouseX, mouseY);
35 | switch( glutButton )
36 | {
37 | case GLUT_LEFT_BUTTON:
38 | return TwMouseButton(action, TW_MOUSE_LEFT);
39 | case GLUT_RIGHT_BUTTON:
40 | return TwMouseButton(action, TW_MOUSE_RIGHT);
41 | case GLUT_MIDDLE_BUTTON:
42 | return TwMouseButton(action, TW_MOUSE_MIDDLE);
43 | default:
44 | return 0;
45 | }
46 | }
47 |
48 | int TW_GLUT_CALL TwEventMouseMotionGLUT(int mouseX, int mouseY)
49 | {
50 | return TwMouseMotion(mouseX, mouseY);
51 | }
52 |
53 |
54 | // GLUT does not send modifiers state to 'Key' and 'Special' callbacks,
55 | // and we cannot call glutGetModifiers here because we do not want to link
56 | // AntTweakBar with glut, so the following function is used to store
57 | // a pointer to the glutGetModifiers function of the calling application.
58 | // It must be called at initialisation of the application.
59 |
60 | int (TW_CALL *g_GLUTGetModifiers)(void) = NULL;
61 |
62 | int TW_CALL TwGLUTModifiersFunc(int (TW_CALL *glutGetModifiersFunc)(void))
63 | {
64 | g_GLUTGetModifiers = glutGetModifiersFunc;
65 | return (g_GLUTGetModifiers==NULL) ? 0 : 1;
66 | }
67 |
68 |
69 | int TW_GLUT_CALL TwEventKeyboardGLUT(unsigned char glutKey, int mouseX, int mouseY)
70 | {
71 | int kmod = 0;
72 |
73 | if( g_GLUTGetModifiers!=NULL )
74 | {
75 | int glutMod = g_GLUTGetModifiers();
76 |
77 | if( glutMod&GLUT_ACTIVE_SHIFT )
78 | kmod |= TW_KMOD_SHIFT;
79 | if( glutMod&GLUT_ACTIVE_CTRL )
80 | kmod |= TW_KMOD_CTRL;
81 | if( glutMod&GLUT_ACTIVE_ALT )
82 | kmod |= TW_KMOD_ALT;
83 | }
84 |
85 | if( (kmod&TW_KMOD_CTRL) && (glutKey>0 && glutKey<27) ) // CTRL special case
86 | glutKey += 'a'-1;
87 |
88 | return TwKeyPressed((int)glutKey, kmod);
89 | }
90 |
91 |
92 | int TW_GLUT_CALL TwEventSpecialGLUT(int glutKey, int mouseX, int mouseY)
93 | {
94 | int k = 0, kmod = 0;
95 |
96 | if( g_GLUTGetModifiers!=NULL )
97 | {
98 | int glutMod = g_GLUTGetModifiers();
99 |
100 | if( glutMod&GLUT_ACTIVE_SHIFT )
101 | kmod |= TW_KMOD_SHIFT;
102 | if( glutMod&GLUT_ACTIVE_CTRL )
103 | kmod |= TW_KMOD_CTRL;
104 | if( glutMod&GLUT_ACTIVE_ALT )
105 | kmod |= TW_KMOD_ALT;
106 | }
107 |
108 | if( glutKey>=GLUT_KEY_F1 && glutKey<=GLUT_KEY_F12 )
109 | k = TW_KEY_F1 + (glutKey-GLUT_KEY_F1);
110 | else
111 | {
112 | switch( glutKey )
113 | {
114 | case GLUT_KEY_LEFT:
115 | k = TW_KEY_LEFT;
116 | break;
117 | case GLUT_KEY_UP:
118 | k = TW_KEY_UP;
119 | break;
120 | case GLUT_KEY_RIGHT:
121 | k = TW_KEY_RIGHT;
122 | break;
123 | case GLUT_KEY_DOWN:
124 | k = TW_KEY_DOWN;
125 | break;
126 | case GLUT_KEY_PAGE_UP:
127 | k = TW_KEY_PAGE_UP;
128 | break;
129 | case GLUT_KEY_PAGE_DOWN:
130 | k = TW_KEY_PAGE_DOWN;
131 | break;
132 | case GLUT_KEY_HOME:
133 | k = TW_KEY_HOME;
134 | break;
135 | case GLUT_KEY_END:
136 | k = TW_KEY_END;
137 | break;
138 | case GLUT_KEY_INSERT:
139 | k = TW_KEY_INSERT;
140 | break;
141 | }
142 | }
143 |
144 | if( k>0 && k
15 | #include
16 | #include
17 | #include
18 |
19 | static int s_KMod = 0;
20 | const int buff_sz = 80;
21 |
22 | // ----------------------------------------------------------------------
23 | // ----------------------------------------------------------------------
24 | static int _XKeyRelease(XEvent *event)
25 | {
26 | KeySym keysym;
27 | char buffer[buff_sz];
28 |
29 | XLookupString((XKeyEvent *)event, buffer, buff_sz, &keysym, 0);
30 |
31 | switch (keysym)
32 | {
33 | case XK_Control_L:
34 | case XK_Control_R: s_KMod &= ~TW_KMOD_CTRL; break;
35 |
36 | case XK_Shift_L:
37 | case XK_Shift_R: s_KMod &= ~TW_KMOD_SHIFT; break;
38 |
39 | case XK_Alt_L:
40 | case XK_Alt_R: s_KMod &= ~TW_KMOD_ALT; break;
41 | }
42 | return 0;
43 | }
44 |
45 | // ----------------------------------------------------------------------
46 | // ----------------------------------------------------------------------
47 | static int _XKeyPress(XEvent *event)
48 | {
49 | int modifiers = 0; // modifiers sent to AntTweakBar
50 | int k = 0; // key sent to AntTweakBar
51 | KeySym keysym;
52 | char buffer[buff_sz];
53 |
54 | int num_char = XLookupString((XKeyEvent *)event, buffer, buff_sz, &keysym, 0);
55 |
56 | if (event->xkey.state & ControlMask)
57 | modifiers |= TW_KMOD_CTRL;
58 | if (event->xkey.state & ShiftMask)
59 | modifiers |= TW_KMOD_SHIFT;
60 | if (event->xkey.state & Mod1Mask)
61 | modifiers |= TW_KMOD_ALT;
62 |
63 | switch (keysym)
64 | {
65 | case XK_Control_L:
66 | case XK_Control_R: s_KMod |= TW_KMOD_CTRL; break;
67 |
68 | case XK_Shift_L:
69 | case XK_Shift_R: s_KMod |= TW_KMOD_SHIFT; break;
70 |
71 | case XK_Alt_L:
72 | case XK_Alt_R: s_KMod |= TW_KMOD_ALT; break;
73 |
74 | case XK_Escape: k = TW_KEY_ESCAPE; break;
75 | case XK_Help: k = TW_KEY_F1; break;
76 | case XK_F1: k = TW_KEY_F1; break;
77 | case XK_F2: k = TW_KEY_F2; break;
78 | case XK_F3: k = TW_KEY_F3; break;
79 | case XK_F4: k = TW_KEY_F4; break;
80 | case XK_F5: k = TW_KEY_F5; break;
81 | case XK_F6: k = TW_KEY_F6; break;
82 | case XK_F7: k = TW_KEY_F7; break;
83 | case XK_F8: k = TW_KEY_F8; break;
84 | case XK_F9: k = TW_KEY_F9; break;
85 | case XK_F10: k = TW_KEY_F10; break;
86 | case XK_F11: k = TW_KEY_F11; break;
87 | case XK_F12: k = TW_KEY_F12; break;
88 | case XK_Up: k = TW_KEY_UP; break;
89 | case XK_Down: k = TW_KEY_DOWN; break;
90 | case XK_Right: k = TW_KEY_RIGHT; break;
91 | case XK_Left: k = TW_KEY_LEFT; break;
92 | case XK_Return: k = TW_KEY_RETURN; break;
93 | case XK_Insert: k = TW_KEY_INSERT; break;
94 | case XK_Delete: k = TW_KEY_DELETE; break;
95 | case XK_BackSpace: k = TW_KEY_BACKSPACE; break;
96 | case XK_Home: k = TW_KEY_HOME; break;
97 | case XK_Tab: k = TW_KEY_TAB; break;
98 | case XK_End: k = TW_KEY_END; break;
99 |
100 | #ifdef XK_Enter
101 | case XK_Enter: k = TW_KEY_RETURN; break;
102 | #endif
103 |
104 | #ifdef XK_KP_Home
105 | case XK_KP_Home: k = TW_KEY_HOME; break;
106 | case XK_KP_End: k = TW_KEY_END; break;
107 | case XK_KP_Delete: k = TW_KEY_DELETE; break;
108 | #endif
109 |
110 | #ifdef XK_KP_Up
111 | case XK_KP_Up: k = TW_KEY_UP; break;
112 | case XK_KP_Down: k = TW_KEY_DOWN; break;
113 | case XK_KP_Right: k = TW_KEY_RIGHT; break;
114 | case XK_KP_Left: k = TW_KEY_LEFT; break;
115 | #endif
116 |
117 | #ifdef XK_KP_Page_Up
118 | case XK_KP_Page_Up: k = TW_KEY_PAGE_UP; break;
119 | case XK_KP_Page_Down: k = TW_KEY_PAGE_DOWN; break;
120 | #endif
121 |
122 | #ifdef XK_KP_Tab
123 | case XK_KP_Tab: k = TW_KEY_TAB; break;
124 | #endif
125 |
126 | default:
127 | if (0)
128 | {
129 | // should we do that, or rely on the buffer (see code below)
130 | if (keysym > 12 && keysym < 127)
131 | k = keysym;
132 | }
133 | break;
134 | }
135 |
136 | if (k == 0 && num_char)
137 | {
138 | int i, handled = 0;
139 | for (i=0; i 0) ? TwKeyPressed(k, modifiers) : 0;
148 | }
149 |
150 | // ----------------------------------------------------------------------
151 | // ----------------------------------------------------------------------
152 | static int _XButtonEvent(XEvent *event)
153 | {
154 | TwMouseAction action = (event->type == ButtonPress) ? TW_MOUSE_PRESSED : TW_MOUSE_RELEASED;
155 | XButtonEvent *xbe = (XButtonEvent *)event;
156 | return TwMouseButton(action, xbe->button);
157 | }
158 |
159 | // ----------------------------------------------------------------------
160 | // ----------------------------------------------------------------------
161 | static int _XConfigureEvent(XEvent *event)
162 | {
163 | XConfigureEvent *xce = (XConfigureEvent *)event;
164 | TwWindowSize(xce->width, xce->height);
165 | return 0;
166 | }
167 |
168 | // ----------------------------------------------------------------------
169 | // ----------------------------------------------------------------------
170 | static int _XMotionEvent(XEvent *event)
171 | {
172 | XMotionEvent *xme = (XMotionEvent *)event;
173 | return TwMouseMotion(xme->x, xme->y);
174 | }
175 |
176 | // ----------------------------------------------------------------------
177 | // ----------------------------------------------------------------------
178 | TW_API int TW_CDECL_CALL TwEventX11(void *xevent)
179 | {
180 | XEvent *event = (XEvent *)xevent;
181 |
182 | switch (event->type)
183 | {
184 | case KeyPress:
185 | return _XKeyPress(xevent);
186 |
187 | case KeyRelease:
188 | return 0; // _XKeyRelease(xevent);
189 |
190 | case ButtonPress:
191 | case ButtonRelease:
192 | return _XButtonEvent(xevent);
193 |
194 | case MotionNotify:
195 | return _XMotionEvent(xevent);
196 |
197 | case ConfigureNotify:
198 | return _XConfigureEvent(xevent);
199 |
200 | default:
201 | break;
202 | }
203 | return 0;
204 | }
205 |
206 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwFonts.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jdupuy/ssgi/1e44048af63779d49bd250b73386841edbfc98ea/src/anttweakbar/TwFonts.h
--------------------------------------------------------------------------------
/src/anttweakbar/TwGraph.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwGraph.h
4 | // @brief ITwGraph pure interface
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // note: Private header
10 | //
11 | // ---------------------------------------------------------------------------
12 |
13 |
14 | #if !defined ANT_TW_GRAPH_INCLUDED
15 | #define ANT_TW_GRAPH_INCLUDED
16 |
17 | #include "TwColors.h"
18 | #include "TwFonts.h"
19 |
20 |
21 | // ---------------------------------------------------------------------------
22 |
23 | #ifdef DrawText // DirectX redefines 'DrawText' !!
24 | # undef DrawText
25 | #endif // DrawText
26 |
27 | class ITwGraph
28 | {
29 | public:
30 | virtual int Init() = 0;
31 | virtual int Shut() = 0;
32 | virtual void BeginDraw(int _WndWidth, int _WndHeight) = 0;
33 | virtual void EndDraw() = 0;
34 | virtual bool IsDrawing() = 0;
35 | virtual void Restore() = 0;
36 |
37 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color0, color32 _Color1, bool _AntiAliased=false) = 0;
38 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color, bool _AntiAliased=false) = 0;
39 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color00, color32 _Color10, color32 _Color01, color32 _Color11) = 0;
40 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color) = 0;
41 | enum Cull { CULL_NONE, CULL_CW, CULL_CCW };
42 | virtual void DrawTriangles(int _NumTriangles, int *_Vertices, color32 *_Colors, Cull _CullMode) = 0;
43 |
44 | virtual void * NewTextObj() = 0;
45 | virtual void DeleteTextObj(void *_TextObj) = 0;
46 | virtual void BuildText(void *_TextObj, const std::string *_TextLines, color32 *_LineColors, color32 *_LineBgColors, int _NbLines, const CTexFont *_Font, int _Sep, int _BgWidth) = 0;
47 | virtual void DrawText(void *_TextObj, int _X, int _Y, color32 _Color, color32 _BgColor) = 0;
48 |
49 | virtual void ChangeViewport(int _X0, int _Y0, int _Width, int _Height, int _OffsetX, int _OffsetY) = 0;
50 | virtual void RestoreViewport() = 0;
51 | virtual void SetScissor(int _X0, int _Y0, int _Width, int _Height) = 0;
52 |
53 | virtual ~ITwGraph() {} // required by gcc
54 | };
55 |
56 | // ---------------------------------------------------------------------------
57 |
58 | #endif // ANT_TW_GRAPH_INCLUDED
59 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwMgr.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jdupuy/ssgi/1e44048af63779d49bd250b73386841edbfc98ea/src/anttweakbar/TwMgr.cpp
--------------------------------------------------------------------------------
/src/anttweakbar/TwOpenGL.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwOpenGL.h
4 | // @brief OpenGL graph functions
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // notes: Private header
10 | // TAB=4
11 | //
12 | // ---------------------------------------------------------------------------
13 |
14 |
15 | #if !defined ANT_TW_OPENGL_INCLUDED
16 | #define ANT_TW_OPENGL_INCLUDED
17 |
18 | #include "TwGraph.h"
19 |
20 | // ---------------------------------------------------------------------------
21 |
22 | class CTwGraphOpenGL : public ITwGraph
23 | {
24 | public:
25 | virtual int Init();
26 | virtual int Shut();
27 | virtual void BeginDraw(int _WndWidth, int _WndHeight);
28 | virtual void EndDraw();
29 | virtual bool IsDrawing();
30 | virtual void Restore();
31 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color0, color32 _Color1, bool _AntiAliased=false);
32 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color, bool _AntiAliased=false) { DrawLine(_X0, _Y0, _X1, _Y1, _Color, _Color, _AntiAliased); }
33 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color00, color32 _Color10, color32 _Color01, color32 _Color11);
34 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color) { DrawRect(_X0, _Y0, _X1, _Y1, _Color, _Color, _Color, _Color); }
35 | virtual void DrawTriangles(int _NumTriangles, int *_Vertices, color32 *_Colors, Cull _CullMode);
36 |
37 | virtual void * NewTextObj();
38 | virtual void DeleteTextObj(void *_TextObj);
39 | virtual void BuildText(void *_TextObj, const std::string *_TextLines, color32 *_LineColors, color32 *_LineBgColors, int _NbLines, const CTexFont *_Font, int _Sep, int _BgWidth);
40 | virtual void DrawText(void *_TextObj, int _X, int _Y, color32 _Color, color32 _BgColor);
41 |
42 | virtual void ChangeViewport(int _X0, int _Y0, int _Width, int _Height, int _OffsetX, int _OffsetY);
43 | virtual void RestoreViewport();
44 | virtual void SetScissor(int _X0, int _Y0, int _Width, int _Height);
45 |
46 | protected:
47 | bool m_Drawing;
48 | GLuint m_FontTexID;
49 | const CTexFont * m_FontTex;
50 | GLfloat m_PrevLineWidth;
51 | GLint m_PrevTexEnv;
52 | GLint m_PrevPolygonMode[2];
53 | GLint m_MaxClipPlanes;
54 | GLint m_PrevTexture;
55 | GLint m_PrevArrayBufferARB;
56 | GLint m_PrevElementArrayBufferARB;
57 | GLboolean m_PrevVertexProgramARB;
58 | GLboolean m_PrevFragmentProgramARB;
59 | GLuint m_PrevProgramObjectARB;
60 | GLboolean m_PrevTexture3D;
61 | enum EMaxTextures { MAX_TEXTURES = 128 };
62 | GLboolean m_PrevActiveTexture1D[MAX_TEXTURES];
63 | GLboolean m_PrevActiveTexture2D[MAX_TEXTURES];
64 | GLboolean m_PrevActiveTexture3D[MAX_TEXTURES];
65 | GLboolean m_PrevClientTexCoordArray[MAX_TEXTURES];
66 | GLint m_PrevActiveTextureARB;
67 | GLint m_PrevClientActiveTextureARB;
68 | bool m_SupportTexRect;
69 | GLboolean m_PrevTexRectARB;
70 | GLint m_PrevBlendEquation;
71 | GLint m_PrevBlendEquationRGB;
72 | GLint m_PrevBlendEquationAlpha;
73 | GLint m_PrevBlendSrcRGB;
74 | GLint m_PrevBlendDstRGB;
75 | GLint m_PrevBlendSrcAlpha;
76 | GLint m_PrevBlendDstAlpha;
77 | GLuint m_PrevVertexArray;
78 | GLint m_ViewportInit[4];
79 | GLfloat m_ProjMatrixInit[16];
80 | enum EMaxVtxAttribs { MAX_VERTEX_ATTRIBS = 128 };
81 | GLint m_PrevEnabledVertexAttrib[MAX_VERTEX_ATTRIBS];
82 | int m_WndWidth;
83 | int m_WndHeight;
84 |
85 | struct Vec2 { GLfloat x, y; Vec2(){} Vec2(GLfloat _X, GLfloat _Y):x(_X),y(_Y){} Vec2(int _X, int _Y):x(GLfloat(_X)),y(GLfloat(_Y)){} };
86 | struct CTextObj
87 | {
88 | std::vector m_TextVerts;
89 | std::vector m_TextUVs;
90 | std::vector m_BgVerts;
91 | std::vectorm_Colors;
92 | std::vectorm_BgColors;
93 | };
94 | };
95 |
96 | // ---------------------------------------------------------------------------
97 |
98 |
99 | #endif // !defined ANT_TW_OPENGL_INCLUDED
100 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwOpenGLCore.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwOpenGLCore.h
4 | // @brief OpenGL Core graph functions
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // note: Private header
10 | //
11 | // ---------------------------------------------------------------------------
12 |
13 |
14 | #if !defined ANT_TW_OPENGL_CORE_INCLUDED
15 | #define ANT_TW_OPENGL_CORE_INCLUDED
16 |
17 | #include "TwGraph.h"
18 |
19 | // ---------------------------------------------------------------------------
20 |
21 | class CTwGraphOpenGLCore : public ITwGraph
22 | {
23 | public:
24 | virtual int Init();
25 | virtual int Shut();
26 | virtual void BeginDraw(int _WndWidth, int _WndHeight);
27 | virtual void EndDraw();
28 | virtual bool IsDrawing();
29 | virtual void Restore();
30 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color0, color32 _Color1, bool _AntiAliased=false);
31 | virtual void DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color, bool _AntiAliased=false) { DrawLine(_X0, _Y0, _X1, _Y1, _Color, _Color, _AntiAliased); }
32 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color00, color32 _Color10, color32 _Color01, color32 _Color11);
33 | virtual void DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color) { DrawRect(_X0, _Y0, _X1, _Y1, _Color, _Color, _Color, _Color); }
34 | virtual void DrawTriangles(int _NumTriangles, int *_Vertices, color32 *_Colors, Cull _CullMode);
35 |
36 | virtual void * NewTextObj();
37 | virtual void DeleteTextObj(void *_TextObj);
38 | virtual void BuildText(void *_TextObj, const std::string *_TextLines, color32 *_LineColors, color32 *_LineBgColors, int _NbLines, const CTexFont *_Font, int _Sep, int _BgWidth);
39 | virtual void DrawText(void *_TextObj, int _X, int _Y, color32 _Color, color32 _BgColor);
40 |
41 | virtual void ChangeViewport(int _X0, int _Y0, int _Width, int _Height, int _OffsetX, int _OffsetY);
42 | virtual void RestoreViewport();
43 | virtual void SetScissor(int _X0, int _Y0, int _Width, int _Height);
44 |
45 | protected:
46 | bool m_Drawing;
47 | GLuint m_FontTexID;
48 | const CTexFont * m_FontTex;
49 |
50 | GLfloat m_PrevLineWidth;
51 | GLint m_PrevActiveTexture;
52 | GLint m_PrevTexture;
53 | GLint m_PrevVArray;
54 | GLboolean m_PrevLineSmooth;
55 | GLboolean m_PrevCullFace;
56 | GLboolean m_PrevDepthTest;
57 | GLboolean m_PrevBlend;
58 | GLint m_PrevSrcBlend;
59 | GLint m_PrevDstBlend;
60 | GLboolean m_PrevScissorTest;
61 | GLint m_PrevScissorBox[4];
62 | GLint m_PrevViewport[4];
63 | GLuint m_PrevProgramObject;
64 |
65 | GLuint m_LineRectVS;
66 | GLuint m_LineRectFS;
67 | GLuint m_LineRectProgram;
68 | GLuint m_LineRectVArray;
69 | GLuint m_LineRectVertices;
70 | GLuint m_LineRectColors;
71 | GLuint m_TriVS;
72 | GLuint m_TriFS;
73 | GLuint m_TriProgram;
74 | GLuint m_TriUniVS;
75 | GLuint m_TriUniFS;
76 | GLuint m_TriUniProgram;
77 | GLuint m_TriTexVS;
78 | GLuint m_TriTexFS;
79 | GLuint m_TriTexProgram;
80 | GLuint m_TriTexUniVS;
81 | GLuint m_TriTexUniFS;
82 | GLuint m_TriTexUniProgram;
83 | GLuint m_TriVArray;
84 | GLuint m_TriVertices;
85 | GLuint m_TriUVs;
86 | GLuint m_TriColors;
87 | GLint m_TriLocationOffset;
88 | GLint m_TriLocationWndSize;
89 | GLint m_TriUniLocationOffset;
90 | GLint m_TriUniLocationWndSize;
91 | GLint m_TriUniLocationColor;
92 | GLint m_TriTexLocationOffset;
93 | GLint m_TriTexLocationWndSize;
94 | GLint m_TriTexLocationTexture;
95 | GLint m_TriTexUniLocationOffset;
96 | GLint m_TriTexUniLocationWndSize;
97 | GLint m_TriTexUniLocationColor;
98 | GLint m_TriTexUniLocationTexture;
99 | size_t m_TriBufferSize;
100 |
101 | int m_WndWidth;
102 | int m_WndHeight;
103 | int m_OffsetX;
104 | int m_OffsetY;
105 |
106 | struct Vec2 { GLfloat x, y; Vec2(){} Vec2(GLfloat _X, GLfloat _Y):x(_X),y(_Y){} Vec2(int _X, int _Y):x(GLfloat(_X)),y(GLfloat(_Y)){} };
107 | struct CTextObj
108 | {
109 | std::vector m_TextVerts;
110 | std::vector m_TextUVs;
111 | std::vector m_BgVerts;
112 | std::vectorm_Colors;
113 | std::vectorm_BgColors;
114 | };
115 | void ResizeTriBuffers(size_t _NewSize);
116 | };
117 |
118 | // ---------------------------------------------------------------------------
119 |
120 |
121 | #endif // !defined ANT_TW_OPENGL_CORE_INCLUDED
122 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwPrecomp.cpp:
--------------------------------------------------------------------------------
1 | #include "TwPrecomp.h"
2 |
--------------------------------------------------------------------------------
/src/anttweakbar/TwPrecomp.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------
2 | //
3 | // @file TwPrecomp.h
4 | // @brief Precompiled header
5 | // @author Philippe Decaudin - http://www.antisphere.com
6 | // @license This file is part of the AntTweakBar library.
7 | // For conditions of distribution and use, see License.txt
8 | //
9 | // note: Private header
10 | //
11 | // ---------------------------------------------------------------------------
12 |
13 |
14 | #if !defined ANT_TW_PRECOMP_INCLUDED
15 | #define ANT_TW_PRECOMP_INCLUDED
16 |
17 |
18 | #if defined _MSC_VER
19 | # pragma warning(disable: 4514) // unreferenced inline function has been removed
20 | # pragma warning(disable: 4710) // function not inlined
21 | # pragma warning(disable: 4786) // template name truncated
22 | # pragma warning(disable: 4530) // exceptions not handled
23 | # define _CRT_SECURE_NO_DEPRECATE // visual 8 secure crt warning
24 | #endif
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #if defined(_MSC_VER) && _MSC_VER<=1200
35 | # pragma warning(push, 3)
36 | #endif
37 | #include
38 | #include
39 | #include
40 | #include