-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();
}
}
}
원형 클래스 상속이 있습니다. 그게 너 한테 어떻게 이해가되는거야? –