PDA

View Full Version : Problems with OpenGL and Fortran



Vinícius Reis
03-03-2005, 09:47 AM
I'm using OpenGL with Fortran and trying to use the "glDrawArrays" command, but I can’t get through it, it's generating an runtime error. What I could do was to read manually and then draw the arrays. Here are the codes:


CALL glEnableClientState(GL_VERTEX_ARRAY)
CALL glEnableClientState(GL_COLOR_ARRAY)
CALL glVertexPointer(2,GLfloat,0,Graf_Vertices)
CALL glColorPointer(3,GLfloat,0,Graf_Cor)
CALL glDrawArrays(GL_TRIANGLE_STRIP,1,n_vertices)
What is working is:


CALL glBegin(GL_TRIANGLE_STRIP)
DO cont=1,n_vertices
x=Graf_Vertices(2*cont)
y=Graf_Vertices(2*cont-1)
r=Graf_Cor(3*cont-2)
g=Graf_Cor(3*cont-1)
b=Graf_Cor(3*cont)
CALL glColor3f(r,g,b)
CALL glVertex2f(x,y)
END DO
CALL glEnd
Would somebody help me out with it?

Gratefull,
Vinícius

Vinícius Reis
03-03-2005, 10:13 AM
I forgot to say, the arrays were dimentioned as follow:



n_vertices=(m-1)*2*n
ALLOCATE(Graf_Vertices(2*n_vertices))
ALLOCATE(Graf_Cor(3*n_vertices))

147-2
03-03-2005, 03:59 PM
I doubt you'll find anybody else who programs fortan, and in truth, I don't either... But I am willing to venture a guess...

The first thing that popped into my mind while reading that was memory organization. Maybe you need to see if there's any padding that you're not expecting, that happens sometimes, especially with old compilers or programming languages which typically expect you (the programmer) not to really care exactly where particular numbers are. If it works without arrays, and bugs out with arrays, I can't imagine it being anything else.

Vinícius Reis
03-15-2005, 06:35 AM
Thank you very much for your help! I discovered what the problem was! It was a bug between the computer and the chair! I just had to change GLfloat, witch is a kind declaration, for GL_FLOAT that’s the real parameter to a subroutine.