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"
39 #include "statusbar.h"
47 GLubyte pixel_data[32 * 32 * 4 + 1];
50 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
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\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\0\0""0\0\0\0\20\0\0\0\0\0\0\0\0\0\0"
74 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40\0\0\0p***\302WWW\350qqq\372\177\177\177\377\177\177\177\377"
77 "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"
78 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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""0000\251ddd\363\213\213"
80 "\213\377\216\216\216\377\206\206\206\377\200\200\200\377\200\200\200\377"
81 "\206\206\206\377\216\216\216\377\213\213\213\377ddd\363000\251\0\0\0""0\0"
82 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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,"
84 ",,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227\0\0\0\200\0\0\0"
85 "\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,,\266\0\0\0""0\0"
86 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40""000\251yyy\373\213"
88 "\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"
89 "\0\0\0@\33\33\33\226GGG\347\213\213\213\377yyy\373000\251\0\0\0\40\0\0\0"
90 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
91 "\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"
92 "\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"
93 "\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"
94 "\0\0\0\0\0\0\0\0\0\0\0\0\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 "\0\0\0\0\0\0\0\0""0***\302\213\213\213\377ttt\366\33\33\33\226\0\0\0\40\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\40\33"
97 "\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"
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\0\0"
99 "\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"
100 "\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"
101 "\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"
102 "\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"
103 "\33\33\33\227\0\0\0\20\0\0\0\0\0\0\0\0\0\0\0@,,,\271ccc\365ccc\365,,,\271"
104 "\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"
105 "\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"
106 "\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"
107 "\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"
108 "\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"
109 "\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"
110 "\0\0\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"
111 "\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"
112 "\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"
113 "\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"
114 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
115 "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@,,,"
116 "\271ccc\365ccc\365,,,\271\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\20\33\33\33\227\206"
117 "\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"
118 "\0\0\0\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"
119 "\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"
120 "\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"
121 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
122 "\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"
123 "\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"
124 "\0\0\0\0\0\40\33\33\33\226ttt\366\213\213\213\377***\302\0\0\0""0\0\0\0\0"
125 "\0\0\0\0\0\0\0\0\0\0\0\0\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\0\0\0\0\0\0\20\0\0\0pddd\363\247\247\247\377GGG\347\0\0\0\177"
127 "\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"
128 "\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"
129 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
130 "\0\0\0\0\0\0\0\0\40""000\251yyy\373\213\213\213\377GGG\347\33\33\33\226\0"
131 "\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"
132 "\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"
133 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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,,,\266yyy\373\247\247\247\377ttt\366<<<\313\33\33\33\227"
135 "\0\0\0\200\0\0\0\200\33\33\33\227<<<\313ttt\366\247\247\247\377yyy\373,,"
136 ",\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"
137 "\0\0\0\0\0\0\0\0\0\0\0\0\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""0000\251ddd\363\213\213\213\377\216\216\216\377\206\206\206"
139 "\377\200\200\200\377\200\200\200\377\206\206\206\377\216\216\216\377\213"
140 "\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"
141 "\0\0\0\0\0\0\0\0\0\0\0\0\0\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\40\0\0\0p***\302WWW\350"
143 "qqq\372\177\177\177\377\177\177\177\377qqq\372WWW\350***\302\0\0\0p\0\0\0"
144 "\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"
145 "\0\0\0\0\0\0\0\0\0\0\0\0\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\20\0\0\0""0\0\0\0P\0\0\0o\0\0\0\177\0\0"
147 "\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"
148 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\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\0\0\0\0\0\0\0\0\0\0\0\0\0"
164 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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"
176 GLfloat cursorVert[] = {
183 GLfloat cursorTex[] = {
195 void *CursorDraw_constructor(){
200 void CursorDraw_init(
struct tCursorDraw *t){
203 t->prv = CursorDraw_constructor();
211 typedef struct {
int x;
int y;}
XY;
212 XY mouse2screen2(
int x,
int y)
220 typedef struct {GLfloat x; GLfloat y;}
FXY;
221 FXY screen2normalized( GLfloat x, GLfloat y )
224 xy.x = (x / gglobal()->display.screenWidth)*2.0f -1.0f;
225 xy.y = (y / gglobal()->display.screenHeight)*2.0f -1.0f;
228 static GLfloat cursIdentity[] = {
229 1.0f, 0.0f, 0.0f, 0.0f,
230 0.0f, 1.0f, 0.0f, 0.0f,
231 0.0f, 0.0f, 1.0f, 0.0f,
232 0.0f, 0.0f, 0.0f, 1.0f
238 static struct cline cur_fiducials [] = {
239 {3,{-.02f,.0f, 0.0f,-.02f, .02f,.0f}},
240 {0,{0.0f,0.0f,0.0f,0.0f,0.0f,0.0f}},
242 static struct cline cur_down [] = {
243 {3,{-.02f,.02f, .0f,.0f, .02f,.02f}},
244 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
246 static struct cline cur_up [] = {
247 {3,{-.02f,-.02f, .0f,.0f, .02f,-.02f}},
248 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
250 static struct cline cur_hover [] = {
251 {2,{-.02f,.0f, .02f,.0f, .0f,.0f}},
252 {2,{.0f,-.02f, .0f,.02f, .0f,.0f}},
253 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
255 static struct cline cur_over [] = {
256 {2,{.0f,.0f, .0f,.005f, .0f,.0f}},
257 {2,{.0f,.008f, .0f,.02f, .0f,.0f}},
258 {0,{.0f,.0f,.0f,.0f,.0f,.0f}},
269 static struct cline *cursor_array [] = {
279 void fiducialDrawB(
int cursortype,
int x,
int y)
287 struct cline *cur, *line;
294 xy = mouse2screen2(x,y);
295 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
296 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
297 aspect = (float)tg->display.screenHeight/(
float)tg->display.screenWidth;
300 FW_GL_DEPTHMASK(GL_FALSE);
301 glDisable(GL_DEPTH_TEST);
302 scap = getMyShader(NO_APPEARANCE_SHADER);
303 enableGlobalShader(scap);
304 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
305 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
310 positionLoc = scap->Vertices;
312 cur = cursor_array[cursortype];
316 for(i=0;i<line->n;i++){
317 p[i][0] = line->p[i*2]*aspect + fxy.x;
318 p[i][1] = line->p[i*2 + 1] + fxy.y;
320 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
322 glDrawArrays(GL_LINE_STRIP,0,line->n);
327 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
328 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
331 glEnable(GL_DEPTH_TEST);
332 FW_GL_DEPTHMASK(GL_TRUE);
333 restoreGlobalShader();
335 void fiducialDraw(
int ID,
int x,
int y,
float angleDeg)
346 xy = mouse2screen2(x,y);
347 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
348 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
357 if(angleDeg != 0.0f){
358 GLfloat cosine, sine, angleRad, xx,yy;
359 angleRad = angleDeg * (float)PI / 180.0f;
360 cosine = cosf(angleRad);
361 sine = sinf(angleRad);
363 xx = cosine*p[i][0] + sine*p[i][1];
364 yy = -sine*p[i][0] + cosine*p[i][1];
378 FW_GL_DEPTHMASK(GL_FALSE);
379 glDisable(GL_DEPTH_TEST);
380 scap = getMyShader(NO_APPEARANCE_SHADER);
381 enableGlobalShader(scap);
382 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
383 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
388 positionLoc = scap->Vertices;
389 glVertexAttribPointer (positionLoc, 2, GL_FLOAT,
391 glDrawArrays(GL_LINE_STRIP,0,3);
393 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
394 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
397 glEnable(GL_DEPTH_TEST);
398 FW_GL_DEPTHMASK(GL_TRUE);
399 restoreGlobalShader();
407 void statusbarHud_DrawCursor(GLint textureID,
int x,
int y);
409 unsigned int getCircleCursorTextureID(){
416 glGenTextures(1, &p->textureID);
417 glBindTexture(GL_TEXTURE_2D, p->textureID);
418 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
419 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
420 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
425 void cursorDraw(
int ID,
int x,
int y,
float angle)
431 GLint positionLoc, texCoordLoc, textureLoc;
433 GLint textureMatrix0;
435 GLfloat cursorVert2[18];
446 glGenTextures(1, &p->textureID);
447 glBindTexture(GL_TEXTURE_2D, p->textureID);
448 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
449 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
450 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, circleCursor.width, circleCursor.height, 0, GL_RGBA , GL_UNSIGNED_BYTE, circleCursor.pixel_data);
455 statusbarHud_DrawCursor(p->textureID,x,y);
458 #ifndef NEWWAY_COPIED_FROM_STATUSBARHUD_CURSORDRAW
460 FW_GL_DEPTHMASK(GL_FALSE);
461 glDisable(GL_DEPTH_TEST);
464 scap = getMyShader(ONE_TEX_APPEARANCE_SHADER);
465 enableGlobalShader(scap);
468 xy = mouse2screen2(x,y);
469 FW_GL_VIEWPORT(0, 0, tg->display.screenWidth, tg->display.screenHeight);
470 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
475 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
476 cursorVert2[i*3 +0] += fxy.x;
477 cursorVert2[i*3 +1] += fxy.y;
479 positionLoc = scap->Vertices;
480 glVertexAttribPointer (positionLoc, 3, GL_FLOAT,
481 GL_FALSE, 0, cursorVert2 );
484 texCoordLoc = scap->TexCoords[0];
485 glVertexAttribPointer ( texCoordLoc, 2, GL_FLOAT,
486 GL_FALSE, 0, cursorTex );
488 glEnableVertexAttribArray (positionLoc );
489 glEnableVertexAttribArray ( texCoordLoc);
492 glActiveTexture ( GL_TEXTURE0 );
493 glBindTexture ( GL_TEXTURE_2D, p->textureID );
497 textureLoc = scap->TextureUnit[0];
500 textureMatrix0 = scap->TextureMatrix[0];
501 glUniformMatrix4fv(textureMatrix0, 1, GL_FALSE, cursIdentity);
503 glUniform1i ( textureLoc, 0 );
508 glUniformMatrix4fv(scap->ModelViewMatrix, 1, GL_FALSE, cursIdentity);
510 glUniformMatrix4fv(scap->ProjectionMatrix, 1, GL_FALSE, cursIdentity);
512 glDrawArrays(GL_TRIANGLES,0,6);
514 FW_GL_BINDBUFFER(GL_ARRAY_BUFFER, 0);
515 FW_GL_BINDBUFFER(GL_ELEMENT_ARRAY_BUFFER, 0);
518 glEnable(GL_DEPTH_TEST);
519 FW_GL_DEPTHMASK(GL_TRUE);
520 restoreGlobalShader();
522 #endif //NEWWAY_COPIED_FROM_STATUSBARHUD_CURSORDRAW
526 FW_GL_DEPTHMASK(GL_FALSE);
528 #ifndef GL_ES_VERSION_2_0
529 FW_GL_SHADEMODEL(GL_FLAT);
541 xy = mouse2screen2(x,y);
544 FW_GL_MATRIX_MODE(GL_PROJECTION);
545 FW_GL_LOAD_IDENTITY();
546 FW_GL_MATRIX_MODE(GL_MODELVIEW);
547 FW_GL_LOAD_IDENTITY();
549 fxy = screen2normalized((GLfloat)xy.x,(GLfloat)xy.y);
551 FW_GL_TRANSLATE_F((
float)fxy.x,(
float)fxy.y,0.0f);
554 enableGlobalShader(getMyShader(ONE_TEX_APPEARANCE_SHADER));
555 shader = getAppearanceProperties()->currentShaderProperties->myShaderProgram;
557 glActiveTexture ( GL_TEXTURE0 );
558 glBindTexture ( GL_TEXTURE_2D, p->textureID );
562 loc = glGetAttribLocation ( shader,
"fw_Texture0" );
564 loc = glGetAttribLocation ( shader,
"fw_Vertex" );
565 xy = mouse2screen2(x,y);
568 cursorVert2[i*3 + j] = cursorVert[i*3 +j];
569 cursorVert2[i*3 +0] += fxy.x;
570 cursorVert2[i*3 +1] += fxy.y;
573 glVertexAttribPointer ( loc, 3, GL_FLOAT, GL_FALSE, 0, cursorVert2 );
575 loc = glGetAttribLocation ( shader,
"fw_TexCoords" );
576 glEnableVertexAttribArray ( loc );
577 glVertexAttribPointer ( loc, 2, GL_FLOAT, GL_FALSE, 0, cursorTex );
579 glEnableVertexAttribArray ( loc );
586 glDisable(GL_DEPTH_TEST);
594 #ifndef GL_ES_VERSION_2_0
595 FW_GL_WINDOWPOS2I(xy.x,xy.y);
596 FW_GL_DRAWPIXELS(circleCursor.width,circleCursor.height,GL_BGRA,GL_UNSIGNED_BYTE,circleCursor.pixel_data);
600 loc = glGetAttribLocation ( shader,
"fw_ModelViewMatrix" );
601 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
602 loc = glGetAttribLocation ( shader,
"fw_ProjectionMatrix" );
603 glUniformMatrix4fv(loc, 1, GL_FALSE, cursIdentity);
605 glDrawArrays(GL_TRIANGLES,0,6);
608 glEnable(GL_DEPTH_TEST);
610 #ifndef GL_ES_VERSION_2_0
611 FW_GL_SHADEMODEL(GL_SMOOTH);
613 FW_GL_DEPTHMASK(GL_TRUE);