Results 1 to 4 of 4

Thread: Problems with OpenGL and Fortran

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    18

    Problems with OpenGL and Fortran

    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:

    Code :
    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:
    Code :
    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

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    18

    Re: Problems with OpenGL and Fortran

    I forgot to say, the arrays were dimentioned as follow:

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

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    Re: Problems with OpenGL and Fortran

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    18

    Re: Problems with OpenGL and Fortran

    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.

Similar Threads

  1. Opengl Fortran Trouble
    By jamie fearon in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-21-2005, 07:35 AM
  2. Using pointer in Fortran binding for OpenGL
    By Vinícius Reis in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-11-2005, 07:41 AM
  3. How to ues opengl in fortran ?? thanks!!!
    By plasma in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-03-2003, 05:22 AM
  4. How can I use OpenGL in compaq visual fortran
    By tang in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-02-2002, 07:12 PM
  5. Visual Fortran 6.5 & OpenGL
    By Paoli in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-06-2001, 11:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean