我有一个非常奇怪的错误,我首先渲染一些地形然后四边形以获得一些参考平面以防出现问题。
这是我最相关的代码:
@Override
protected void compilePrograms() {
super.compilePrograms();
programTerrain = new Program(
new VertexShader("data/shaders/terrain.vs.glsl").compile(),
new TessellationControlShader("data/shaders/terrain.tcs.glsl").compile(),
new TessellationEvaluationShader("data/shaders/terrain.tes.glsl").compile(),
new FragmentShader("data/shaders/terrain.fs.glsl").compile()
).compile();
programQuad = new Program(
new VertexShader("data/shaders/quad.vs.glsl").compile(),
new FragmentShader("data/shaders/quad.fs.glsl").compile()
).compile();
programsCompiled();
}
@Override
protected void init() {
super.init();
float[] plane = new float[] {
-400f, -5f, -400f,
-400f, -5f, 400f,
400f, -5f, 400f,
400f, -5f, -400f
};
//temp
FloatBuffer dataBuffer = BufferUtils.createFloatBuffer(16 * 16 * 16 * 3 + 4 * 3);
dataBuffer.put(generateRandomTerrain(16, 16));
dataBuffer.put(plane);
dataBuffer.clear();
buffer = new DynamicDrawArrayBuffer().create().bind().fillData(dataBuffer);
vertexArray = new VertexArrayObject().create().bind();
vertexArray.setAttribute(buffer, VS_POSITION, 3, GL_FLOAT, false, 0, 0);
vertexArray.enableAttributes(VS_POSITION);
modelMatrix.identity().translate(0f, 0f, 0f);
Uniforms.setUniformMatrix4(UNIFORM_MODEL_MATRIX, false, modelMatrix.writeToFloatBuffer(modelMatrixBuffer));
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glPatchParameteri(GL_PATCH_VERTICES, 16);
}
@Override
protected void render(final double msDelta) {
super.render(msDelta);
glClearColor(25f / 255f, 25f / 255f, 112f / 225f, 1.0f);
glClearDepthf(1f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
programTerrain.use();
programTerrain.drawArrays(GL_PATCHES, 0, 16 * 16 * 16);
programQuad.use();
programQuad.drawArrays(GL_QUADS, 16 * 16 * 16, 4);
}
我在这里使用的所有内容都应该是直截了当的,因为对象只是围绕OpenGL的非常简单的包装器,Í请列出drawArrays
以供进一步参考:
public Program drawArrays(final int mode, final int offset, final int count) {
assertCompiled();
assertUsing();
GL11.glDrawArrays(mode, offset, count);
return this;
}
我得到的错误如下:
Chosen display mode: 1920 x 1080 x 32 @60Hz
Started OpenGL with the following parameters:
Major version: 4
Minor version: 4
Forward compatible: true
Profile Core: true
jan 26, 2014 9:19:20 PM pkg3dgame.Controller start
SEVERE: null
org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
at org.lwjgl.opengl.GL11.glDrawArrays(GL11.java:1205)
at programs.Program.drawArrays(Program.java:87)
at pkg3dgame.FPSGameController.render(FPSGameController.java:124)
at pkg3dgame.Controller.renderImpl(Controller.java:208)
at pkg3dgame.Controller.start(Controller.java:150)
at pkg3dgame.FPSGameController.main(FPSGameController.java:210)
当我传入GL_TRIANGLES
或GL_LINE_STRIP
时,代码 的工作非常奇怪,例如,我正在使用LWJGL以防有人想知道。
在调试模式下更新:Could not locate symbol glVertexWeighthNV
,不确定它是什么意思。