OpenGl NeHe 5 and Fonts (rotate)

Started by Frank Brübach, July 14, 2024, 10:30:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach



Here's a little oxygen Basic openGL example Like NeHe 5 basically example but included Fonts with Rotation too


'
' -- openGL example pyramid + cube, nehe 5 by frank bruebach, 22-10-2023, 14-07-2024
  ' -- oxygenbasic, with fonts
  '
  'includepath "$\inc\"
  $ FileName "testOpglNehe5.exe"
  'include  "RTL32.inc"
  'include  "RTL64.inc"
  $ title    "Rotating cube + pyramid (nehe 5) + fonts"
  $ fontA =  "Arial",FW_SEMIBOLD

  int width=640
  int height=480
  uses OpenglSceneFrame.inc

  sub Initialize(sys hWnd)
  '=======================
  end sub
  '

  procedure drawPyramid() 'test
  =======================
  static single ang1,angi1
  static single framecounter

  framecounter++
  gltranslatef -0.5,0.5,-1
  glrotatef angi1,0.0,1.0,0.0
  'glscalef    0.01,0.01,0.01
  glscalef    1.5,1.5,1.5
  glBegin GL_TRIANGLE_FAN
    glColor3f  0, 128, 255 : glVertex3i  0.0,  1.0,  0.0
    glColor3f 255,  0,  0 : glVertex3i -1.0, -1.0,  1.0
    glColor3f 255, 255, 255 : glVertex3i  1.0, -1.0,  1.0
    glColor3f  0,  0, 255 : glVertex3i  1.0, -1.0, -1.0
    glColor3f  0, 255,  0 : glVertex3i -1.0, -1.0, -1.0
    glColor3f 255,  0,  0 : glVertex3i -1.0, -1.0,  1.0
  glEnd
  angi1 += 180.0/framecounter
end procedure

  sub Scene(sys hWnd)
  '==================
  '
  static single ang1,angi1=1
  '
  NewFrame
  glClearColor 0.5, 0.5, 0.7, 0.0
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  Fog          0.5, 0.5, 0.7, 0.05 'rgb and density
 
  glLoadIdentity
  gltranslatef    -1.0, -1.0, -8.0 '-6.0
  glrotatef ang1, 0.0, 0.0,  1.0
  '
  ''glBegin GL_TRIANGLES
  ''glColor3f  1.0, 0.0, 0.0 : glVertex3f  0.0,  1.0, 0.0
  ''glColor3f  0.0, 1.0, 0.0 : glVertex3f  -1.0, -1.0, 0.0
  ''glColor3f  0.0, 0.0, 1.0 : glVertex3f  1.0, -1.0, 0.0
  ''glEnd

    glLoadIdentity
    gltranslatef    2.0, 0.0, -6.0
    glscalef 0.75,0.75,0.75
    glrotatef ang1, 0.0, 1.0,  1.0
   
  glBegin GL_QUADS          ' Drawing using Quads
    ' Top Quad
    glColor3f 0, 255, 0          ' Green   
    glVertex3f  1.0,  1.0, -1.0  ' Top Right
    glVertex3f -1.0,  1.0, -1.0  ' Top Left
    glVertex3f -1.0,  1.0,  1.0  ' Bottom Left
    glVertex3f  1.0,  1.0,  1.0  ' Bottom Right

    ' Bottom Quad
    glColor3f 255, 127, 0        ' Orange   
    glVertex3f  1.0, -1.0,  1.0  ' Top Right
    glVertex3f -1.0, -1.0,  1.0  ' Top left
    glVertex3f -1.0, -1.0, -1.0  ' Bottom Left
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Right

    ' Front Quad
    glColor3f 255, 0, 0          ' Red   
    glVertex3f  1.0,  1.0,  1.0  ' Top Right
    glVertex3f -1.0,  1.0,  1.0  ' Top Left
    glVertex3f -1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f  1.0, -1.0,  1.0  ' Bottom Right

    ' Back Quad
    glColor3f 255, 255, 0        ' Yellow
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Left
    glVertex3f -1.0, -1.0, -1.0  ' Bottom Right
    glVertex3f -1.0,  1.0, -1.0  ' Top Right
    glVertex3f  1.0,  1.0, -1.0  ' Top Left
   
    ' Left Quad
    glColor3f 0, 0, 255          ' Blue
    glVertex3f -1.0,  1.0, -1.0  ' Top Right
    glVertex3f -1.0, -1.0, -1.0  ' Top Left
    glVertex3f -1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f -1.0,  1.0,  1.0  ' Bottom Right
   
    ' Right Quad
    glColor3f 255, 0, 255        ' Violet
    glVertex3f  1.0,  1.0, -1.0  ' Top Right
    glVertex3f  1.0,  1.0,  1.0  ' Top Left
    glVertex3f  1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Right
 
  glEnd
 
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  glLoadIdentity
  gltranslatef    -1.0, 0.0, -6.0 '-4.0
 
  drawpyramid()
'---------------- //
  glPushMatrix
  '
  glLoadIdentity
  static int framecount
  sys x,y
  framecount++
  gltranslatef -.5,.25,-4.0
  'glColor3f    .99,.50,.50
  glColor3f    .99,.20,.20
  glscalef     .2,.2,.01
  gprint       str(framecount)
  '
  glpopmatrix

  glpushMatrix
  'glClearColor 0.8, 0.3, 0.5, 0
  glscalef     .2,.2,.01
  glRotatef 90.0,0,0,1
  gprint "Hello Oxygen OpenGL"
  glPopMatrix

  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  glLoadIdentity
  glpushMatrix
  gltranslatef    2.0, 0.0, -4.0
  'glClearColor 0.8, 0.3, 0.5, 0
  glscalef     .2,.2,.01
  glRotatef 90.0,0,0,1
  gprint "Hello nehe 5 example"
  glPopMatrix


  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub

  sub Release(sys hwnd)
  '====================
  end sub