On Dec 15, 2006, at 9:03 PM, David Dunham wrote: On 15 Dec 2006, at 20:39, Adam wrote:
"invalid types 'GLfloat[7][14][GLfloat]' for array subscript"
I know this has OpenGL code in it, but this isn't GL-specific, so I felt that these lists are more appropriate for this question.
This list is for the use of the Xcode development system, not really for specific development questions. (Those belong on Carbon or mac- games-dev or similar lists.)
But I'll take a stab at yours: you're using a floating point variable for an index. This isn't good C practice. Change your GLfloat to "int" and you'll probably get a happier result. (What would arr_tetris_screen[0.5][1.3] represent?)
David Dunham A Sharp, LLC "People seem to misinterpret complexity as sophistication" -- Niklaus Wirth
Whoops. I didn't know about the carbon list. I'll remember that in the future. See below for more...
On Dec 15, 2006, at 9:02 PM, Chris Espinosa wrote:
On Dec 15, 2006, at 8:39 PM, Adam wrote: void redisplay(){ for (GLfloat redisp = 0; redisp <= 7; redisp ++) { for (GLfloat redisp2 = 0; redisp2 <= 14; redisp ++) { switch (arr_tetris_screen [redisp] [redisp2]) { case box: { glBegin(GL_QUADS); glColor3f(1.0, 0.0, 0.0); glVertex3f(redisp+1, redisp2+1, 0.0); glVertex3f(redisp, redisp2+1, 0.0); glVertex3f(redisp, redisp2+1, 0.0); glVertex3f(redisp, redisp2, 0.0); } default: exit(1234); } } } glutPostRedisplay(); }
This gives me two errors: "jam exited with exit code 1" "invalid types 'GLfloat[7][14][GLfloat]' for array subscript"
I know this has OpenGL code in it, but this isn't GL-specific, so I felt that these lists are more appropriate for this question. You should probably use integers, rather than floating-point values, for the array indicies, and for the array content as well. The compiler does not like to index into arrays using floats.
Chris
Thank you both for your help. It works now. I will subscribe to the Carbon or Cocoa list (when I find one) and remember to use that next time. Thank you both again.
All help is appreciated and thanks in advance.
~ < [ / Adam-o \ ] > ~
+-------------------------------------------+ | My computer's Stats | | Mac OS 10.4.8 | | 1 Ghz Apple Powerbook G4 | | Xcode v. 2.4.1 | +-------------------------------------------+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please keep your posts straight and to the point. Also please comment the code you use as I am still learning OpenGL and Xcode and may not yet understand the meaning of the command. Thank you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|