
Why even if I change the Ortho and view port I can't see farther than a cube of 1x1x1 ?
Posted Saturday, 9 June, 2012 - 18:07 by dolfuz inHello, I hope some one can help me.
I'm using VB and I have this code in different functions but essentially is all the code:
Private Sub SetupViewport() Dim w As Integer = GlControl1.Width 'Getting width and height to configure the view port and ortho Dim h As Integer = GlControl1.Height GL.MatrixMode(MatrixMode.Projection) 'All the transformations will be applied to the projection GL.Ortho(0, 0, w, h, 1, -1) 'Configuring the ortho and view port GL.Viewport(0, 0, w - 10, h - 10) GL.MatrixMode(MatrixMode.Modelview) 'All transformation will be applied to the model GL.LoadIdentity() End Sub '---------------------------------------- Private Sub GlControl1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles GlControl1.Paint If Not clsBol_load Then Return End If GL.Clear(ClearBufferMask.ColorBufferBit Or ClearBufferMask.DepthBufferBit) 'Clearing the visual control SetupViewport() ' Initialize the ortho and view port GL.Begin(BeginMode.Lines) 'Staring to make the models using Lines to draw lines GL.Color3(Color.Yellow) 'The line will be painted in yellow 'The line will go from 0,0,0 to 2,2,2. Because BeginMode is lines, each two Vertex OpenTK will paint GL.Vertex3(0.0F, 0.0F, 0.0F) 'Using Vertex3 to put coordenades in 3 dimentions GL.Vertex3(2.0F, 2.0F, 2.0F) GL.Color3(Color.Blue) 'Changing the nex line to blue GL.Vertex3(1.0F, 1.0F, 1.0F) 'The line 2 will start from 1,1,1 and end in 2, 2, 2 GL.Vertex3(2.0F, 2.0F, 2.0F) GL.End() 'Finishing drawing for the control GlControl1.SwapBuffers() 'After calling swapBuffers the control will paint the lines End Sub
This code only displays part of the yellow line (the part from 0 to 1) :(
Even when I change all the parameters of the ortho or viewport I can't make OpenTK displays the 2nd line (the blue one) that's outside the 1X1X1 cube displayed in this code.
Can anyone please help me to know why I cant see other blue line?
Thanks so much for your help!


Comments
Re: Why even if I change the Ortho and view port I can't ...
Im making some dirty tricks to view all my model.
Im using the GL.Scale function in order to see the model, but I know there most be a better way to see all the model without scaling it.
Can anyone help me?
Thanks so much!
Re: Why even if I change the Ortho and view port I can't ...
I think the problem is this line:
GL.Ortho(0, 0, w, h, 1, -1)Try setting you clipping planes to other values.
eg:
GL.Ortho(0, 0, w, h, 0.0f, 100.0f)Also your clipping distances shoudn't have different signs.
When you've done this, you'll have to put your camera bit away from 0,0,0 to be able to see the object.
see:
http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml
Re: Why even if I change the Ortho and view port I can't ...
You've also got your GL.Ortho parameters in the wrong order, I think (should be left, right, bottom, top, near, far; not left, bottom, right, top, near, far); in fact, I believe you should be generating an error (your left and right parameters are the same), and OpenGL is actually ignoring your GL.Ortho call.