我的两个LWJGL类给了我错误,我假设它与我所制作的多维数据集有关,因为它没有显示!
错误:stonehearth_display / stonehearth_cube类型的层次结构不一致
stonehearth_display:
package com.mime.stonehearth;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class stonehearth_display extends stonehearth_cube{
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(800, 600));
Display.setTitle("Stonehearth Pre-Alpha 0.0.1");
Display.create();
} catch (LWJGLException e) {
System.err.println("Display wasn't initialized correctly.");
System.exit(1);
}
try {
render();
angle = (angle+1)%360;
}
while (!Display.isCloseRequested()) {
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
}
stonehearth_cube.java
package com.mime.stonehearth;
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class stonehearth_cube extends stonehearth_display{
int angle = 0 ;
public void render(){
float edgeLength= 20.0f;
edgeLength /= 2.0f;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), 0.0f, -50.0f, 50.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
glPushMatrix();
glTranslatef((Display.getWidth()/2), (Display.getHeight()/2), 0.0f);
glRotatef(angle, 1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
//Back
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-edgeLength, edgeLength, edgeLength);
glVertex3f(-edgeLength, -edgeLength, edgeLength);
glVertex3f(edgeLength, -edgeLength, edgeLength);
glVertex3f(-edgeLength, edgeLength, edgeLength);
glVertex3f(edgeLength, edgeLength, edgeLength);
glVertex3f(edgeLength, -edgeLength, edgeLength);
//Front
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(-edgeLength, edgeLength, -edgeLength);
glVertex3f(-edgeLength, -edgeLength, -edgeLength);
glVertex3f(edgeLength, -edgeLength, -edgeLength);
glVertex3f(-edgeLength, edgeLength, -edgeLength);
glVertex3f(edgeLength, edgeLength, -edgeLength);
glVertex3f(edgeLength, -edgeLength, -edgeLength);
// Right
glColor3f(1.0f, 1.0f, 1.0f);
glVertex3f(edgeLength, edgeLength, -edgeLength);
glVertex3f(edgeLength, -edgeLength, -edgeLength);
glVertex3f(edgeLength, -edgeLength, edgeLength);
glVertex3f(edgeLength, edgeLength, -edgeLength);
glVertex3f(edgeLength, edgeLength, edgeLength);
glVertex3f(edgeLength, -edgeLength, edgeLength);
glEnd();
glPopMatrix();
}
}
}
答案 0 :(得分:0)
你不能拥有自己或她的子类继承的类。
stone_cube - > stone_display - > stone_cube - > stone_display ...
你抓住了吗?我认为你只需要从stone_display继承stone_cube,之后,你必须创建另一个创建一个stone_display或一个stone_cube的东西。