Author Topic: OpenGL rotated quad  (Read 258 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
OpenGL rotated quad
« on: April 13, 2018, 05:46:41 AM »
Hello

i'm having problems when i modified the QuadRotate.o2bas  example code to draw cube and diamond
and the results are just  blank screens.

can someone help me on this, the code is listed below
Code: [Select]
  includepath "$\inc\"
  $ FileName  "QuadRotate.exe"
  'include    "RTL32.inc"
  include    "RTL64.inc"
  $ title     "Rotating Quad"
  include     "OpenglSceneFrame.inc"


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

 


  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1,angi1=1
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
'  glClearColor 0.5, 0, 0, 0
  glClearColor 1.1,.5,0,1
  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1
  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend

'  draw triangle fan  -- does NOT work
     glBegin  GL_QUADS 
         glcolor3ub 0,255,0   : glvertex2f  0,2  '1st triangle
         glcolor3ub 255,0,255 : glvertex2f  -2,0
         glcolor3ub 0,255,255 : glvertex2f  -1,-1
         glcolor3ub 128,0,255 : glvertex2f  0,-0.8 '2nd
         glcolor3ub 255,128,0 : glvertex2f  2,-1.1 '3rd
         glcolor3ub 255,128,0 : glvertex2f  3,0    '4th
      glEnd



' Draw cube  -- does NOT work
  ' glBegin  GL_QUADS
    '   glcolor3ub 255,0,0
    '   glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
    '   glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
    '   glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
    '   glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

  '     glcolor3ub 255,255,0
    '   glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
     '  glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

   '    glcolor3ub 255,0,255
   '    glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
    '   glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
     '  glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
    '   glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
     '  glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

     '  glcolor3ub 0,255,255
     '  glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
     '  glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
     '  glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
    '   glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
    '   glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
   ' glEnd



  ' DrawDiamond   -- does NOT work
'glbegin GL_QUADS
  '     glcolor3ub 255,   0,   0 : glvertex3f  0, .1414, 0
    '      glcolor3ub   0, 255,   0 : glvertex3f  .1, 0, 1
  '        glcolor3ub   0,   0, 255 : glvertex3f  .1, 0,-1
  '        glcolor3ub   0, 255,   0 : glvertex3f -.1, 0,-1
  '        glcolor3ub   0,   0, 255 : glvertex3f -.1, 0, 1
  '        glcolor3ub   0, 255,   0 : glvertex3f  .1, 0, 1
  '     glend
  '    glbegin GL_QUADS
  '        glcolor3ub 255,   0,   0 : glvertex3f  0,-.1414, 0
  '        glcolor3ub   0, 255,   0 : glvertex3f  .1, 0, 1
   '       glcolor3ub   0,   0, 255 : glvertex3f -.1, 0, 1
 '         glcolor3ub   0, 255,   0 : glvertex3f -.1, 0,-1
 '         glcolor3ub   0,   0, 255 : glvertex3f  .1, 0,-1
 '         glcolor3ub   0, 255,   0 : glvertex3f  .1, 0, 1
  '     glend


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


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



chrisc

  • Guest
Re: OpenGL rotated quad
« Reply #1 on: April 13, 2018, 05:49:49 AM »

also what are the equivalent equates for  PB equates in O2 ?

i only found GL_QUADS in O2

Code: [Select]
gl_triangle_fan

gl_triangles

gl_quad_strip

chrisc

  • Guest
Re: OpenGL rotated quad
« Reply #2 on: April 14, 2018, 07:14:07 AM »
Hello
can someone help me on this?

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1855
Re: OpenGL rotated quad
« Reply #3 on: April 14, 2018, 08:48:26 AM »
#define GL_TRIANGLES    0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP   0x0008


OxygenBasic is able to read C header files directly without conversion.

Khronos OpenGLŪ Registry
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3194
Re: OpenGL rotated quad
« Reply #4 on: April 14, 2018, 10:20:41 AM »
Quote
OxygenBasic is able to read C header files directly without conversion.

A powerful feature not mentioned enough on this forum.

@Charles,

Can I use C header files with DLLC and not define the API functions?
« Last Edit: April 14, 2018, 10:30:18 AM by John »

chrisc

  • Guest
Re: OpenGL rotated quad
« Reply #5 on: April 14, 2018, 02:36:44 PM »
Thanxx Mike

that's work