Commit 45dcc46b328c7aae5a3a179d337e09dac7531a70

Authored by Pavel Govyadinov
1 parent 4cc75fd4

experimental overlay code... non-functional

Showing 2 changed files with 121 additions and 9 deletions   Show diff stats
TextureTest.cu
... ... @@ -4,6 +4,7 @@
4 4 #include "stim/math/vector.h"
5 5 //#include <GL/glew.h>
6 6 #include <GL/glut.h>
  7 +//#include <GL/gl.h>
7 8 //#include <GL/glext.h>
8 9 #include "stim/gl/gl_texture.h"
9 10 #include "stim/gl/error.h"
... ... @@ -12,6 +13,8 @@
12 13 #define HORIZONTAL 1
13 14 stim::camera cam;
14 15 GLuint texID;
  16 + float a = -1.0;
  17 + float b = 1.0;
15 18 GLsizei size[2] = {900,900};
16 19 GLfloat Normals[6][3] =
17 20 {{ -1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
... ... @@ -25,9 +28,9 @@
25 28 {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}};
26 29 GLint lines[24] = {0,1,1,2,2,3,0,3,4,5,5,7,7,6,6,4,3,6,2,7,1,5,0,4};
27 30 GLfloat vertexDrw[8][3] =
28   - {{-1.0, -1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, 1.0},
29   - {-1.0, 1.0, 1.0}, {-1.0, -1.0, -1.0}, {1.0, -1.0, -1.0},
30   - {-1.0, 1.0, -1.0}, {1.0, 1.0, -1.0}};
  31 + {{a, a, b}, {b, a, b}, {b, b, b},
  32 + {a, b, b}, {a, a, a}, {b, a, a},
  33 + {a, b, a}, {b, b, a}};
31 34 static float mousePos[2] = {0,0};
32 35 static float prevmousePos[2] = {0,0};
33 36 unsigned long tick = 0;
... ... @@ -45,7 +48,6 @@
45 48 ,adjustDrw/2
46 49 ,adjustDrw/2};
47 50 static GLfloat org[2] = {adjustTex/2,adjustTex/2+425*adjustTex};
48   -
49 51 //init for a cube
50 52 void
51 53 glInit()
... ... @@ -66,6 +68,7 @@ glInit()
66 68 glViewport(0, 0, size[0], size[1]);
67 69 glMatrixMode(GL_PROJECTION);
68 70 glLoadIdentity();
  71 + glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0);
69 72 glMatrixMode(GL_MODELVIEW);
70 73  
71 74 CHECK_OPENGL_ERROR
... ... @@ -181,15 +184,108 @@ DrawPlanes()
181 184 glPopName();
182 185 }
183 186  
  187 +void
  188 +DrawSpiders()
  189 +{
  190 + glBegin(GL_QUADS);
  191 + glTexCoord3f(
  192 + vertexTex[0][0],
  193 + vertexTex[0][1],
  194 + oriTex[2]
  195 + );
  196 + glVertex2f( -5.0,-5.0);
  197 + glTexCoord3f(
  198 + vertexTex[1][0],
  199 + vertexTex[1][1],
  200 + oriTex[2]
  201 + );
  202 + glVertex2f(-3.0, -5.0);
  203 + glTexCoord3f(
  204 + vertexTex[2][0],
  205 + vertexTex[2][1],
  206 + oriTex[2]
  207 + );
  208 + glVertex2f(-3.0, -3.0);
  209 + glTexCoord3f(
  210 + vertexTex[3][0],
  211 + vertexTex[3][1],
  212 + oriTex[2]
  213 + );
  214 + glVertex2f(-5.0, -3.0);
  215 + glEnd();
  216 + /*glBegin(GL_QUADS);
  217 + glTexCoord3f(
  218 + vertexTex[3][0],
  219 + oriTex[1],
  220 + vertexTex[3][2]
  221 + );
  222 + glVertex3f(
  223 + vertexDrw[3][0],
  224 + oriDrw[1],
  225 + vertexDrw[3][2]
  226 + );
  227 + glTexCoord3f(
  228 + vertexTex[2][0],
  229 + oriTex[1],
  230 + vertexTex[2][2]
  231 + );
  232 + glVertex3f(
  233 + vertexDrw[2][0],
  234 + oriDrw[1],
  235 + vertexDrw[2][2]
  236 + );
  237 + glTexCoord3f(
  238 + vertexTex[7][0],
  239 + oriTex[1],
  240 + vertexTex[7][2]
  241 + );
  242 + glVertex3f(
  243 + vertexDrw[7][0],
  244 + oriDrw[1],
  245 + vertexDrw[7][2]
  246 + );
  247 + glTexCoord3f(
  248 + vertexTex[6][0],
  249 + oriTex[1],
  250 + vertexTex[6][2]
  251 + );
  252 + glVertex3f(
  253 + vertexDrw[6][0],
  254 + oriDrw[1],
  255 + vertexDrw[6][2]
  256 + );
  257 + glEnd();*/
  258 +}
  259 +
  260 +
  261 +
