Итак, я работаю над игрой с OpenGL и Java, и я решил использовать JSFML для моего окна, текста, загрузки изображений и т. Д. ... И у меня есть некоторые небольшие проблемы.Буфер глубины JSFML не работает
Рисунок OpenGL отлично работает, пока я не попытаюсь сыграть с глубиной, тогда он просто не работает!
Вот мой код до сих пор:
import java.io.*;
import org.jsfml.graphics.*;
import org.jsfml.window.*;
import static org.lwjgl.opengl.GL11.*;
//import static org.lwjgl.util.glu.GLU.*;
public class Main
{
static Image icon;
static Texture playert;
static long a, b, c, d;
static float e;
public static void main(String[] args) throws Exception
{
c = 0l;
icon = new Image();
icon.loadFromStream(new FileInputStream("Icon.png"));
ContextSettings contextSettings;
contextSettings = new ContextSettings (24, 8, 0, 2, 1);
VideoMode v = new VideoMode(800, 600);
RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML Game", org.jsfml.window.WindowStyle.DEFAULT, contextSettings);
window.setIcon(icon);
window.setFramerateLimit(120);
Context.getContext().setActive(true);
Text pauseMessage = new Text();
Font font = new Font();
font.loadFromStream(new FileInputStream("Minecraftia.ttf"));
pauseMessage.setFont(font);
pauseMessage.setCharacterSize(20);
pauseMessage.setPosition(0.f, 0.f);
pauseMessage.setColor(new Color(250, 250, 250));
pauseMessage.setString("This is Mission:Iinfinity, prototyped in JSFML");
Text fps = new Text();
fps.setFont(font);
fps.setCharacterSize(20);
fps.setPosition(0.f, 20.f);
fps.setColor(new Color(250, 250, 250));
fps.setString("FPS: " + c);
org.lwjgl.opengl.GLContext.useContext(Context.getContext());
glDepthMask(true);
glClearDepth(1.f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float ratio = window.getSize().x/window.getSize().y;
glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
a = System.currentTimeMillis();
d = System.currentTimeMillis();
while (true)
{
window.clear();
if(b - a >= 1000)
{
a = b;
fps.setString("FPS: " + c);
c = 0;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
window.pushGLStates();
window.draw(pauseMessage);
window.draw(fps);
window.popGLStates();
glPushMatrix();
glTranslatef(0.0f, 0.0f, -10f);
//glRotatef(10f, 0.f, 0.f, 1.f);
glBegin(GL_POLYGON);
glVertex3f(-0.5f, -0.5f, 0);
glVertex3f(-0.5f, 0.5f, 0);
glVertex3f(0.5f, 0.5f, 0);
glVertex3f(0.5f, -0.5f, 0);
glEnd();
glPopMatrix();
window.display();
if(Keyboard.isKeyPressed(Keyboard.Key.ESCAPE))
{
window.close();
System.exit(0);
}
b = System.currentTimeMillis();
c++;
}
}
}
EDIT: Хорошо, установил ContextSettings но куб до сих пор упорно отказывается рисовать дальше, чем 1 коорд глубокой или 1 коорд задней