だから、私は今働いている私のエンジンに問題が移動します。OpenGLはクワッド
これはキューブを作成するコードである:
private void render(){
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT|GL11.GL_DEPTH_BUFFER_BIT);
for(int x=0; x<16; x++){
for(int z=0; z<16; z++) {
b.renderBlock(x, 0, z, texture);
}
}
glMatrixMode(GL_MODELVIEW);
GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
GL11.glEnable(GL_CULL_FACE);
GL11.glLoadIdentity();
}
これは、それが基本的にブロック四角形を描画ブロック
Block.java(b.renderblock)
package net.themorfeus.awesum.adventure.game;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;
public class Block {
private float rquad = 0f;
public void renderBlock(int posx, int posy, int posz, Texture t) {
t.bind();
//GL11.glLoadIdentity(); // Reset The Current Modelview Matrix
GL11.glTranslatef(posx,posy,posz); // Move Right 1.5 Units And Into The Screen 6.0
GL11.glRotatef(rquad,0.0f,0.0f,1.0f); // Rotate The Quad On The X axis (NEW)
GL11.glColor3f(1.0f,1.0f,1.0f); // Set The Color To Blue One Time Only
GL11.glBegin(GL11.GL_QUADS); // Draw A Quad
//GL11.glColor3f(0.5f, 0.4f, 0.4f); // Set The Color To Green
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(1f, 1f,-1f); // Top Right Of The Quad (Top)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(-1f, 1f,-1f); // Top Left Of The Quad (Top)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(-1f, 1f, 1f); // Bottom Left Of The Quad (Top)
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(1f, 1f, 1f); // Bottom Right Of The Quad (Top)
//GL11.glColor3f(1.2f,0.5f,0.9f); // Set The Color To Orange
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(1f,-1f, 1f); // Top Right Of The Quad (Bottom)
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(-1f,-1f, 1f); // Top Left Of The Quad (Bottom)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(-1f,-1f,-1f); // Bottom Left Of The Quad (Bottom)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(1f,-1f,-1f); // Bottom Right Of The Quad (Bottom)
//GL11.glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(1f, 1f, 1f); // Top Right Of The Quad (Front)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(-1f, 1f, 1f); // Top Left Of The Quad (Front)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(-1f,-1f, 1f); // Bottom Left Of The Quad (Front)
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(1f,-1f, 1f); // Bottom Right Of The Quad (Front)
//GL11.glColor3f(1f,0.5f,0.0f); // Set The Color To Yellow
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(1f,-1f,-1f); // Bottom Left Of The Quad (Back)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(-1f,-1f,-1f); // Bottom Right Of The Quad (Back)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(-1f, 1f,-1f); // Top Right Of The Quad (Back)
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(1f, 1f,-1f); // Top Left Of The Quad (Back)
//GL11.glColor3f(0.0f,0.0f,0.3f); // Set The Color To Blue
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(-1f, 1f, 1f); // Top Right Of The Quad (Left)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(-1f, 1f,-1f); // Top Left Of The Quad (Left)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(-1f,-1f,-1f); // Bottom Left Of The Quad (Left)
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(-1f,-1f, 1f); // Bottom Right Of The Quad (Left)
//GL11.glColor3f(0.5f,0.0f,0.5f); // Set The Color To Violet
GL11.glTexCoord2f(0,0);
GL11.glVertex3f(1f, 1f,-1f); // Top Right Of The Quad (Right)
GL11.glTexCoord2f(1,0);
GL11.glVertex3f(1f, 1f, 1f); // Top Left Of The Quad (Right)
GL11.glTexCoord2f(1,1);
GL11.glVertex3f(1f,-1f, 1f); // Bottom Left Of The Quad (Right)
GL11.glTexCoord2f(0,1);
GL11.glVertex3f(1f,-1f,-1f); // Bottom Right Of The Quad (Right)
GL11.glEnd();
//rquad+=0.0000001f;
}
}
の16×16プラットフォームをレンダリングしなければなりません。
ちょっとした提案:実際には、即時モードコード( 'glBegin()... glEnd()')を取り除くべきです。この関数呼び出しのオーバーヘッドはすべてネイティブコードでは十分に悪いですが、JNI境界を超えてもそれを改善することはできません。頂点配列と頂点バッファオブジェクトを使用する。 – datenwolf