26#include <libFreeWRL.h>
29#include "../vrml_parser/Structs.h"
30#include "main/headers.h"
31#include "vrml_parser/Structs.h"
32#include "scenegraph/Viewer.h"
33#include "scenegraph/Component_Shape.h"
34#include "opengl/Frustum.h"
35#include "opengl/OpenGL_Utils.h"
36#include "opengl/Textures.h"
37#include "opengl/LoadTextures.h"
38#include "main/MainLoop.h"
39#include "scenegraph/RenderFuncs.h"
41#include "../scenegraph/LinearAlgebra.h"
49 GLubyte pixel_data[32 * 32 * 4 + 1];
52 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
53 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
54 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
55 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
56 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
57 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
58 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
59 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
60 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
61 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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0\0\0o\0\0\0P\0\0\0""0\0\0\0\20\0\0\0\0\0\0\0\0\0\0"
76 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
77 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
78 "\0\0\0\0\0\40\0\0\0p***\302WWW\350qqq\372\177\177\177\377\177\177\177\377"
79 "qqq\372WWW\350***\302\0\0\0p\0\0\0\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
80 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
81 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""0000\251ddd\363\213\213"
82 "\213\377\216\216\216\377\206\206\206\377\200\200\200\377\200\200\200\377"
83 "\206\206\206\377\216\216\216\377\213\213\213\377ddd\363000\251\0\0\0""0\0"
84 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
85 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""0,"
86 ",,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227\0\0\0\200\0\0\0"
87 "\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,,\266\0\0\0""0\0"
88 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
89 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40""000\251yyy\373\213"
90 "\213\213\377GGG\347\33\33\33\226\0\0\0@\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\20"
91 "\0\0\0@\33\33\33\226GGG\347\213\213\213\377yyy\373000\251\0\0\0\40\0\0\0"
92 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
93 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0pddd\363\247\247\247\377GGG\347"
94 "\0\0\0\177\0\0\0\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
95 "\40\0\0\0\177GGG\347\247\247\247\377ddd\363\0\0\0p\0\0\0\20\0\0\0\0\0\0\0"
96 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
97 "\0\0\0\0\0\0\0\0""0***\302\213\213\213\377ttt\366\33\33\33\226\0\0\0\40\0"
98 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40\33"
99 "\33\33\226ttt\366\213\213\213\377***\302\0\0\0""0\0\0\0\0\0\0\0\0\0\0\0\0"
100 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
101 "\0\0\0PWWW\350\216\216\216\377<<<\313\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\0\0"
102 "\0@\0\0\0o\0\0\0o\0\0\0@\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@<<<\313\216\216\216"
103 "\377WWW\350\0\0\0P\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
104 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0oqqq\372\206\206\206\377"
105 "\33\33\33\227\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@,,,\271ccc\365ccc\365,,,\271"
106 "\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\33\33\33\227\206\206\206\377qqq\372\0\0"
107 "\0o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
108 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\177\177\177\177\377\200\200\200\377\0\0"
109 "\0\200\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0occc\365\337\337\337\377\337\337\337"
110 "\377ccc\365\0\0\0o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200\200\200\200\377\177"
111 "\177\177\377\0\0\0\177\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
112 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\177\177\177\177\377"
113 "\200\200\200\377\0\0\0\200\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0occc\365\337\337"
114 "\337\377\337\337\337\377ccc\365\0\0\0o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\200"
115 "\200\200\200\377\177\177\177\377\0\0\0\177\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
116 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
117 "oqqq\372\206\206\206\377\33\33\33\227\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@,,,"
118 "\271ccc\365ccc\365,,,\271\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\33\33\33\227\206"
119 "\206\206\377qqq\372\0\0\0o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
120 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0PWWW\350\216\216"
121 "\216\377<<<\313\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0@\0\0\0o\0\0\0o\0\0"
122 "\0@\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@<<<\313\216\216\216\377WWW\350\0\0\0P"
123 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
124 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0""0***\302\213\213\213\377ttt\366\33\33\33"
125 "\226\0\0\0\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
126 "\0\0\0\0\0\40\33\33\33\226ttt\366\213\213\213\377***\302\0\0\0""0\0\0\0\0"
127 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
128 "\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0pddd\363\247\247\247\377GGG\347\0\0\0\177"
129 "\0\0\0\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40\0\0\0"
130 "\177GGG\347\247\247\247\377ddd\363\0\0\0p\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0"
131 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
132 "\0\0\0\0\0\0\0\0\40""000\251yyy\373\213\213\213\377GGG\347\33\33\33\226\0"
133 "\0\0@\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0@\33\33\33\226GGG\347\213\213"
134 "\213\377yyy\373000\251\0\0\0\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
135 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
136 "\0\0\0\0\0\0""0,,,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227"
137 "\0\0\0\200\0\0\0\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,"
138 ",\266\0\0\0""0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
139 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
140 "\0\0\0\0\0\0""0000\251ddd\363\213\213\213\377\216\216\216\377\206\206\206"
141 "\377\200\200\200\377\200\200\200\377\206\206\206\377\216\216\216\377\213"
142 "\213\213\377ddd\363000\251\0\0\0""0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
143 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
144 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\40\0\0\0p***\302WWW\350"
145 "qqq\372\177\177\177\377\177\177\177\377qqq\372WWW\350***\302\0\0\0p\0\0\0"
146 "\40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
147 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
148 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\0\0""0\0\0\0P\0\0\0o\0\0\0\177\0\0"
149 "\0\177\0\0\0o\0\0\0P\0\0\0""0\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
150 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
151 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
152 "\0\0\0\0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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
166 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
167 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
168 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
169 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
170 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
171 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
178GLfloat cursorVert[] = {
185GLfloat cursorTex[] = {
197void *CursorDraw_constructor(){
202void CursorDraw_init(
struct tCursorDraw *t){
205 t->prv = CursorDraw_constructor();
207 ppCursorDraw p = (ppCursorDraw)t->prv;
213typedef struct {
int x;
int y;}
XY;
214XY mouse2screen2(
int x,
int y)
222typedef struct {GLfloat x; GLfloat y;}
FXY;
223FXY screen2normalized( GLfloat x, GLfloat y )
226 xy.x = (x / gglobal()->display.screenWidth)*2.0f -1.0f;
227 xy.y = (y / gglobal()->display.screenHeight)*2.0f -1.0f;
230static GLfloat cursIdentity[] = {
231 1.0f, 0.0f, 0.0f, 0.0f,
232 0.0f, 1.0f, 0.0f, 0.0f,
233 0.0f, 0.0f, 1.0f, 0.0f,
234 0.0f, 0.0f, 0.0f, 1.0f
240static struct cline cur_fiducials [] = {
241 {3,{-.02f,.0f, 0.0f,-.02f, .02f,.0f}},
242 {0,{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}},
244static struct cline cur_down [] = {
245 {3,{-.02f,.02f, .0f,.0f, .02f,.02f}},
246 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
248static struct cline cur_up [] = {
249 {3,{-.02f,-.02f, .0f,.0f, .02f,-.02f}},
250 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
252static struct cline cur_hover [] = {
253 {2,{-.02f,.0f, .02f,.0f, .0f,.0f}},
254 {2,{.0f,-.02f, .0f,.02f, .0f,.0f}},
255 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
257static struct cline cur_over [] = {
258 {2,{.0f,.0f, .0f,.005f, .0f,.0f}},
259 {2,{.0f,.008f, .0f,.02f, .0f,.0f}},
260 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
262static struct cline cur_circle [] = {
263 {3,{.1f,.00f, .0866f,.05f, .05f,.0866f}},
264 {3,{.05f,.0866f, .00f, .1f, -.05f, .0866f}},
265 {3,{-.05f, .0866f, -.0866f, .05f, -.1f, .00f}},
266 {3,{ -.1f, .00f, -.0866f, -.05f, -.05f, -.0866f}},
267 {3,{ -.05f, -.0866f, .00f, -.1f, .05f, -.0866f}},
268 {3,{ .05f, -.0866f, .0866f, -.05f, .1f, .00f }},
269 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
280static struct cline *cursor_array [] = {
290s_shader_capabilities_t *getMyShader(
unsigned int rq_cap0);
292void fiducialDrawB(
int cursortype,
int x,
int y)
300 struct cline *cur, *line;
301 s_shader_capabilities_t *scap;
302 ttglobal tg = gglobal();
307 xy = mouse2screen2(x,y);
308 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
309 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
310 aspect = (float)tg->display.screenHeight/(
float)tg->display.screenWidth;
313 FW_GL_DEPTHMASK(GL_FALSE);
314 glDisable(GL_DEPTH_TEST);
315 scap = getMyShader(NO_APPEARANCE_SHADER);
316 enableGlobalShader(scap);
317 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
318 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
323 positionLoc = scap->Vertices;
325 cur = cursor_array[cursortype];
329 for(i=0;i<line->n;i++){
330 p[i][0] = line->p[i*2]*aspect + fxy.x;
331 p[i][1] = line->p[i*2 + 1] + fxy.y;
333 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
335 glDrawArrays(GL_LINE_STRIP,0,line->n);
340 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
341 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
344 glEnable(GL_DEPTH_TEST);
345 FW_GL_DEPTHMASK(GL_TRUE);
346 restoreGlobalShader();
348void fiducialDraw(
int ID,
int x,
int y,
float angleDeg)
356 s_shader_capabilities_t *scap;
357 ttglobal tg = gglobal();
359 xy = mouse2screen2(x,y);
360 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
361 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
370 if(angleDeg != 0.0f){
371 GLfloat cosine, sine, angleRad, xx,yy;
372 angleRad = angleDeg * (float)PI / 180.0f;
373 cosine = cosf(angleRad);
374 sine = sinf(angleRad);
376 xx = cosine*p[i][0] + sine*p[i][1];
377 yy = -sine*p[i][0] + cosine*p[i][1];
391 FW_GL_DEPTHMASK(GL_FALSE);
392 glDisable(GL_DEPTH_TEST);
393 scap = getMyShader(NO_APPEARANCE_SHADER);
394 enableGlobalShader(scap);
395 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
396 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
401 positionLoc = scap->Vertices;
402 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
404 glDrawArrays(GL_LINE_STRIP,0,3);
406 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
407 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
410 glEnable(GL_DEPTH_TEST);
411 FW_GL_DEPTHMASK(GL_TRUE);
412 restoreGlobalShader();
420void statusbarHud_DrawCursor(GLint textureID,
int x,
int y);
422unsigned int getCircleCursorTextureID(){
425 ttglobal tg = gglobal();
426 p = (ppCursorDraw)tg->CursorDraw.prv;
429 glGenTextures(1, &p->textureID);
430 glBindTexture(GL_TEXTURE_2D, p->textureID);
431 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
432 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
433 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
438void cursorDraw(
int ID,
int x,
int y,
float angle)
444 GLint positionLoc, texCoordLoc, textureLoc;
446 GLint textureMatrix0;
448 GLfloat cursorVert2[18];
451 s_shader_capabilities_t *scap;
452 ttglobal tg = gglobal();
453 p = (ppCursorDraw)tg->CursorDraw.prv;
459 glGenTextures(1, &p->textureID);
460 glBindTexture(GL_TEXTURE_2D, p->textureID);
461 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
462 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
463 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
468 statusbarHud_DrawCursor(p->textureID,x,y);
471#ifndef NEWWAY_COPIED_FROM_STATUSBARHUD_CURSORDRAW
473 FW_GL_DEPTHMASK(GL_FALSE);
474 glDisable(GL_DEPTH_TEST);
477 scap = getMyShader(ONE_TEX_APPEARANCE_SHADER);
478 enableGlobalShader(scap);
481 xy = mouse2screen2(x,y);
482 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
483 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
488 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
489 cursorVert2[i*3 +0] += fxy.x;
490 cursorVert2[i*3 +1] += fxy.y;
492 positionLoc = scap->Vertices;
493 glVertexAttribPointer (positionLoc, 3, GL_FLOAT,
494 GL_FALSE, 0, cursorVert2 );
497 texCoordLoc = scap->TexCoords[0];
498 glVertexAttribPointer ( texCoordLoc, 2, GL_FLOAT,
499 GL_FALSE, 0, cursorTex );
501 glEnableVertexAttribArray (positionLoc );
502 glEnableVertexAttribArray ( texCoordLoc);
505 glActiveTexture ( GL_TEXTURE0 );
506 glBindTexture ( GL_TEXTURE_2D, p->textureID );
510 textureLoc = scap->TextureUnit[0];
513 textureMatrix0 = scap->TextureMatrix[0];
514 glUniformMatrix4fv(textureMatrix0, 1, GL_FALSE, cursIdentity);
516 glUniform1i ( textureLoc, 0 );
521 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
523 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
525 glDrawArrays(GL_TRIANGLES,0,6);
527 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
528 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
531 glEnable(GL_DEPTH_TEST);
532 FW_GL_DEPTHMASK(GL_TRUE);
533 restoreGlobalShader();
539 FW_GL_DEPTHMASK(GL_FALSE);
541 #ifndef GL_ES_VERSION_2_0
542 FW_GL_SHADEMODEL(GL_FLAT);
554 xy = mouse2screen2(x,y);
557 FW_GL_MATRIX_MODE(GL_PROJECTION);
558 FW_GL_LOAD_IDENTITY();
559 FW_GL_MATRIX_MODE(GL_MODELVIEW);
560 FW_GL_LOAD_IDENTITY();
562 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
564 FW_GL_TRANSLATE_F((
float)fxy.x,(
float)fxy.y,0.0f);
567 enableGlobalShader(getMyShader(ONE_TEX_APPEARANCE_SHADER));
568 shader = getAppearanceProperties()->currentShaderProperties->myShaderProgram;
570 glActiveTexture ( GL_TEXTURE0 );
571 glBindTexture ( GL_TEXTURE_2D, p->textureID );
575 loc = glGetAttribLocation ( shader,
"fw_Texture0" );
577 loc = glGetAttribLocation ( shader,
"fw_Vertex" );
578 xy = mouse2screen2(x,y);
581 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
582 cursorVert2[i*3 +0] += fxy.x;
583 cursorVert2[i*3 +1] += fxy.y;
586 glVertexAttribPointer ( loc, 3, GL_FLOAT, GL_FALSE, 0, cursorVert2 );
588 loc = glGetAttribLocation ( shader,
"fw_TexCoords" );
589 glEnableVertexAttribArray ( loc );
590 glVertexAttribPointer ( loc, 2, GL_FLOAT, GL_FALSE, 0, cursorTex );
592 glEnableVertexAttribArray ( loc );
599 glDisable(GL_DEPTH_TEST);
607 #ifndef GL_ES_VERSION_2_0
608 FW_GL_WINDOWPOS2I(xy.x,xy.y);
609 FW_GL_DRAWPIXELS(circleCursor.width,circleCursor.height,GL_BGRA,GL_UNSIGNED_BYTE,circleCursor.pixel_data);
613 loc = glGetAttribLocation ( shader,
"fw_ModelViewMatrix" );
614 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
615 loc = glGetAttribLocation ( shader,
"fw_ProjectionMatrix" );
616 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
618 glDrawArrays(GL_TRIANGLES,0,6);
621 glEnable(GL_DEPTH_TEST);
623 #ifndef GL_ES_VERSION_2_0
624 FW_GL_SHADEMODEL(GL_SMOOTH);
626 FW_GL_DEPTHMASK(GL_TRUE);
632void vecprinti3fb(
char *name,
int i,
float *p,
char *eol){
633printf(
"%s[%d] %f %f %f %s",name,i,p[0],p[1],p[2],eol);
635int extent6f_isSet(
float *extent6);
636static float testextent [] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
637void reallyDrawOnce();
639void extent6f_draw(
float *extent)
646 GLuint lineindices[3];
647 struct cline *cur, *line;
648 s_shader_capabilities_t *scap;
649 ttglobal tg = gglobal();
650 if(!extent6f_isSet(extent))
return;
652 scap = getMyShader(NO_APPEARANCE_SHADER);
653 enableGlobalShader(scap);
667 p[n][1] = extent[j+2];
668 p[n][2] = extent[k+4];
678 p[n][1] = extent[i+2];
679 p[n][2] = extent[k+4];
688 p[n][1] = extent[j+2];
689 p[n][2] = extent[i+4];
696 positionLoc = scap->Vertices;
700 sendArraysToGPU (GL_LINES, 0, n);
701 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[0]);
705 sendElementsToGPU(GL_LINES,2,(
int *)lineindices);
712 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[i]);
722 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
723 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
725 restoreGlobalShader();
727void draw_bbox(
float *center,
float *size){
729 bbox2extent6f(center,size,extent);
730 extent6f_draw(extent);
732void draw_viewpoint(
int type,
float *fov,
float aspect)
738 struct cline *cur, *line;
739 s_shader_capabilities_t *scap;
740 ttglobal tg = gglobal();
742 scap = getMyShader(NO_APPEARANCE_SHADER);
743 enableGlobalShader(scap);
745 if(type == NODE_Viewpoint || type == NODE_GeoViewpoint){
752 vecset3f(p[0],0.0f,0.0f,0.0f);
753 vecset3f(p[1],w,h,-d);
754 vecset3f(p[2],0.0f,0.0f,0.0f);
755 vecset3f(p[3],-w,h,-d);
756 vecset3f(p[4],0.0f,0.0f,0.0f);
757 vecset3f(p[5],-w,-h,-d);
758 vecset3f(p[6],0.0f,0.0f,0.0f);
759 vecset3f(p[7],w,-h,-d);
761 vecset3f(p[8],-w,-h,-d);
762 vecset3f(p[9],w,-h,-d);
763 vecset3f(p[10],w,-h,-d);
764 vecset3f(p[11],w,h,-d);
765 vecset3f(p[12],w,h,-d);
766 vecset3f(p[13],-w,h,-d);
767 vecset3f(p[14],-w,h,-d);
768 vecset3f(p[15],-w,-h,-d);
773 if(type == NODE_OrthoViewpoint){
775 float w1,w2,h1,h2,d = 1.0f;
782 vecset3f(p[0],w1,h1,d);
783 vecset3f(p[1],w2,h1,d);
784 vecset3f(p[2],w2,h1,d);
785 vecset3f(p[3],w2,h2,d);
786 vecset3f(p[4],w2,h2,d);
787 vecset3f(p[5],w1,h2,d);
788 vecset3f(p[6],w1,h2,d);
789 vecset3f(p[7],w1,h1,d);
791 vecset3f(p[8 ],w1,h1,-d);
792 vecset3f(p[9 ],w2,h1,-d);
793 vecset3f(p[10],w2,h1,-d);
794 vecset3f(p[11],w2,h2,-d);
795 vecset3f(p[12],w2,h2,-d);
796 vecset3f(p[13],w1,h2,-d);
797 vecset3f(p[14],w1,h2,-d);
798 vecset3f(p[15],w1,h1,-d);
805 positionLoc = scap->Vertices;
807 sendArraysToGPU (GL_LINES, 0, n);
808 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[0]);
813 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
814 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
816 restoreGlobalShader();
819void draw_frustum(
float *corners)
825 struct cline *cur, *line;
826 s_shader_capabilities_t *scap;
827 ttglobal tg = gglobal();
831 for(
int i=0;i<4;i++){
833 int m = j*4 + (i+1) % 4;
834 veccopy3f(p[n],&corners[k*3]);
835 veccopy3f(p[n+1],&corners[m*3]);
838 for(
int i=0;i<4;i++){
839 veccopy3f(p[n],&corners[i*3]);
840 veccopy3f(p[n+1],&corners[(i+4)*3]);
843 scap = getMyShader(NO_APPEARANCE_SHADER);
844 enableGlobalShader(scap);
847 positionLoc = scap->Vertices;
849 sendArraysToGPU (GL_LINES, 0, n);
850 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[0]);
855 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
856 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
858 restoreGlobalShader();
861void line_draw(
float* p,
float* q,
int depthtest,
float width) {
865 s_shader_capabilities_t* scap;
866 ttglobal tg = gglobal();
869 scap = getMyShader(NO_APPEARANCE_SHADER);
870 enableGlobalShader(scap);
871 positionLoc = scap->Vertices;
873 sendArraysToGPU(GL_LINES, 0, 2);
874 FW_GL_VERTEX_POINTER(3, GL_FLOAT, 0, pp[0]);
875 if (!depthtest) glDisable(GL_DEPTH_TEST);
878 if (!depthtest) glEnable(GL_DEPTH_TEST);
883 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
884 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
886 restoreGlobalShader();