Author Topic: Some Problems  (Read 2727 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Some Problems
« on: November 20, 2010, 01:42:16 PM »
Deleted
« Last Edit: May 05, 2015, 12:47:14 PM by Peter »

Charles Pegge

  • Guest
Re: Some Problems
« Reply #1 on: November 21, 2010, 01:47:09 AM »
Hi Peter,

I've marked up the fixes.

the glut callback functions must be marked callback or external

pkey must be masked to 8 bits to obtain ascii codes.

low level bound functions (without prototypes) will not take expressions as parameters.

But I would not spend too long with GLUT. The full Opengl gives you far more control and flexibility.
You are welcome to borrow any code from my OpenglView Demos if it helps save time. :)

Charles


Code: [Select]

Declare Sub ExitProcess Lib "kernel32.dll" (ByVal uExitCode As Long)

% GL_QUADS     = &H0007
% GL_LINES     = &H0001
% GLUT_DOUBLE  = 2
% GLUT_RGBA    = 0

Dim ogl32,glut32,kernel32 as long

ogl32    = LoadLibrary "opengl32.dll"
glut32   = LoadLibrary "glut32.dll"
kernel32 = LoadLibrary "kernel32.dll"

Bind glut32
(
  glutInitWindowPosition glutInitWindowPosition
  glutInitDisplayMode    glutInitDisplayMode
  glutInitWindowSize     glutInitWindowSize
  glutCreateWindow       glutCreateWindow
  glutKeyboardFunc       glutKeyboardFunc
  glutDisplayFunc        glutDisplayFunc
  glutMainLoop           glutMainLoop
  glutSwapBuffers        glutSwapBuffers
  glutDestroyWindow      glutDestroyWindow
  glutMainLoop           glutMainLoop
)

Bind ogl32
(
  glClearColor   glClearColor
  glBegin        glBegin
  glEnd          glEnd
  glColor3f      glColor3f
  glVertex3f     glVertex3f
  glVertex2f     glVertex2f
  glLineWidth    glLineWidth
)


StackPointer=esp


Function Key(byval pkey as long, byval x as long, byval y as long) callback 'must be byval
 k=pkey and 255
 'print hex pkey
iF k =27 Or K =32   /* Escape / Space bar */
 ExitProcess 0
End iF
End Function

Function Draw() callback
glClearColor 0.0, 0.0, 0.0, 0.0
glBegin (GL_QUADS)
  glColor3f (1.0, 0.0, 0.0): glVertex2f ( 1.0, 1.0)
  glColor3f (0.0, 1.0, 0.0): glVertex2f (-1.0, 1.0)
  glColor3f (0.0, 0.0, 1.0): glVertex2f (-1.0,-1.0)
  glColor3f (1.0, 1.0, 1.0): glVertex2f ( 1.0,-1.0)
glEnd
glLineWidth 2.5
glColor3f(0.5, 1.0, 0.0)
glBegin(GL_LINES)
  glVertex2f(-1.0, 0.0 )
  glVertex2f( 1.0, 0.0 )
  glVertex2f( 0.0, -1.0)
  glVertex2f( 0.0, 1.0 )
glEnd
glutSwapBuffers    
End Function

A = GLUT_DOUBLE | GLUT_RGBA   /* bad solution! */
glutInitDisplayMode (A)       /* GLUT_SINGLE | GLUT_RGBA  <--- doesn't go! - low level binding does not take expressions*/
glutInitWindowPosition 320,240
glutInitWindowSize 640,480
glutCreateWindow ("Colour")
glutDisplayFunc  &Draw ' must be a callback function
glutKeyboardFunc &Key           /* <--- compiler error! - key(..) must be a callback function */      
glutMainLoop
              
/*Attention:
a click of the window close button [X] want not close this application!
program is still running in the task!
*/
« Last Edit: November 21, 2010, 01:54:00 AM by Charles Pegge »