REVIEWED: DrawCubeTextureRec() formatting

This commit is contained in:
raysan5 2021-10-12 12:08:12 +02:00
parent 282ec9bb76
commit 4a1bd12e2d

View file

@ -341,57 +341,57 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
// Front Face ----------------------------------------------------- // Front face -----------------------------------------------------
// Bottom Line // Bottom line
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right
// Left Line // Left line
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right
// Top Line // Top line
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left
// Right Line // Right line
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left
// Back Face ------------------------------------------------------ // Back face ------------------------------------------------------
// Bottom Line // Bottom line
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right
// Left Line // Left line
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right
// Top Line // Top line
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left
// Right Line // Right line
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left
// Top Face ------------------------------------------------------- // Top face -------------------------------------------------------
// Left Line // Left line
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left front
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left back
// Right Line // Right line
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right front
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right back
// Bottom Face --------------------------------------------------- // Bottom face ---------------------------------------------------
// Left Line // Left line
rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front rlVertex3f(x-width/2, y-height/2, z+length/2); // Top left front
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back rlVertex3f(x-width/2, y-height/2, z-length/2); // Top left back
// Right Line // Right line
rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front rlVertex3f(x+width/2, y-height/2, z+length/2); // Top right front
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back rlVertex3f(x+width/2, y-height/2, z-length/2); // Top right back
rlEnd(); rlEnd();
rlPopMatrix(); rlPopMatrix();
} }
@ -464,13 +464,14 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
rlSetTexture(0); rlSetTexture(0);
} }
// Draw cube with texture piece applied to all faces
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color) void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
{ {
float x = position.x; float x = position.x;
float y = position.y; float y = position.y;
float z = position.z; float z = position.z;
float texture_width = (float)texture.width; float texWidth = (float)texture.width;
float texture_height = (float)texture.height; float texHeight = (float)texture.height;
rlCheckRenderBatchLimit(36); rlCheckRenderBatchLimit(36);
@ -479,137 +480,72 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
// Front Face // Front face
{
// Normal Pointing Towards Viewer
rlNormal3f(0.0f, 0.0f, 1.0f); rlNormal3f(0.0f, 0.0f, 1.0f);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y - height/2, z + length/2); rlVertex3f(x - width/2, y - height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y - height/2, z + length/2); rlVertex3f(x + width/2, y - height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y + height/2, z + length/2); rlVertex3f(x + width/2, y + height/2, z + length/2);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y + height/2, z + length/2); rlVertex3f(x - width/2, y + height/2, z + length/2);
}
// Back Face // Back face
{
// Normal Pointing Away From Viewer
rlNormal3f(0.0f, 0.0f, - 1.0f); rlNormal3f(0.0f, 0.0f, - 1.0f);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y - height/2, z - length/2); rlVertex3f(x - width/2, y - height/2, z - length/2);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y + height/2, z - length/2); rlVertex3f(x - width/2, y + height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y + height/2, z - length/2); rlVertex3f(x + width/2, y + height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y - height/2, z - length/2); rlVertex3f(x + width/2, y - height/2, z - length/2);
}
// Top Face // Top face
{
// Normal Pointing Up
rlNormal3f(0.0f, 1.0f, 0.0f); rlNormal3f(0.0f, 1.0f, 0.0f);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y + height/2, z - length/2); rlVertex3f(x - width/2, y + height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y + height/2, z + length/2); rlVertex3f(x - width/2, y + height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y + height/2, z + length/2); rlVertex3f(x + width/2, y + height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y + height/2, z - length/2); rlVertex3f(x + width/2, y + height/2, z - length/2);
}
// Bottom Face // Bottom face
{
// Normal Pointing Down
rlNormal3f(0.0f, - 1.0f, 0.0f); rlNormal3f(0.0f, - 1.0f, 0.0f);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y - height/2, z - length/2); rlVertex3f(x - width/2, y - height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y - height/2, z - length/2); rlVertex3f(x + width/2, y - height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y - height/2, z + length/2); rlVertex3f(x + width/2, y - height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y - height/2, z + length/2); rlVertex3f(x - width/2, y - height/2, z + length/2);
}
// Right face // Right face
{
// Normal Pointing Right
rlNormal3f(1.0f, 0.0f, 0.0f); rlNormal3f(1.0f, 0.0f, 0.0f);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y - height/2, z - length/2); rlVertex3f(x + width/2, y - height/2, z - length/2);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y + height/2, z - length/2); rlVertex3f(x + width/2, y + height/2, z - length/2);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x + width/2, y + height/2, z + length/2); rlVertex3f(x + width/2, y + height/2, z + length/2);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x + width/2, y - height/2, z + length/2); rlVertex3f(x + width/2, y - height/2, z + length/2);
}
// Left Face // Left face
{
// Normal Pointing Left
rlNormal3f( - 1.0f, 0.0f, 0.0f); rlNormal3f( - 1.0f, 0.0f, 0.0f);
rlTexCoord2f(source.x/texWidth, (source.y + source.height)/texHeight);
// Bottom Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y - height/2, z - length/2); rlVertex3f(x - width/2, y - height/2, z - length/2);
rlTexCoord2f((source.x + source.width)/texWidth, (source.y + source.height)/texHeight);
// Bottom Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, (source.y + source.height) / texture_height);
rlVertex3f(x - width/2, y - height/2, z + length/2); rlVertex3f(x - width/2, y - height/2, z + length/2);
rlTexCoord2f((source.x + source.width)/texWidth, source.y/texHeight);
// Top Right Of The Texture and Quad
rlTexCoord2f((source.x + source.width) / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y + height/2, z + length/2); rlVertex3f(x - width/2, y + height/2, z + length/2);
rlTexCoord2f(source.x/texWidth, source.y/texHeight);
// Top Left Of The Texture and Quad
rlTexCoord2f(source.x / texture_width, source.y / texture_height);
rlVertex3f(x - width/2, y + height/2, z - length/2); rlVertex3f(x - width/2, y + height/2, z - length/2);
}
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);