0
큐브를 구성하는 6 개의 쿼드가 있어야하며 각 쿼드에 다른 텍스처를 바인딩하고 싶습니다. 내가 정확히 그것을 어떻게 할 수 있었 을까? 지금까지 내가 가지고있는 것 :openGL 쿼드에 여러 텍스처 바인딩
glPushMatrix(); {
glTranslatef(x, y, z);
glBegin(GL_QUADS);
{
//FrontFace
if(id != Blocks.Air){
setTexCords = true;
glColor3f(1, 1, 1);
id.getFrontTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
{
glEnd();
glBegin(GL_QUADS);
{
//BackFace
if(id != Blocks.Air){
setTexCords = true;
id.getBackTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
}
glEnd();
glBegin(GL_QUADS);
{
//BottomFace
if(id != Blocks.Air){
setTexCords = true;
id.getBottomTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
}
glEnd();
glBegin(GL_QUADS);
{
//TopFace
if(id != Blocks.Air){
glColor3f(1, 1, 1);
setTexCords = true;
id.getTopTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
}
glEnd();
glBegin(GL_QUADS);
{
//LeftFace
if(id != Blocks.Air){
setTexCords = true;
id.getLeftTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(-Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
}
glEnd();
glBegin(GL_QUADS);
{
//Right Face
if(id != Blocks.Air){
setTexCords = true;
id.getRightTexture().bind();
}else{
setTexCords = false;
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
}
if(textureType == "IMAGE"){
}else{
glColor3d(toFloatColor(tid.getRed()), toFloatColor(tid.getGreen()), toFloatColor(tid.getBlue()));
}
if(setTexCords) glTexCoord2f(0, 0);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(0, 1);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,-Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 1);
glVertex3f(Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
if(setTexCords) glTexCoord2f(1, 0);
glVertex3f(-Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE,Blocks.BLOCK_SIZE);
}
glEnd();
}
glPopMatrix();
내가 앱을 실행할 때마다 상단이 검게 나타나고 나머지는 같은 텍스처입니다. 도움 주셔서 감사합니다!
고정 함수 GL에서 배열 텍스처를 사용할 수 없습니다. –
@NicolBolas : 글쎄, 고정 배열 기능을 버리는 것 외에도 텍스처 배열을 사용할 것을 제안했습니다. – datenwolf
버텍스 배열을 사용하도록 코드를 업데이트했으나 어쨌든 고마워요. – APerson