Author Topic: [glfw / ogl] Rendering Troubles  (Read 3471 times)

0 Members and 1 Guest are viewing this topic.

Offline Storm Trooper

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
[glfw / ogl] Rendering Troubles
« on: June 23, 2011 »
Hi,

can you spot what is making this code not display the object?

thanks alot,

Code: [Select]
' compile with -lang deprecated -s gui

option static
option explicit

#include "gl/gl.bi"
#include "gl/glext.bi"
#include "gl/glfw.bi"

declare sub clear_buffer        ( byval red     as single=0.0f,_
                                  byval grn     as single=0.0f,_
                                  byval blu     as single=0.0f )
                         
declare sub graphics            ( byval title   as string,_
                                  byval wwidth  as integer,_
                                  byval height  as integer,_
                                  byval mode    as integer=0 )

declare sub init_demo()
declare sub main_demo()

declare sub render_test()

init_demo()
main_demo()


sub init_demo()
   
    graphics("glfw test",640,480,1)
   
end sub


sub main_demo()
   
    while ( glfwGetKey( GLFW_KEY_ESC )=0 )
       
        clear_buffer()
       
        render_test()
       
        glfwSwapBuffers()
   
    wend

    glfwTerminate()

end sub




sub render_test()
   
    dim as single scale_x=10.0f, scale_y=10.0f, scale_z=10.0f

    glMatrixMode( GL_MODELVIEW )
   
glLoadIdentity()

glTranslatef( 0.0f, 0.0f, -10.0f )
   
    glBegin(GL_QUADS)

glColor3f( 1.0f, 1.0f, 1.0f )

glVertex3f( -scale_x,-scale_y,-scale_z )
glVertex3f( -scale_x, scale_y,-scale_z )
glVertex3f(  scale_x, scale_y,-scale_z )
glVertex3f(  scale_x,-scale_y,-scale_z )
 
    glEnd()

end sub


sub clear_buffer( byval red as single=0.0f, byval grn as single=0.0f, byval blu as single=0.0f )
   
    glClearColor( red, grn, blu, 1.0f )
    glClear     ( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT )
   
end sub


sub graphics( byval title as string, byval wwidth as integer, byval height as integer, byval mode as integer=1 )
   
    glfwInit()
   
    if mode=1 then
        glfwOpenWindow( wwidth, height, 8,8,8,8, 32,8, GLFW_WINDOW )
    else
        glfwOpenWindow( wwidth, height, 8,8,8,8, 32,8, GLFW_FULLSCREEN )
        'glfwSwapInterval( 1 )
    end if
   
    glfwSetWindowTitle( title )
   
    glViewport      ( 0, 0, wwidth, height)     ' Reset The Current Viewport
glMatrixMode    ( GL_PROJECTION )         ' Select The Projection Matrix
glLoadIdentity  ()         ' Reset The Projection Matrix

gluPerspective  ( 45.0f, csng(wwidth/height), 0.1f, 100.0f )        ' Calculate The Aspect Ratio Of The Window.

glMatrixMode    ( GL_MODELVIEW )         ' Select The Modelview Matrix
glLoadIdentity  ()    
    glShadeModel    ( GL_SMOOTH )     ' Enables Smooth Shading
glClearColor    ( 0.0f, 0.0f, 0.0f, 0.0f )         ' Black Background
glClearDepth    ( 1.0f )     ' Depth Buffer Setup
glEnable     ( GL_DEPTH_TEST ) ' Enables Depth Testing
glDepthFunc     ( GL_LEQUAL ) ' The Type Of Depth Test To Do
glHint          ( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ' Really Nice Perspective Calculations
   
    glEnable         ( GL_CULL_FACE )                                   ' Enable Backface culling
    glPolygonMode    ( GL_FRONT, GL_FILL )
   
end sub

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [glfw / ogl] Rendering Troubles
« Reply #1 on: June 23, 2011 »
Hi,

I think you need to include glu.bi as well because you're using gluperspective.

Also the X_scale Y_scale z_Scale variables are not set.

That's where you should start looking.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [glfw / ogl] Rendering Troubles
« Reply #2 on: June 23, 2011 »
Without looking too closely: the winding of your polygon doesn't seem to be counter-clockwise and thus would get backface-culled.
Challenge Trophies Won:

Offline Storm Trooper

  • C= 64
  • **
  • Posts: 45
  • Karma: 2
    • View Profile
Re: [glfw / ogl] Rendering Troubles
« Reply #3 on: June 30, 2011 »
Thanks for the points, twas the perspective range. The scaling values are set btw.
Sorry to trouble you, but what are the correct verts u/v for the whole cube?

thankyou.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: [glfw / ogl] Rendering Troubles
« Reply #4 on: July 02, 2011 »
Challenge Trophies Won: