Silverfrost Forums

Welcome to our forums

Simple OpenGL Program

19 Jun 2018 5:34 #22230

Totally Frustrated, using Win 10 and Fortran to Opengl calls, output 'crazy': PROGRAM BASIC INCLUDE <clearwin.ins>,nolist INCLUDE <opengl.ins>,nolist DIMENSION X(N),Y(N),Z(N) INTEGER ctrl X=0. Y=0. Z=0. i=winio@('%es%ca[Simple Opengl Sample]&') i=winio@('%sp%ww[no border]%og[static]%1w', * 0, 0, 1000, 1000, ctrl) CALL glBegin(GL_LINES) CALL glRotatef(22.0,1.0,0.0,0.0) CALL glRotatef(22.0,0.0,1.0,0.0) CALL glRotatef(22.0,0.0,0.0,1.0) INDX=0 DO 10 I=1,7 INDX=INDX+1 IF (INDX .EQ. N) GOTO 20 CALL glVertex3f(X(INDX),Y(INDX),Z(INDX)) CALL glVertex3f(X(INDX+1),Y(INDX+1),Z(INDX+1)) 10 CONTINUE 20 CALL glEnd END

Note: N in above was 8, tried to submit and it entered a emoticon? No matter what I change the glRotate commands to, get the same thing, a vertical and a horizontal line on the output, no Z axis and had addition curve date yet did not plot the curve. Have this identical program in C++ works great??? How Simple can one get??? Anyone have ideas? Sid Kraft

19 Jun 2018 7:32 #22231

I have not tested your program but a quick glance shows %1w instead of %lw.

19 Jun 2018 11:27 #22232

John Silver: I left out 3 statements by mistake where I set the input values to 1.: after the below which set the values all to zero for the complete arrays: x=0. y=0. z=0. should have been additional codes:

x(2)=1. y(4)=1. z(6)=1. this should have drawn the x,y,z axes but after changing the 1 to l, still did not work! Sid

21 Jun 2018 12:29 #22247

So Frustrated with this system, cannot post a screen shot so have to type in every line of code and other statements whenever I want to ask question ! BOO bad system!

I finally got the above program to work but there appears to be a memory management problem with the Fortran to OpenGL callable system, the minute that I add more code to above, I get 'crazy' output data from OpenGL, zig zag lines all over the place. I would suggest exploring this problem as is not good for the system to act this way, Sid kraft

21 Jun 2018 1:09 #22249

stfark1, did you look at the opengl examples in ftn95 documentation? (use ftn95 /help)

https://i.imgur.com/DY0yCet.png

      PROGRAM Simple
      INCLUDE <clearwin.ins>,nolist
      INCLUDE <opengl.ins>,nolist
      REAL t1,t2
      INTEGER i, ctrl
      i=winio@('%es%ca[Simple OpengGL Sample]&')
      i=winio@('%sp%ww[no_border]%og[static]%lw',
     *         0, 0, 500, 500, ctrl)
      CALL glClearColor (0.0, 0.0, 0.0, 0.0)
      CALL glClear(GL_COLOR_BUFFER_BIT)
      CALL glColor3f(1.0, 1.0, 1.0)
      CALL glMatrixMode(GL_PROJECTION)
      CALL glLoadIdentity()
      CALL glOrtho(-1d0, 1d0, -1d0, 1d0, -1d0, 1d0)
      CALL glBegin(GL_POLYGON)     
C
      CALL glColor3f(1.0,0.0,0.0)
      CALL glVertex2f(-0.5, -0.5)
C      
      CALL glColor3f(0.0,1.0,0.0)
      CALL glVertex2f(-0.5, 0.5)
C
      CALL glColor3f(0.0,0.0,1.0)      
      CALL glVertex2f( 0.5, 0.5)
C
      CALL glColor3f(1.0,0.0,0.0)      
      CALL glVertex2f( 0.5, -0.5)
      CALL glEnd()
      CALL glFlush()
      END

There is also another opengl example which shows you some rotations. In general, I prefer to use SCC, because in the internet more useful examples are written in C++.

First you should read some simple opengl manuals and understand how opengl works in the basic structure. Your main code has some basic fortran errors... Dimension N unknown, X,Y,Z initialized incorrectly... and some basic opengl calls are missing...

Please login to reply.