我的Java类给了我错误

我的Java类给了我错误,java,opengl,Java,Opengl,我的两个LWJGL类给了我错误,我假设这与我制作的立方体有关,因为它没有显示出来 错误:stonehearth_display/stonehearth_cube类型的层次结构不一致 石炉显示器: package com.mime.stonehearth; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public class ston

我的两个LWJGL类给了我错误,我假设这与我制作的立方体有关,因为它没有显示出来

错误:stonehearth_display/stonehearth_cube类型的层次结构不一致

石炉显示器:

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();
    }
}

}

您不能让他或她的子类继承类

石头立方体-->石头立方体显示-->石头立方体-->石头立方体显示

你明白了吗


我认为您只需从stone_display继承stone_cube,然后,您必须创建另一个,在其中创建一个stone_display或一个stone_cube并执行其他操作。

您有一个循环类继承。这对你有什么意义?