943,013 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 54
  • C++ RSS
Sep 2nd, 2010
0

OpenGL help

Expand Post »
Hey, at my camp, I made a random 3D maze gen off of OpenGL

So, I downloaded OpenGL 3.7, and I placed the glut.dll in the right place, the header file in the right place, the lib file in the right place etc.

But my conflict is that I used a different version of OpenGL at my camp because the header 3.7 header doesn't recognize some of the code.

So could someone tell me what version of OpenGL uses this header?

C++ Syntax (Toggle Plain Text)
  1. <GL/glut.h>
thank you.

And if you know the solution and can run the code, here is the whole code if you're curious.

C++ Syntax (Toggle Plain Text)
  1. // openGL stuff
  2.  
  3. #include <list>
  4. #include <time.h>
  5. #include <windows.h>
  6. #include <GL/glut.h>
  7. #include <stdlib.h>
  8. #include <cstdio>
  9. #include <iostream>
  10.  
  11. #define MSIZE 5
  12.  
  13. using namespace std;
  14.  
  15. void init();
  16. void display();
  17. void keyboard();
  18.  
  19. class Character {
  20. GLfloat x, y, z;
  21.  
  22. public:
  23. Character(GLfloat _cx, GLfloat _cy, GLfloat _cz)
  24. {
  25. x = _cx;
  26. y = _cy;
  27. z = _cz;
  28. }
  29. Character(const Character& b)
  30. {
  31. x = b.x;
  32. y = b.y;
  33. z = b.z;
  34. }
  35.  
  36. void draw()
  37. {
  38. glShadeModel(GL_SMOOTH);
  39. glPushMatrix();
  40. //glRotatef(cspin, 0.0, 0.0, 1.0);
  41. //cspin ++;
  42. glTranslatef(0.0, 0.0, -.25);
  43. glColor4f(1.0, 0.0, 1.0, 0.0);
  44. glutSolidTeapot(5.0);
  45. glDisable(GL_LIGHTING);
  46. glPopMatrix();
  47. }
  48. };
  49.  
  50. class Cell {
  51.  
  52. public:
  53. GLfloat x, y, z;
  54. GLfloat width, depth, height;
  55. GLfloat red, green, blue;
  56.  
  57. Cell(){
  58. x = -1;
  59. y = -1;
  60. z = -1;
  61. red = ((float) rand()) / RAND_MAX;
  62. green = ((float) rand()) / RAND_MAX;
  63. blue = ((float) rand()) / RAND_MAX;
  64. }
  65.  
  66. Cell(const Cell& cell){
  67. x=cell.x;
  68. y=cell.y;
  69. z=cell.z;
  70. red = cell.red;
  71. green = cell.green;
  72. blue = cell.blue;
  73.  
  74. }
  75.  
  76. bool adjacent(Cell& cell)
  77. {
  78. GLfloat dx = abs(x-cell.x);
  79. GLfloat dy = abs(y-cell.y);
  80. GLfloat dz = abs(z-cell.z);
  81.  
  82. return (dx == 1 && dy == 0 && dz == 0) ||
  83. (dy == 1 && dx == 0 && dz == 0) ||
  84. (dz == 1 && dx == 0 && dy == 0);
  85. }
  86.  
  87. bool equals (Cell& cell)
  88. {
  89. return(x==cell.x && y == cell.y && z == cell.z);
  90. }
  91.  
  92. void draw()
  93. {
  94. /*glFrontFace(GL_CW);
  95. glBegin(GL_QUADS);
  96. glColor4f(0.0, 1.0, 1.0, 0.7);
  97. glVertex3f(x, y, z);
  98. glVertex3f(x + width, y, z);
  99. glVertex3f(x + width, y + height, z);
  100. glVertex3f(x, y + height, z);
  101.  
  102. glColor4f(1.0, 0.0, 0.0, 0.7);
  103. glVertex3f(x, y, z);
  104. glVertex3f(x, y + height, z);
  105. glVertex3f(x, y + height, z + depth);
  106. glVertex3f(x, y, z + depth);
  107.  
  108. glColor4f(1.0, 1.0, 0.0, 0.7);
  109. glVertex3f(x, y, z);
  110. glVertex3f(x, y, z + depth);
  111. glVertex3f(x + width, y, z + depth);
  112. glVertex3f(x + width, y, z);
  113.  
  114. glColor4f(0.0, 1.0, 1.0, 0.7);
  115. glVertex3f(x + width, y + height, z + depth);
  116. glVertex3f(x + width, y, z + depth);
  117. glVertex3f(x, y, z + depth);
  118. glVertex3f(x, y + height, z + depth);
  119.  
  120. glColor4f(1.0, 0.0, 0.0, 0.7);
  121. glVertex3f(x + width, y, z + depth);
  122. glVertex3f(x + width, y + height, z + depth);
  123. glVertex3f(x + width, y + height, z);
  124. glVertex3f(x + width, y, z);
  125.  
  126. glColor4f(1.0, 1.0, 0.0, 0.7);
  127. glVertex3f(x + width, y + height, z);
  128. glVertex3f(x + width, y + height, z + depth);
  129. glVertex3f(x, y + height, z + depth);
  130. glVertex3f(x, y + height, z);
  131.  
  132. glEnd();*/
  133.  
  134. }
  135.  
  136. //int operator<(Cell& );
  137. };
  138.  
  139.  
  140. typedef list<Cell> CLIST;
  141.  
  142. class CellSet{
  143. //CLIST set;
  144.  
  145. public:
  146. CLIST set;
  147.  
  148. CellSet(){}
  149. CellSet(Cell cell) {
  150. set.push_front(cell);
  151. }
  152. CellSet(const CellSet& set2){
  153. set.assign(set2.set.begin(),set2.set.end());
  154. }
  155.  
  156. bool member(Cell& cell){
  157. for(CLIST::iterator i=set.begin();i!=set.end();++i) {
  158. if (cell.equals(*i)){
  159. return true;
  160. }
  161. }
  162. return false;
  163. }
  164.  
  165. CellSet& merge(CellSet& set2)
  166. {
  167. //se
  168. for(CLIST::iterator i=set2.set.begin();i!=set2.set.end();++i) {
  169. CLIST::iterator j=set.begin();
  170. if (!member(*i))
  171. {
  172. set.push_front(*i);
  173. }
  174. }
  175. return *this;
  176. }
  177. CellSet& difference(CellSet& set2)
  178. {
  179. for(CLIST::iterator i=set2.set.begin();i!=set2.set.end();++i) {
  180. CLIST::iterator j=set.begin();
  181. while (j!=set.end()&& !(*i).equals(*j)) {
  182. ++j;
  183. }
  184. if(j!=set.end())
  185. {
  186. set.erase(j);
  187. }
  188. }
  189. return *this;
  190. }
  191. bool empty(){
  192. return set.empty();
  193. }
  194. CellSet& intersect(CellSet& set2){
  195. for(CLIST::iterator i=set.begin();i!=set.end();++i) {
  196. CLIST::iterator j=set2.set.begin();
  197. while (j!=set2.set.end()&& !(*i).equals(*j)) {
  198. ++j;
  199. }
  200. if(j==set2.set.end())
  201. {
  202. set.erase(i);
  203. }
  204. }
  205. return *this;
  206. }
  207. bool subset(CellSet& set2){
  208. CLIST::iterator i;
  209. for(i=set.begin();i!=set.end();++i) {
  210. if (! set2.member(*i)){
  211. return false;
  212. }
  213. }
  214. return true;
  215. }
  216. bool equals(CellSet& set2){
  217. CLIST::iterator i;
  218. return (subset(set2) && set2.subset(*this));
  219. }
  220.  
  221.  
  222. CLIST::iterator get(int index){
  223. CLIST::iterator i;
  224. for (i=set.begin();index > 0 && i != set.end();++i, --index);
  225. return i;
  226. }
  227. };
  228.  
  229. typedef list<CellSet> CSLIST;
  230.  
  231. class CSSet {
  232. //CSLIST set;
  233.  
  234. public:
  235. CSLIST set;
  236.  
  237. CSSet(){}
  238. CSSet(CellSet cell) {
  239. set.push_front(cell);
  240. }
  241. CSSet(const CSSet& set2){
  242. set.assign(set2.set.begin(),set2.set.end());
  243. }
  244.  
  245. bool member(CellSet& cell){
  246. for(CSLIST::iterator i=set.begin();i!=set.end();++i) {
  247. if (cell.equals(*i)){
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253.  
  254. CSSet& merge(CSSet& set2)
  255. {
  256. //se
  257. for(CSLIST::iterator i=set2.set.begin();i!=set2.set.end();++i) {
  258. CSLIST::iterator j=set.begin();
  259. if (!member(*i))
  260. {
  261. set.push_front(*i);
  262. }
  263. }
  264. return *this;
  265. }
  266. CSSet& difference(CSSet& set2)
  267. {
  268. for(CSLIST::iterator i=set2.set.begin();i!=set2.set.end();++i) {
  269. CSLIST::iterator j=set.begin();
  270. while (j!=set.end()&& !(*i).equals(*j)) {
  271. ++j;
  272. }
  273. if(j!=set.end())
  274. {
  275. set.erase(j);
  276. }
  277. }
  278. return *this;
  279. }
  280. bool empty(){
  281. return set.empty();
  282. }
  283. CSSet& intersect(CSSet& set2){
  284. for(CSLIST::iterator i=set.begin();i!=set.end();++i) {
  285. CSLIST::iterator j=set2.set.begin();
  286. while (j!=set2.set.end()&& !(*i).equals(*j)) {
  287. ++j;
  288. }
  289. if(j==set2.set.end())
  290. {
  291. set.erase(i);
  292. }
  293. }
  294. return *this;
  295. }
  296.  
  297. bool subset(CSSet& set2){
  298. CSLIST::iterator i;
  299. for(i=set.begin();i!=set.end();++i) {
  300. if (! set2.member(*i)){
  301. return false;
  302. }
  303. }
  304. return true;
  305. }
  306. bool equals(CSSet& set2){
  307. CSLIST::iterator i;
  308. return (subset(set2) && set2.subset(*this));
  309. }
  310.  
  311. CSLIST::iterator get(int index){
  312. CSLIST::iterator i;
  313. for (i=set.begin();index > 0 && i != set.end();++i, --index);
  314. return i;
  315. }
  316. };
  317.  
  318. /*int operator<(Cell& cell1, Cell& cell2) {
  319. return cell1.getID() < cell2.getID();
  320. }*/
  321.  
  322. //typedef list<CSET> CSSET;
  323.  
  324. CSSet walls;
  325. GLfloat cspin = 0.0;
  326. GLfloat x = 0.25, y = 0.25, z = 0.25;
  327. GLfloat xspin = 0.0, yspin = 0.0, zspin = 0.0;
  328.  
  329. CellSet maze;
  330. //Cell cells[MSIZE][MSIZE][MSIZE];
  331. bool intersectWall(CellSet wall) {
  332. Cell cell1 = *(wall.get(0));
  333. Cell cell2 = *(wall.get(1));
  334. GLfloat cx = cell1.x, cy = cell1.y, cz = cell1.z;
  335. //
  336. GLfloat dx = 1, dy = 1, dz = 1;
  337. if (cell1.x != cell2.x){
  338. dx=0;
  339. cx += (cell1.x < cell2.x ? 1 : 0);
  340. }
  341. if (cell1.y != cell2.y){
  342. dy=0;
  343. cy += (cell1.y < cell2.y ? 1 : 0);
  344. }
  345. if (cell1.z != cell2.z){
  346. dz=0;
  347. cz += (cell1.z < cell2.z ? 1 : 0);
  348. }
  349. //
  350. GLfloat px = x - 0.05, py = y - 0.05, pz = z - 0.05;
  351. GLfloat pw = 0.1, ph = 0.1, pd = 0.1;
  352.  
  353. // x1 = cx, y1 = cy, z1 = cz, width1 = dx, height1 = dy, depth1 = dz
  354. // x2 = px, y2 = cy, z2 = cz, width2 = pw, height2 = ph, depth2 = pz
  355.  
  356. return !(cx>px+pw || cx + dx<px)&&
  357. !(cy>py+ph || cy + dy<py)&&
  358. !(cz>pz+pd || cz + dz<pz);
  359.  
  360. //glFrontFace(GL_CW);
  361. //cout << cx << endl;
  362.  
  363. //glBegin(GL_QUADS);
  364. //glColor3f(1.0, 1.0, 1.0);
  365. /*if (dz == 0 || dy == 0) {
  366. glVertex3f(cx, cy, cz);
  367. glVertex3f(cx + dx, cy, cz);
  368. glVertex3f(cx + dx, cy + dy, cz + dz);
  369. glVertex3f(cx, cy + dy, cz + dz);
  370. }
  371.  
  372. if (dx == 0) {
  373. glVertex3f(cx, cy, cz);
  374. glVertex3f(cx + dx, cy + dy, cz);
  375. glVertex3f(cx + dx, cy + dy, cz + dz);
  376. glVertex3f(cx, cy, cz + dz);
  377. }*/
  378. //glEnd();
  379. }
  380.  
  381. void drawWall(CellSet wall) {
  382. Cell cell1 = *(wall.get(0));
  383. Cell cell2 = *(wall.get(1));
  384. GLfloat cx = cell1.x, cy = cell1.y, cz = cell1.z;
  385. //
  386. GLfloat dx = 1, dy = 1, dz = 1;
  387. if (cell1.x != cell2.x){
  388. dx=0;
  389. cx += (cell1.x < cell2.x ? 1 : 0);
  390. }
  391. if (cell1.y != cell2.y){
  392. dy=0;
  393. cy += (cell1.y < cell2.y ? 1 : 0);
  394. }
  395. if (cell1.z != cell2.z){
  396. dz=0;
  397. cz += (cell1.z < cell2.z ? 1 : 0);
  398. }
  399.  
  400. //glFrontFace(GL_CW);
  401. //cout << cx << endl;
  402. glColor3f((cell1.red + cell2.red) / 2,(cell1.green + cell2.green) / 2, (cell1.blue + cell2.blue) / 2);
  403. /*glBegin(GL_QUADS);
  404. glVertex3f(-1.0, -1.0, -1.0);
  405. glVertex3f(-1.0, 1.0, -1.0);
  406. glVertex3f(1.0, 1.0, -1.0);
  407. glVertex3f(-1.0, 1.0, -1.0);
  408. glEnd();*/
  409. glBegin(GL_QUADS);
  410. //glColor3f(1.0, 1.0, 1.0);
  411. if (dz == 0 || dy == 0) {
  412. glVertex3f(cx, cy, cz);
  413. glVertex3f(cx + dx, cy, cz);
  414. glVertex3f(cx + dx, cy + dy, cz + dz);
  415. glVertex3f(cx, cy + dy, cz + dz);
  416. }
  417.  
  418. if (dx == 0) {
  419. glVertex3f(cx, cy, cz);
  420. glVertex3f(cx, cy + dy, cz);
  421. glVertex3f(cx, cy + dy, cz + dz);
  422. glVertex3f(cx, cy, cz + dz);
  423. }
  424. glEnd();
  425.  
  426. }
  427.  
  428.  
  429.  
  430. /* W x,y,z W
  431. 0,1,1 1,1,1 1,1,1
  432.  
  433. xy walls
  434. xz walls
  435. yz walls
  436. */
  437.  
  438.  
  439.  
  440. GLfloat tx = 0.0, ty = 0.0, tz = 0.0;
  441. GLfloat cx = 0.0, cy = 0.0, cz = -10.0;
  442. /*typedef list<Building> BLIST;
  443.  
  444. BLIST bl;*/
  445.  
  446. /*void draw()
  447. {
  448. glShadeModel(GL_SMOOTH);
  449. glPushMatrix();
  450. glRotatef(cspin, 0.0, 0.0, 1.0);
  451. cspin ++;
  452. glColor3f(1.0, 1.0, 0.0);
  453. glutSolidCube(5.0);
  454. glutSolidTorus(1.0, 2.0, 2.0, 20);
  455. glDisable(GL_LIGHTING);
  456. glPopMatrix();
  457. }*/
  458.  
  459. bool intersectWalls()
  460. {
  461. for(CSLIST::iterator i = walls.set.begin(); i != walls.set.end(); ++i)
  462. {
  463. if (intersectWall(*i)) return true;
  464. }
  465. return false;
  466. }
  467.  
  468. void display()
  469. {
  470. glClear(GL_COLOR_BUFFER_BIT);
  471. glClear(GL_DEPTH_BUFFER_BIT);
  472.  
  473. glMatrixMode(GL_PROJECTION);
  474. //glLoadIdentity();
  475. glPushMatrix();
  476. //glTranslatef(x, y, z);
  477. //glTranslatef(-x, -y, -z);
  478. glRotatef(xspin, 1.0, 0.0, 0.0);
  479. glRotatef(yspin, 0.0, 1.0, 0.0);
  480. glRotatef(zspin, 0.0, 0.0, 1.0);
  481. glTranslatef(-x, -y, -z);
  482. //glTranslatef(-x, -y, -z);
  483. /*glRotatef(xspin, 1.0, 0.0, 0.0);
  484. glRotatef(yspin, 0.0, 1.0, 0.0);
  485. glRotatef(zspin, 0.0, 0.0, 1.0);*/
  486. //gluPerspective(30.0, 4.0 / 3.0 , 0.5, MSIZE + 1);
  487. //glTranslatef(0, 0, -1.5);
  488. //glRotatef(cspin, 0.0, 1.0, 0.0);
  489. glColor4f(1.0, 1.0, 1.0, 0.0);
  490. //cspin += 0.5;
  491.  
  492.  
  493. glMatrixMode(GL_MODELVIEW);
  494. glPushMatrix();
  495. glTranslatef(x, y, z); // - 1.5);
  496. glRotatef(-xspin, 1.0, 0.0, 0.0);
  497. glRotatef(-yspin, 0.0, 1.0, 0.0);
  498. glRotatef(-zspin, 0.0, 0.0, 1.0);
  499. glTranslatef(0, 0, -1.5);
  500. //glRotatef(xspin, 0.0, 1.0, 0.0);
  501. //glRotatef(cspin, 0.0, -4.0, 0.0);
  502. //glRotatef(cspin, 0.0, 0.0, -4.0);
  503.  
  504. glutSolidTeapot(0.1);
  505.  
  506. glPopMatrix();
  507.  
  508. //Character player(cx, cy, cz);
  509. //player.draw();
  510.  
  511. CSLIST::iterator i;
  512.  
  513. for(i = walls.set.begin(); i != walls.set.end(); ++i)
  514. {
  515. drawWall((*i));
  516. }
  517.  
  518. //glPopMatrix();
  519. glMatrixMode(GL_PROJECTION);
  520.  
  521. glPopMatrix();
  522.  
  523. //glMatrixMode(GL_MODELVIEW);
  524.  
  525. glFlush();
  526.  
  527. glutPostRedisplay();
  528. }
  529. void keyboard() {
  530. if (GetAsyncKeyState(0x57) & 0x8000)
  531. {
  532. y += 0.01;
  533. if(intersectWalls()) y -= 0.01;
  534. else cout << y << endl;
  535. //cout << z << endl;
  536. //yspin = 90;
  537. //xspin = 0;
  538. //yspin = 0;
  539. //zspin = 0;
  540. }
  541. if (GetAsyncKeyState(0x41) & 0x8000)
  542. {
  543. x -= 0.01;
  544. if(intersectWalls()) x += 0.01;
  545. //yspin = 270;
  546. //xspin = 0;
  547. //xspin = 0;
  548. //yspin = 0;
  549. //zspin = 0;
  550. }
  551. if (GetAsyncKeyState(0x44) & 0x8000)
  552. {
  553. x += 0.01;
  554. if(intersectWalls()) x -= 0.01;
  555. //xspin = 0;
  556. //yspin = 0;
  557. //zspin = 0;
  558. }
  559. if (GetAsyncKeyState(0x53) & 0x8000)
  560. {
  561. y-= 0.01;
  562. if(intersectWalls()) y += 0.01;
  563. //cout << z << endl;
  564. //xspin = 0;
  565. //yspin = 0;
  566. //zspin = 0;
  567.  
  568. }
  569. if (GetAsyncKeyState(0x20) & 0x8000)
  570. {
  571. tx = cx;
  572. ty = cy;
  573. tz = cz + 20;
  574. }
  575. if (GetAsyncKeyState(0x26) & 0x8000)
  576. {
  577. z -= 0.01;
  578. //xspin = 180; //++;//; = 180;
  579. //yspin = 0;
  580. //zspin = 180;
  581. //zspin = 180;
  582. if(intersectWalls()) z += 0.01;
  583. //xspin = 180;
  584.  
  585. }
  586. if (GetAsyncKeyState(0x28) & 0x8000)
  587. {
  588. z += 0.01;
  589. if(intersectWalls()) z -= 0.01;
  590. //xspin = 0;
  591. //yspin = 0;
  592. //zspin = 0;
  593. }
  594. }
  595.  
  596. void init() {
  597. glEnable(GL_DEPTH_TEST);
  598. //glEnable(GL_BLEND);
  599. glMatrixMode(GL_PROJECTION);
  600. glLoadIdentity();
  601. //glOrtho(-0.5, 0.5, -0.5, 0.5, -5, 5);
  602. gluPerspective(30.0, 4.0 / 3.0 , 0.5, MSIZE + 1);
  603. glMatrixMode(GL_MODELVIEW);
  604. //glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
  605. glLoadIdentity();
  606. //makedense(-500.0, -500.0, -500.0, 1000.0, 1000.0, 1000.0,
  607. // -500.0, -500.0, -500.0, 1000.0, 1000.0, 1000.0);
  608.  
  609. glEnable(GL_FOG);
  610. {
  611. GLint fogMode;
  612. GLfloat fogColor[4] = {0.0, 0.0, 0.0, 1.0};
  613.  
  614. fogMode = GL_EXP;
  615. glFogi(GL_FOG_MODE, fogMode);
  616. glFogfv(GL_FOG_COLOR, fogColor);
  617. glFogf(GL_FOG_DENSITY, 0.5);
  618. glHint(GL_FOG_HINT, GL_DONT_CARE);
  619. glFogf(GL_FOG_START, 1.0);
  620. glFogf(GL_FOG_END, 10.0);
  621. }
  622. glClearColor(0.0, 0.0, 0.0, 1.0);
  623. }
  624.  
  625. /*int main(int argc, char **argv)
  626. {
  627. //srand(time(NULL));
  628. glutInit(&argc, argv);
  629. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  630. glutInitWindowSize(800, 600);
  631. glutInitWindowPosition(100, 100);
  632. glutCreateWindow("Paul is so awesome you are freaking out");
  633. init();
  634. glutDisplayFunc(display);
  635. glutIdleFunc(keyboard);
  636. //glutMouseFunc(mouse);
  637. glutMainLoop();
  638. return 0;
  639. }*/
  640.  
  641. int main(int argc, char *argv[])
  642. {
  643.  
  644. CSSet conn;
  645.  
  646. srand(time(NULL));
  647.  
  648. for(int x=0;x<MSIZE;x++)
  649. {
  650. for(int y=0;y<MSIZE;++y)
  651. {
  652. for(int z=0;z<MSIZE;++z)
  653. {
  654. Cell cell;
  655. cell.x = x;
  656. cell.y = y;
  657. cell.z = z;
  658. if (cell.x == 0){
  659. CellSet edge;
  660. Cell cell2 = cell;
  661. cell2.x = -1;
  662. edge.merge(CellSet(cell));
  663. edge.merge(CellSet(cell2));
  664. walls.merge(CSSet(edge));
  665. }
  666. else if (cell.x == MSIZE-1){
  667. CellSet edge;
  668. Cell cell2 = cell;
  669. cell2.x = MSIZE;
  670. edge.merge(CellSet(cell));
  671. edge.merge(CellSet(cell2));
  672. walls.merge(CSSet(edge));
  673. }
  674. if (cell.y == 0){
  675. CellSet edge;
  676. Cell cell2 = cell;
  677. cell2.y = -1;
  678. edge.merge(CellSet(cell));
  679. edge.merge(CellSet(cell2));
  680. walls.merge(CSSet(edge));
  681. }
  682. else if (cell.y == MSIZE-1){
  683. CellSet edge;
  684. Cell cell2 = cell;
  685. cell2.y = MSIZE;
  686. edge.merge(CellSet(cell));
  687. edge.merge(CellSet(cell2));
  688. walls.merge(CSSet(edge));
  689. }
  690. if (cell.z == 0){
  691. CellSet edge;
  692. Cell cell2 = cell;
  693. cell2.z = -1;
  694. edge.merge(CellSet(cell));
  695. edge.merge(CellSet(cell2));
  696. walls.merge(CSSet(edge));
  697. }
  698. else if (cell.z == MSIZE-1){
  699. CellSet edge;
  700. Cell cell2 = cell;
  701. cell2.z = MSIZE;
  702. edge.merge(CellSet(cell));
  703. edge.merge(CellSet(cell2));
  704. walls.merge(CSSet(edge));
  705. }
  706. //if (cell.x)
  707. maze.merge(CellSet(cell));
  708. CellSet initial(cell);
  709. conn.merge(CSSet(initial));
  710. }
  711. }
  712. }
  713.  
  714. for(CLIST::iterator i = maze.set.begin();i!=maze.set.end(); ++i)
  715. {
  716. for(CLIST::iterator j =maze.set.begin(); j!=maze.set.end(); ++j)
  717. {
  718. if((*i).adjacent(*j)) {
  719. CellSet edge;
  720. edge.merge(CellSet(*i));
  721. edge.merge(CellSet(*j));
  722. walls.merge(CSSet(edge));
  723. }
  724. }
  725. }
  726.  
  727. while(conn.set.size()>1)
  728. {
  729. int _size = conn.set.size();
  730. int i = rand()%walls.set.size();
  731. CSSet wallset;
  732. CSLIST::iterator wall = walls.get(i);
  733. CSLIST::iterator cset = conn.set.begin();
  734.  
  735. while(cset!=conn.set.end()) {
  736. for (CLIST::iterator j=(*wall).set.begin(); j !=(*wall).set.end(); ++j)
  737. {
  738. if( (*cset).member(*j)) {
  739. wallset.merge(CSSet(*cset));
  740. }
  741. }
  742. ++cset;
  743. }
  744. if (wallset.set.size() > 1) {
  745. conn.difference(wallset);
  746. CellSet merged;
  747. for (CSLIST::iterator j=wallset.set.begin(); j != wallset.set.end(); ++j)
  748. {
  749. merged.merge(*j);
  750. }
  751. conn.merge(CSSet(merged));
  752.  
  753. walls.difference(CSSet(*wall));
  754. }
  755. if (conn.set.size() != _size) { cout << conn.set.size() << endl;}
  756.  
  757. }
  758.  
  759. glutInit(&argc, argv);
  760. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
  761. glutInitWindowSize(800, 600);
  762. glutInitWindowPosition(100, 100);
  763. glutCreateWindow("Paul is so awesome you are freaking out");
  764. init();
  765. glutDisplayFunc(display);
  766. glutIdleFunc(keyboard);
  767. //glutMouseFunc(mouse);
  768. glutMainLoop();
  769. return 0;
  770. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
koolman123 is offline Offline
8 posts
since Sep 2010
Sep 3rd, 2010
0
Re: OpenGL help
GLUT is a layer on top of OpenGL - http://www.opengl.org/resources/libraries/glut/

If you just want to post code an don't have a question about it, I'd put it here: http://www.daniweb.com/code/forum8.html
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
Sep 3rd, 2010
0
Re: OpenGL help
All it does is draw a teapot?! so whats the point here?
Reputation Points: 62
Solved Threads: 27
Posting Whiz in Training
Kanoisa is offline Offline
216 posts
since Jul 2008
Sep 3rd, 2010
0
Re: OpenGL help
No, I have a question.

Read the post it says I want to know what version of OpenGL uses that header.

Don't jump to conclusions.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
koolman123 is offline Offline
8 posts
since Sep 2010
Sep 4th, 2010
0
Re: OpenGL help
I didn't jump to conclusions. I read the 1 line about your question and then answered it. Then I saw your 800 lines of code and thought that it belonged in the code snippets section.
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC