On Mac OS X Leopard 10.5.1, I am running gosu 0.7.8.5.
I am drawing a simple cube using a gl block, and have a z-fighting problem. I have played with
adjusting the glDepthFunc, clearing the z-buffer with different values, pushed the near clipping
plane out from 0.0 and brought the far clipping plane in close to the near clipping plane, and I
just can't seem to get it to go away.
I see the back of the cube over the front of the cube.
Could it be the gosu environment causing me problems?
Here is some simplified code illustrating the problem and the attached file is a screenshot:
require 'rubygems'
require 'gosu'
require 'gl'
require 'glu'
include Gl
include Glu
class GameWindow < Gosu::Window
def initialize
super(800, 600, false)
self.caption = "oglt3"
end
def draw
gl do
glClearColor(0.0, 0.2, 0.5, 1.0)
glClearDepth(0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glDepthFunc(GL_GEQUAL)
glEnable(GL_DEPTH_TEST)
```
glMatrixMode(GL_PROJECTION)
glLoadIdentity
gluPerspective(45.0, 1.2, 1.0, 15.0)
glTranslate(0.0, 0.0, -10.0)
glBegin(GL_TRIANGLES)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, -2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, -2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, -2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, -2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, -2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, -2.5, -2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, -2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, -2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, 2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, 2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, 2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, -2.5, -2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, 2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, 2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, 2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, 2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, 2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, 2.5, -2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, 2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, 2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, -2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, -2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, -2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, 2.5, -2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, -2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, -2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, 2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, 2.5, 2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, 2.5, 2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, -2.5, 2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(2.5, -2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(-2.5, -2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(-2.5, 2.5, -2.5)
glColor3f(1.0, 0.0, 0.0)
glVertex3f(-2.5, 2.5, -2.5)
glColor3f(0.0, 1.0, 0.0)
glVertex3f(2.5, 2.5, -2.5)
glColor3f(0.0, 0.0, 1.0)
glVertex3f(2.5, -2.5, -2.5)
glEnd
end
```
end
def button_down(id)
if Gosu::Button::KbEscape == id
close
end
end
end
window = GameWindow.new
window.show
Original link: http://code.google.com/p/gosu/issues/detail?id=24