184 262 //render cube
185 263 void
186 264 renderScene()
187 265 {
  266 +/* glInitNames();
  267 + glEnable(GL_TEXTURE_3D);
  268 + glBindTexture(GL_TEXTURE_3D, texID);
  269 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  270 + glMatrixMode(GL_MODELVIEW);
  271 + glLoadIdentity();
  272 + p = cam.getPosition();
  273 + up = cam.getUp();
  274 + d = cam.getLookAt();
  275 + gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], up[0], up[1], up[2]);
  276 + DrawPlanes();
  277 + glDisable(GL_TEXTURE_3D);
  278 + DrawCube();
  279 +*/
  280 +
  281 +//Draw 3D elements
188 282 glInitNames();
189 283 glEnable(GL_TEXTURE_3D);
190 284 glBindTexture(GL_TEXTURE_3D, texID);
191   - CHECK_OPENGL_ERROR
192 285 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  286 + glMatrixMode(GL_PROJECTION);
  287 + //glLoadIdentity();
  288 + glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0);
193 289 glMatrixMode(GL_MODELVIEW);
194 290 glLoadIdentity();
195 291 p = cam.getPosition();
... ... @@ -199,6 +295,19 @@ renderScene()
199 295 DrawPlanes();
200 296 glDisable(GL_TEXTURE_3D);
201 297 DrawCube();
  298 +
  299 +
  300 +//Draw 2D elements
  301 + glEnable(GL_TEXTURE_3D);
  302 + glBindTexture(GL_TEXTURE_3D, texID);
  303 + glMatrixMode(GL_PROJECTION);
  304 + glLoadIdentity();
  305 + gluOrtho2D(-5.0, 2.0,-5.0, 2.0);
  306 + glMatrixMode(GL_MODELVIEW);
  307 + DrawSpiders();
  308 + glDisable(GL_TEXTURE_3D);
  309 +*/
  310 +
202 311 glutSwapBuffers();
203 312 }
204 313  
... ... @@ -300,14 +409,12 @@ processKeys(unsigned char key, int x, int y)
300 409 void
301 410 changeSize(int w, int h)
302 411 {
303   - CHECK_OPENGL_ERROR
304 412 glViewport(0,0,w,h);
305 413 glMatrixMode(GL_PROJECTION);
306 414 glLoadIdentity();
307   - glOrtho(-3.0, 3.0,-3.0, 3.0, -0.0, 1000.0);
  415 + glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0);
308 416 //gluPerspective(90, 4.0/3.0, 0.1, 100.0);
309 417 glMatrixMode(GL_MODELVIEW);
310   - CHECK_OPENGL_ERROR
311 418 }
312 419  
313 420  
... ... @@ -317,6 +424,11 @@ main(int argc, char **argv)
317 424 CHECK_OPENGL_ERROR
318 425 glutInit(&argc, argv);
319 426 glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
  427 + int overlaySupport = glutLayerGet(GLUT_OVERLAY_POSSIBLE);
  428 + if(overlaySupport) {
  429 + std::cout << "Overlay YAY!" << std::endl;
  430 + } else {
  431 + std::cout << "Overlay AW!" << std::endl;}
320 432 glutInitWindowSize(size[0], size[1]);
321 433 glutCreateWindow("gl_texture");
322 434 //std::cout << " Initialization is complete in Glut" << std::endl;
... ...
1   -Subproject commit 5f54af5bd29311434eee0930989babd057bfb7c5
  1 +Subproject commit fb0bc2f13a22ec3579c5d48970eec944e31b59bc
... ...