Simple renderer in .net with SharpGL (openGL)


Re: Simple renderer in .net with SharpGL (openGL)
#49
Yes, that is what I also thinking about. But there needs to be another thinking error. I have to check with a lot of coffee this morning Smile

Here is my current code (I see - nothing), that I now explain:
loadidentity - set the current matrix (Projection) to start modus
viewport - is the 2d window that should be used (left bottom corner at 0,0 and upper right corner from control width and height)
perspective (field of view in radian, ratio, znear, zfar) - for zfar I use two times the radius of the bounding box.
frustum (left, right, bottom, top, znear, zfar) - for left, right, bottom, top I use the radius of the bounding box, zfar like above.
Then I switch to the modelview and start with a fresh matrix.
The only transformation now is with the lookat matrix
lookat (eyex,eyey,eyez,centerx,centery,centerz,upx,upy,upz)
Code:
gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Projection)
        gl.LoadIdentity()
        gl.Viewport(0, 0, OpenGLControl2.Width, OpenGLControl2.Height)
        gl.Perspective(CDbl(fov), CDbl(OpenGLControl2.Width / OpenGLControl2.Height), CDbl(0.1), CDbl(2 * gradiusOfBoundingbox))
        gl.Frustum(CDbl(gradiusOfBoundingbox + 100), CDbl((gradiusOfBoundingbox + 100) * -1), CDbl((gradiusOfBoundingbox + 100) * -1), CDbl(gradiusOfBoundingbox + 100), CDbl(0.1), CDbl(2 * gradiusOfBoundingbox))

        gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Modelview)
        gl.LoadIdentity()

        gl.LookAt(CDbl(0), CDbl(0), CDbl(0), CDbl(0), CDbl(0), CDbl((gradiusOfBoundingbox / Math.Sin(fov / 2)) * 2), CDbl(0), CDbl(-1), CDbl(0))

        DrawLines(gl)

        gl.Flush()

Where is my error??
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Re: Simple renderer in .net with SharpGL (openGL) - by Michael Heidemann - 2013-12-07, 7:06

Forum Jump:


Users browsing this thread: 10 Guest(s)