PDA

View Full Version : I got a hole in my sphere!



talyrond
01-09-2006, 09:15 AM
See the link for what Iím getting:

http://www.v8914.com/sphere.jpg

This is driving me round the bend! Below is the piece of code that produces the above, itís in VB .net but that should not detract from the problem.

Draw the scene:

gl.ClearColor(1, 1, 1, 0)
gl.Clear(OpenGL.gl.COLOR_BUFFER_BIT)

Dim quadric As IntPtr
quadric = glu.NewQuadric
gl.Color3f(1, 0, 0)
glu.Sphere(quadric, 1.2, 10, 10)
Me.RenderingContext.SwapBuffers()

The Resize event:

gl.Viewport(0, 0, Me.Width, Me.Width)

I know itís a sillly example but demenstrates the problem. Any thing larger than 1.0 for the radius of the sphere and the hole will start to appear. I my actual program I use gl.Ortho to do all my scaling zooming etc and I still get the problem. I am programming a 2D CAD system. I seems that gluPerspective is OK but Iím only doing 2D.

Any help would really be approciated

Talyrond

01-09-2006, 09:19 AM
It looks like toy sphere is being truncated by either your near or far frustum plane. Either adjust your frustum or your camera position or both.

:)

talyrond
01-09-2006, 09:26 AM
Smiley, thankyou so much, that fixed it! You got so quickly

I just added:

gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-(Me.Width / 2), Me.Width / 2, -(Me.Width / 2), Me.Width / 2, 100, -100)

The last two arguments were originally 1 and -1, because I was doing 2D I never even realized that the figures made any difference.

Cheers

Talyrond

01-09-2006, 09:30 AM
I got it quickly because it's happened to me about a million times before :D

Cheers :)