Click to See Complete Forum and Search --> : OpenGL, Tao framework , VB.NET Simulating motion & zooming


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

mejlango
August 17th, 2008, 07:50 AM
Hi,

I found some good tutorial about OpenGL, it is for C#, but maybe it will help you:

http://www.taumuon.co.uk/jabuka/index.html
http://www.taumuon.co.uk/jabuka/Tutorial1/Tutorial1_v4.pdf

There is shown how to override "OnPaint" and there is also a introduction to animation.