This commit is contained in:
Andy Killorin 2025-01-03 13:32:26 -05:00
parent 04978fdbbb
commit 4cfa230985
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -61,114 +61,27 @@ fn main() {
let mut draw_gl = || {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
glTranslatef(0.0, 0.0, -5.0);
glRotatef(xrot, 1.0, 0.0, 0.0);
glRotatef(yrot, 0.0, 1.0, 0.0);
glRotatef(zrot, 0.0, 0.0, 1.0);
// Front face
glBindTexture(GL_TEXTURE_2D, tex_exterior);
glBegin(GL_QUADS);
//slice(tex_exterior, tex_top, tex_interior);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glTranslatef(0.0, 0.0, -1.0);
glEnd();
for i in 0..=6 {
glPushMatrix();
glTranslatef(0., -1.0, 1.0);
glRotatef(2970. * i as f32, 0.0, 1.0, 0.0);
glTranslatef(0., 1.0, -1.0);
glScalef(1., 0.4, 1.);
slice(tex_exterior, tex_top, tex_interior, false);
glPopMatrix();
}
// Back face
glBindTexture(GL_TEXTURE_2D, tex_exterior);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, 1.0, -1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, 1.0, -1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
// Top face
glBindTexture(GL_TEXTURE_2D, tex_top);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-1.0, 1.0, -1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(1.0, 1.0, -1.0);
glEnd();
// Bottom face
glBindTexture(GL_TEXTURE_2D, tex_exterior);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, 1.0);
glEnd();
// Right face
glBindTexture(GL_TEXTURE_2D, tex_exterior);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(1.0, 1.0, -1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, 1.0);
glEnd();
// Left face
glBindTexture(GL_TEXTURE_2D, tex_exterior);
glBegin(GL_QUADS);
glColor3f(1., 1., 1.);
glTexCoord2f(1.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-1.0, 1.0, -1.0);
glEnd();
glTranslatef(0.0, 0.0, -3.);
slice(tex_exterior, tex_top, tex_interior);
//xrot += 56.0;
yrot += 44.0;
//zrot += 72.0;
yrot += 24.0;
};
@ -203,7 +116,8 @@ fn main() {
println!("Bye!");
}
unsafe fn slice(tex_exterior: u32, tex_top: u32, tex_interior: u32) {
unsafe fn slice(tex_exterior: u32, tex_top: u32, tex_interior: u32, edges: bool) {
if edges {
// left face
glBindTexture(GL_TEXTURE_2D, tex_interior);
glBegin(GL_QUADS);
@ -231,6 +145,7 @@ unsafe fn slice(tex_exterior: u32, tex_top: u32, tex_interior: u32) {
glTexCoord2f(1.0, 1.0);
glVertex3f(0.0, 1.0, 1.0);
glEnd();
}
// top face
glBindTexture(GL_TEXTURE_2D, tex_top);