braveheartkenya
February 24th, 2008, 10:57 AM
Hi,
I'm new to openGL programming. I'm trying to simulate motion and zooming in and out in an SimpleOpenGLControl 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>
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.EventArgs) Handles MyBase.Load
myGlWindow.InitializeContexts()
myGlWindow.AutoSwapBuffers = 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_PROJECTION)
Gl.glLoadIdentity()
Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -10.0, 10.0)
Gl.glMatrixMode(Gl.GL_MODELVIEW)
Gl.glLoadIdentity()
xTrans = 0
yTrans = 0
zTrans = 0
End Sub
Private Sub myGlWindow_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles myGlWindow.Paint
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT)
Gl.glColor3f(0.2F, 0.2F, 0.8F)
'Gl.glTranslatef(0.0F, 0.0F, 0.0F)
Gl.glTranslatef(xTrans, yTrans, zTrans)
Gl.glBegin(Gl.GL_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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUp.Click
'MsgBox("up")
yTrans = yTrans + 1
myGlWindow.SwapBuffers()
End Sub
End Class
</code>
Any help would be greatly appreciated.
Thanks
P.S. i've tried to attach the whole project but it refused... so i'll try again later
I'm new to openGL programming. I'm trying to simulate motion and zooming in and out in an SimpleOpenGLControl 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>
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.EventArgs) Handles MyBase.Load
myGlWindow.InitializeContexts()
myGlWindow.AutoSwapBuffers = 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_PROJECTION)
Gl.glLoadIdentity()
Gl.glOrtho(0.0, 10.0, 0.0, 10.0, -10.0, 10.0)
Gl.glMatrixMode(Gl.GL_MODELVIEW)
Gl.glLoadIdentity()
xTrans = 0
yTrans = 0
zTrans = 0
End Sub
Private Sub myGlWindow_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles myGlWindow.Paint
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT)
Gl.glColor3f(0.2F, 0.2F, 0.8F)
'Gl.glTranslatef(0.0F, 0.0F, 0.0F)
Gl.glTranslatef(xTrans, yTrans, zTrans)
Gl.glBegin(Gl.GL_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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUp.Click
'MsgBox("up")
yTrans = yTrans + 1
myGlWindow.SwapBuffers()
End Sub
End Class
</code>
Any help would be greatly appreciated.
Thanks
P.S. i've tried to attach the whole project but it refused... so i'll try again later