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/OpenGL_Utils.h"
35#include "opengl/Textures.h"
36#include "opengl/LoadTextures.h"
37#include "main/MainLoop.h"
38#include "scenegraph/RenderFuncs.h"
40#include "../scenegraph/LinearAlgebra.h"
48 GLubyte pixel_data[32 * 32 * 4 + 1];
51 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
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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0\0""0\0\0\0\20\0\0\0\0\0\0\0\0\0\0"
75 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40\0\0\0p***\302WWW\350qqq\372\177\177\177\377\177\177\177\377"
78 "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"
79 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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""0000\251ddd\363\213\213"
81 "\213\377\216\216\216\377\206\206\206\377\200\200\200\377\200\200\200\377"
82 "\206\206\206\377\216\216\216\377\213\213\213\377ddd\363000\251\0\0\0""0\0"
83 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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,"
85 ",,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227\0\0\0\200\0\0\0"
86 "\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,,\266\0\0\0""0\0"
87 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40""000\251yyy\373\213"
89 "\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"
90 "\0\0\0@\33\33\33\226GGG\347\213\213\213\377yyy\373000\251\0\0\0\40\0\0\0"
91 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
92 "\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"
93 "\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"
94 "\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"
95 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
96 "\0\0\0\0\0\0\0\0""0***\302\213\213\213\377ttt\366\33\33\33\226\0\0\0\40\0"
97 "\0\0\0\0\0\0\0\0\0\0\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"
98 "\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"
99 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
100 "\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"
101 "\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"
102 "\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"
103 "\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"
104 "\33\33\33\227\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@,,,\271ccc\365ccc\365,,,\271"
105 "\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"
106 "\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"
107 "\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"
108 "\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"
109 "\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"
110 "\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"
111 "\0\0\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"
112 "\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"
113 "\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"
114 "\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"
115 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
116 "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@,,,"
117 "\271ccc\365ccc\365,,,\271\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\33\33\33\227\206"
118 "\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"
119 "\0\0\0\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"
120 "\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"
121 "\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"
122 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
123 "\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"
124 "\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"
125 "\0\0\0\0\0\40\33\33\33\226ttt\366\213\213\213\377***\302\0\0\0""0\0\0\0\0"
126 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
127 "\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"
128 "\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"
129 "\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"
130 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
131 "\0\0\0\0\0\0\0\0\40""000\251yyy\373\213\213\213\377GGG\347\33\33\33\226\0"
132 "\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"
133 "\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"
134 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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,,,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227"
136 "\0\0\0\200\0\0\0\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,"
137 ",\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"
138 "\0\0\0\0\0\0\0\0\0\0\0\0\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""0000\251ddd\363\213\213\213\377\216\216\216\377\206\206\206"
140 "\377\200\200\200\377\200\200\200\377\206\206\206\377\216\216\216\377\213"
141 "\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"
142 "\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40\0\0\0p***\302WWW\350"
144 "qqq\372\177\177\177\377\177\177\177\377qqq\372WWW\350***\302\0\0\0p\0\0\0"
145 "\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"
146 "\0\0\0\0\0\0\0\0\0\0\0\0\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\20\0\0\0""0\0\0\0P\0\0\0o\0\0\0\177\0\0"
148 "\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"
149 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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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0\0\0\0\0\0\0\0\0\0\0\0\0"
165 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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"
177GLfloat cursorVert[] = {
184GLfloat cursorTex[] = {
196void *CursorDraw_constructor(){
201void CursorDraw_init(
struct tCursorDraw *t){
204 t->prv = CursorDraw_constructor();
212typedef struct {
int x;
int y;}
XY;
213XY mouse2screen2(
int x,
int y)
221typedef struct {GLfloat x; GLfloat y;}
FXY;
222FXY screen2normalized( GLfloat x, GLfloat y )
225 xy.x = (x / gglobal()->display.screenWidth)*2.0f -1.0f;
226 xy.y = (y / gglobal()->display.screenHeight)*2.0f -1.0f;
229static GLfloat cursIdentity[] = {
230 1.0f, 0.0f, 0.0f, 0.0f,
231 0.0f, 1.0f, 0.0f, 0.0f,
232 0.0f, 0.0f, 1.0f, 0.0f,
233 0.0f, 0.0f, 0.0f, 1.0f
239static struct cline cur_fiducials [] = {
240 {3,{-.02f,.0f, 0.0f,-.02f, .02f,.0f}},
241 {0,{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}},
243static struct cline cur_down [] = {
244 {3,{-.02f,.02f, .0f,.0f, .02f,.02f}},
245 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
247static struct cline cur_up [] = {
248 {3,{-.02f,-.02f, .0f,.0f, .02f,-.02f}},
249 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
251static struct cline cur_hover [] = {
252 {2,{-.02f,.0f, .02f,.0f, .0f,.0f}},
253 {2,{.0f,-.02f, .0f,.02f, .0f,.0f}},
254 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
256static struct cline cur_over [] = {
257 {2,{.0f,.0f, .0f,.005f, .0f,.0f}},
258 {2,{.0f,.008f, .0f,.02f, .0f,.0f}},
259 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
270static struct cline *cursor_array [] = {
280void fiducialDrawB(
int cursortype,
int x,
int y)
288 struct cline *cur, *line;
295 xy = mouse2screen2(x,y);
296 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
297 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
298 aspect = (float)tg->display.screenHeight/(
float)tg->display.screenWidth;
301 FW_GL_DEPTHMASK(GL_FALSE);
302 glDisable(GL_DEPTH_TEST);
303 scap = getMyShader(NO_APPEARANCE_SHADER);
304 enableGlobalShader(scap);
305 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
306 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
311 positionLoc = scap->Vertices;
313 cur = cursor_array[cursortype];
317 for(i=0;i<line->n;i++){
318 p[i][0] = line->p[i*2]*aspect + fxy.x;
319 p[i][1] = line->p[i*2 + 1] + fxy.y;
321 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
323 glDrawArrays(GL_LINE_STRIP,0,line->n);
328 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
329 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
332 glEnable(GL_DEPTH_TEST);
333 FW_GL_DEPTHMASK(GL_TRUE);
334 restoreGlobalShader();
336void fiducialDraw(
int ID,
int x,
int y,
float angleDeg)
347 xy = mouse2screen2(x,y);
348 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
349 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
358 if(angleDeg != 0.0f){
359 GLfloat cosine, sine, angleRad, xx,yy;
360 angleRad = angleDeg * (float)PI / 180.0f;
361 cosine = cosf(angleRad);
362 sine = sinf(angleRad);
364 xx = cosine*p[i][0] + sine*p[i][1];
365 yy = -sine*p[i][0] + cosine*p[i][1];
379 FW_GL_DEPTHMASK(GL_FALSE);
380 glDisable(GL_DEPTH_TEST);
381 scap = getMyShader(NO_APPEARANCE_SHADER);
382 enableGlobalShader(scap);
383 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
384 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
389 positionLoc = scap->Vertices;
390 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
392 glDrawArrays(GL_LINE_STRIP,0,3);
394 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
395 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
398 glEnable(GL_DEPTH_TEST);
399 FW_GL_DEPTHMASK(GL_TRUE);
400 restoreGlobalShader();
408void statusbarHud_DrawCursor(GLint textureID,
int x,
int y);
410unsigned int getCircleCursorTextureID(){
417 glGenTextures(1, &p->textureID);
418 glBindTexture(GL_TEXTURE_2D, p->textureID);
419 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
420 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
421 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
426void cursorDraw(
int ID,
int x,
int y,
float angle)
432 GLint positionLoc, texCoordLoc, textureLoc;
434 GLint textureMatrix0;
436 GLfloat cursorVert2[18];
447 glGenTextures(1, &p->textureID);
448 glBindTexture(GL_TEXTURE_2D, p->textureID);
449 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
450 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
451 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
456 statusbarHud_DrawCursor(p->textureID,x,y);
459#ifndef NEWWAY_COPIED_FROM_STATUSBARHUD_CURSORDRAW
461 FW_GL_DEPTHMASK(GL_FALSE);
462 glDisable(GL_DEPTH_TEST);
465 scap = getMyShader(ONE_TEX_APPEARANCE_SHADER);
466 enableGlobalShader(scap);
469 xy = mouse2screen2(x,y);
470 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
471 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
476 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
477 cursorVert2[i*3 +0] += fxy.x;
478 cursorVert2[i*3 +1] += fxy.y;
480 positionLoc = scap->Vertices;
481 glVertexAttribPointer (positionLoc, 3, GL_FLOAT,
482 GL_FALSE, 0, cursorVert2 );
485 texCoordLoc = scap->TexCoords[0];
486 glVertexAttribPointer ( texCoordLoc, 2, GL_FLOAT,
487 GL_FALSE, 0, cursorTex );
489 glEnableVertexAttribArray (positionLoc );
490 glEnableVertexAttribArray ( texCoordLoc);
493 glActiveTexture ( GL_TEXTURE0 );
494 glBindTexture ( GL_TEXTURE_2D, p->textureID );
498 textureLoc = scap->TextureUnit[0];
501 textureMatrix0 = scap->TextureMatrix[0];
502 glUniformMatrix4fv(textureMatrix0, 1, GL_FALSE, cursIdentity);
504 glUniform1i ( textureLoc, 0 );
509 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
511 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
513 glDrawArrays(GL_TRIANGLES,0,6);
515 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
516 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
519 glEnable(GL_DEPTH_TEST);
520 FW_GL_DEPTHMASK(GL_TRUE);
521 restoreGlobalShader();
527 FW_GL_DEPTHMASK(GL_FALSE);
529 #ifndef GL_ES_VERSION_2_0
530 FW_GL_SHADEMODEL(GL_FLAT);
542 xy = mouse2screen2(x,y);
545 FW_GL_MATRIX_MODE(GL_PROJECTION);
546 FW_GL_LOAD_IDENTITY();
547 FW_GL_MATRIX_MODE(GL_MODELVIEW);
548 FW_GL_LOAD_IDENTITY();
550 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
552 FW_GL_TRANSLATE_F((
float)fxy.x,(
float)fxy.y,0.0f);
555 enableGlobalShader(getMyShader(ONE_TEX_APPEARANCE_SHADER));
556 shader = getAppearanceProperties()->currentShaderProperties->myShaderProgram;
558 glActiveTexture ( GL_TEXTURE0 );
559 glBindTexture ( GL_TEXTURE_2D, p->textureID );
563 loc = glGetAttribLocation ( shader,
"fw_Texture0" );
565 loc = glGetAttribLocation ( shader,
"fw_Vertex" );
566 xy = mouse2screen2(x,y);
569 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
570 cursorVert2[i*3 +0] += fxy.x;
571 cursorVert2[i*3 +1] += fxy.y;
574 glVertexAttribPointer ( loc, 3, GL_FLOAT, GL_FALSE, 0, cursorVert2 );
576 loc = glGetAttribLocation ( shader,
"fw_TexCoords" );
577 glEnableVertexAttribArray ( loc );
578 glVertexAttribPointer ( loc, 2, GL_FLOAT, GL_FALSE, 0, cursorTex );
580 glEnableVertexAttribArray ( loc );
587 glDisable(GL_DEPTH_TEST);
595 #ifndef GL_ES_VERSION_2_0
596 FW_GL_WINDOWPOS2I(xy.x,xy.y);
597 FW_GL_DRAWPIXELS(circleCursor.width,circleCursor.height,GL_BGRA,GL_UNSIGNED_BYTE,circleCursor.pixel_data);
601 loc = glGetAttribLocation ( shader,
"fw_ModelViewMatrix" );
602 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
603 loc = glGetAttribLocation ( shader,
"fw_ProjectionMatrix" );
604 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
606 glDrawArrays(GL_TRIANGLES,0,6);
609 glEnable(GL_DEPTH_TEST);
611 #ifndef GL_ES_VERSION_2_0
612 FW_GL_SHADEMODEL(GL_SMOOTH);
614 FW_GL_DEPTHMASK(GL_TRUE);
620void vecprinti3fb(
char *name,
int i,
float *p,
char *eol){
621printf(
"%s[%d] %f %f %f %s",name,i,p[0],p[1],p[2],eol);
623int extent6f_isSet(
float *extent6);
624static float testextent [] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
625void reallyDrawOnce();
627void extent6f_draw(
float *extent)
634 unsigned short lineindices[3];
635 struct cline *cur, *line;
638 if(!extent6f_isSet(extent))
return;
640 scap = getMyShader(NO_APPEARANCE_SHADER);
641 enableGlobalShader(scap);
655 p[n][1] = extent[j+2];
656 p[n][2] = extent[k+4];
666 p[n][1] = extent[i+2];
667 p[n][2] = extent[k+4];
676 p[n][1] = extent[j+2];
677 p[n][2] = extent[i+4];
684 positionLoc = scap->Vertices;
688 sendArraysToGPU (GL_LINES, 0, n);
689 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[0]);
693 sendElementsToGPU(GL_LINES,2,(ushort *)lineindices);
700 FW_GL_VERTEX_POINTER (3,GL_FLOAT,0,p[i]);
710 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
711 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
713 restoreGlobalShader();