2014-02-12 2 views
-1

두 개의 LWJGL 클래스가 오류를 일으키고 있으며, 표시되지 않은 큐브와 관련이 있다고 가정합니다!에러가 발생하는 Java 클래스

오류 :

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

} 
+6

원형 클래스 상속이 있습니다. 그게 너 한테 어떻게 이해가되는거야? –

답변

0

당신은 자신 혹은 그녀의 ChildClass에 의해 상속 클래스를 가질 수 없습니다 : 유형 stonehearth_display의 계층 구조/stonehearth_cube 일관성

stonehearth_display입니다. > stone_display - -> stone_cube -> stone_display ...

당신이 그것을 잡을 마십시오

stone_cube?

당신은 stone_display에서 stone_cube를 상속하면됩니다. 이후에는 하나의 stone_display 또는 하나의 stone_cube를 만들고 다른 것을 만들어야합니다.

관련 문제