Я возился с кадровыми буферами, вдруг что-то сломалось, я вернулся к состоянию, когда все работало, а затем внезапно OpenGL прекратил рендеринг.У меня был шанс glClearColor
, я также мог рендерить вещи с помощью glBegin, но рендеринг с помощью шейдеров и glDrawElements
ничего не дал мне.Я отключил каждый фрейм-буфер, я проверил каждый класс в моем проекте, проверил шейдеры и ничего.
package test;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;
import org.lwjgl.util.vector.Vector2f;
public class Main {
public static World world;
public static GUIRenderer renderer;
public static FrameBuffer buffer;
public static void main(String[] args) throws InterruptedException {
try {
ContextAttribs attributes = new ContextAttribs(3,2).withForwardCompatible(true).withProfileCore(true);
Display.setDisplayMode(new DisplayMode(800, 600));
Display.setTitle("Test");
Display.create(new PixelFormat(), attributes);
} catch(LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
world = new World();
Vector2f[] vec = {new Vector2f(-1, 1), new Vector2f(-1, -1), new Vector2f(1, -1), new Vector2f(1, 1)};
int[] indices = {0, 1, 2, 0, 2, 3};
Mesh mesh = new Mesh();
mesh.load(vec, indices);
BasicShader2D shader = new BasicShader2D();
renderer = new GUIRenderer();
buffer = new FrameBuffer();
GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
while(!Display.isCloseRequested()) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glClearColor(0.5f, 0, 0, 1);
GL11.glEnable(GL11.GL_TEXTURE_2D);
//buffer.bind();
world.tick();
renderer.render(mesh, shader);
//buffer.unbind();
GL11.glDisable(GL11.GL_TEXTURE_2D);
Display.update();
Thread.sleep(16);
}
world.delete();
Display.destroy();
}
}
//vertex
#version 150 core
uniform mat4 transformation;
uniform mat4 projection;
uniform mat4 view;
in vec3 pos;
in vec3 normal;
void main() {
gl_Position = projection * view * transformation * vec4(pos, 1.0);
}
//fragment
#version 150 core
//#define PI 3.1415926535897932384626433832795
out vec4 color_out;
void main(){
color_out = vec4(1.0, 1.0, 0.0, 1.0);
}