Simulating motion and zoom with opengl Tao framework vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • braveheartkenya
    New Member
    • Feb 2008
    • 1

    Simulating motion and zoom with opengl Tao framework vb.net

    Hi,

    I'm new to openGL programming. I'm trying to simulate motion and zooming in and out in an SimpleOpenGLCon trol from the Tao Framework. <So you'll need to install the framework and put in a reference in Visual Studio to 'Tao' in order to test my code>

    I've just begun trying to move an object up and down, but i can't seem to get the object to move. i know i'm missing something but i can't figure it out. I think it has to do with loading the transformed coordinates into a new buffer and displaying the contents from the buffer... but i don't know how to do that.

    Here's my code:
    [code=vbnet]
    Imports Tao.OpenGl
    Imports Tao.Platform
    Imports Tao.FreeGlut

    Public Class frmMainWin

    Dim xTrans, yTrans, zTrans As Single

    Private Sub frmMainWin_Load (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
    myGlWindow.Init ializeContexts( )
    myGlWindow.Auto SwapBuffers = True

    'init glwindow
    Gl.glClearColor (0.0F, 0.0F, 0.0F, 0.0F)

    'Glu.gluLookAt(
    Gl.glViewport(0 , 0, 400, 300)
    Gl.glMatrixMode (Gl.GL_PROJECTI ON)
    Gl.glLoadIdenti ty()

    Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -10.0, 10.0)
    Gl.glMatrixMode (Gl.GL_MODELVIE W)
    Gl.glLoadIdenti ty()

    xTrans = 0
    yTrans = 0
    zTrans = 0

    End Sub

    Private Sub myGlWindow_Pain t(ByVal sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles myGlWindow.Pain t
    Gl.glClear(Gl.G L_COLOR_BUFFER_ BIT)

    Gl.glColor3f(0. 2F, 0.2F, 0.8F)

    'Gl.glTranslate f(0.0F, 0.0F, 0.0F)
    Gl.glTranslatef (xTrans, yTrans, zTrans)
    Gl.glBegin(Gl.G L_TRIANGLES) 'Draw a triangle
    Gl.glVertex3f(0 .5F, 1.0F, 0.0F)
    Gl.glVertex3f(0 .0F, 0.0F, 0.0F)
    Gl.glVertex3f(1 .0F, 0.0F, 0.0F)
    Gl.glEnd()

    End Sub

    Private Sub cmdUp_Click(ByV al sender As System.Object, ByVal e As System.EventArg s) Handles cmdUp.Click
    'MsgBox("up")
    yTrans = yTrans + 1

    myGlWindow.Swap Buffers()

    End Sub
    End Class
    [/code]

    Any help would be greatly appreciated.
    Thanks
    Last edited by debasisdas; Feb 25 '08, 04:24 AM. Reason: added code=vbnet tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET forum.

    Comment

    Working...