From 930291bd672cb60b68c1f5637decdc4ec00c032e Mon Sep 17 00:00:00 2001 From: eri451 Date: Sat, 25 Jan 2014 15:50:46 +0100 Subject: [PATCH] eppic fail Chris --- lesson02/lesson2.c | 181 +++++------------------------------------ lesson02/makefile | 7 +- lesson02/openBracket.c | 85 +++++++++++++++++++ lesson02/openBracket.h | 11 +++ lesson02/slash.c | 86 ++++++++++++++++++++ lesson02/slash.h | 11 +++ lesson02/texture.bmp | Bin 196730 -> 196730 bytes 7 files changed, 220 insertions(+), 161 deletions(-) create mode 100644 lesson02/openBracket.c create mode 100644 lesson02/openBracket.h create mode 100644 lesson02/slash.c create mode 100644 lesson02/slash.h diff --git a/lesson02/lesson2.c b/lesson02/lesson2.c index 339663f..d88a005 100755 --- a/lesson02/lesson2.c +++ b/lesson02/lesson2.c @@ -10,10 +10,14 @@ #include // Header File For The OpenGL32 Library #include // Header File For The GLu32 Library #include // Header File For sleeping. +#include // Header File for math. #include #include +#include "slash.h" +#include "openBracket.h" + #define PI 3.1415 /* ASCII code for the escape key. */ @@ -26,7 +30,7 @@ float xrot = 0.0f; float yrot = 0.0f; float zrot = 0.0f; -float i = 0.15; +float i = 0.3; int full = 0; int oszi = 0; @@ -207,79 +211,11 @@ void rota(int what) yrot += i; zrot += i; } - if (xrot > 360) { xrot = 0; oszi = 0;} - if (yrot > 360) { yrot = 0; oszi = 0;} - if (zrot > 360) { zrot = 0; oszi = 0;} + if (xrot >= 360) xrot = 0; + if (yrot >= 360) yrot = 0; + if (zrot >= 360) zrot = 0; } -void DrawOpenBracket(){ - // draw a square (quadrilateral) - glBegin(GL_QUADS); // start drawing a polygon (4 sided) - - // Down - // Front Face (note that the texture's corners have to match the quad's corners) - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - - // Back Face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad - - // Bottom Face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad - - // Right face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - - // Left Face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - - // Up - // Front Face (note that the texture's corners have to match the quad's corners) - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - - // Back Face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Left Of The Texture and Quad - - // Top Face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.2f, -0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, -0.0f, 0.5f); // Bottom Left Of The Texture and Quad - - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - - glEnd(); // done with the polygon -} void DrawCloseBracket(){ // draw a square (quadrilateral) @@ -350,74 +286,6 @@ void DrawCloseBracket(){ glEnd(); // done with the polygon } -void DrawSlash(){ - // draw a square (quadrilateral) - glBegin(GL_QUADS); // start drawing a polygon (4 sided) - - // Down - // Front Face (note that the texture's corners have to match the quad's corners) - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - - // Back Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad - - // Bottom Face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad - - // Right face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - - // Left Face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad - - // Up - // Front Face (note that the texture's corners have to match the quad's corners) - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - - // Back Face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Left Of The Texture and Quad - - // Top Face - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - - // Left Face - glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad - - // Right face - glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad - glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad - glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad - glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Left Of The Texture and Quad - - glEnd(); // done with the polygon -} /* The main drawing function. */ void DrawGLScene() @@ -429,44 +297,39 @@ void DrawGLScene() glTranslatef(0.0f,0.0f,-8.0f); // Move Left 1.5 Units And Into The Screen 6.0 glRotatef(xrot, 1.0f, 0.0f, 0.0f); - glRotatef(yrot, 0.0f, 1.0f, 0.0f); + glRotatef(yrot, 0.0f, 0.0f, 0.0f); glRotatef(zrot, 0.0f, 0.0f, 1.0f); + glTranslatef(0.0f, sin((yrot*PI)/180), 0.0f); + glBindTexture(GL_TEXTURE_2D, texture[0]); // choose the texture to use. glTranslatef(-3.0f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 1.0f, 0.0f); - DrawOpenBracket(); - glRotatef(xrot, 0.0f,-1.0f, 0.0f); + DrawOpenBracket( 0.0f, yrot, 0.0f); glTranslatef(1.2f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 1.0f, 0.0f); - DrawOpenBracket(); - glRotatef(xrot, 0.0f,-1.0f, 0.0f); + DrawOpenBracket( 0.0f, yrot, 0.0f); glTranslatef(1.2f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 1.0f, 0.0f); - DrawOpenBracket(); - glRotatef(xrot, 0.0f,-1.0f, 0.0f); + DrawOpenBracket( 0.0f, yrot, 0.0f); glTranslatef(1.2f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 0.0f, 1.0f); - DrawSlash(); - glRotatef(xrot, 0.0f, 0.0f,-1.0f); + DrawSlash(0.0f, yrot, 0.0f); glTranslatef(1.2f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 1.0f, 0.0f); + glRotatef(yrot, 0.0f, 1.0f, 0.0f); DrawCloseBracket(); - glRotatef(xrot, 0.0f,-1.0f, 0.0f); + glRotatef(yrot, 0.0f,-1.0f, 0.0f); glTranslatef(1.2f, 0.0f, 0.0f); - glRotatef(xrot, 0.0f, 1.0f, 0.0f); + glRotatef(yrot, 0.0f, 1.0f, 0.0f); DrawCloseBracket(); - glRotatef(xrot, 0.0f,-1.0f, 0.0f); + glRotatef(yrot, 0.0f,-1.0f, 0.0f); + // swap buffers to display, since we're double buffered. glutSwapBuffers(); - if (oszi) rota(0); + if (oszi) rota(1); } /* The function called whenever a key is pressed. */ @@ -555,7 +418,7 @@ int main(int argc, char **argv) glutInitWindowPosition(400, 210); /* Open a window */ - window = glutCreateWindow("Jeff Molofee's GL Code Tutorial ... NeHe '99"); + window = glutCreateWindow("c3d2 animation"); /* Register the function to do all our OpenGL drawing. */ glutDisplayFunc(&DrawGLScene); diff --git a/lesson02/makefile b/lesson02/makefile index df89f9b..41b2245 100755 --- a/lesson02/makefile +++ b/lesson02/makefile @@ -5,6 +5,7 @@ COMPILERFLAGS = -Wall CC = gcc CFLAGS = $(COMPILERFLAGS) $(INCLUDE) LIBRARIES = -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm +OBJECTS = $(patsubst %.c, %.o, $(wildcard ./*.c)) # for all, set the targets to be every lesson1.c-lesson13.c # file, removing the .c extension. That is, at this point, @@ -33,8 +34,8 @@ lesson%.tar.gz : # # 1. compile the thing. uses the variables defined above. # -lesson% : lesson%.o - $(CC) $(CFLAGS) -o $@ $(LIBDIR) $< $(LIBRARIES) +lesson% : lesson%.o $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBDIR) $(LIBRARIES) # to clean up: # delete all of the lessonX files. @@ -46,3 +47,5 @@ clean: distclean: rm $(wildcard lesson[1-9].tar.gz lesson1[0-3].tar.gz) +%.o: %.c + $(CC) -c -o $@ $< diff --git a/lesson02/openBracket.c b/lesson02/openBracket.c new file mode 100644 index 0000000..4845bc2 --- /dev/null +++ b/lesson02/openBracket.c @@ -0,0 +1,85 @@ +#include // Header File For The GLUT Library +#include // Header File For The OpenGL32 Library +#include // Header File For The GLu32 Library + + +void DrawOpenBracket(float xrot, float yrot, float zrot) +{ + glRotatef(xrot, 1.0f, 0.0f, 0.0f); + glRotatef(yrot, 0.0f, 1.0f, 0.0f); + glRotatef(zrot, 0.0f, 0.0f, 1.0f); + + // draw a square (quadrilateral) + glBegin(GL_QUADS); // start drawing a polygon (4 sided) + + // Down + // Front Face (note that the texture's corners have to match the quad's corners) + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + + // Back Face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad + + // Bottom Face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad + + // Right face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + + // Left Face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + + // Up + // Front Face (note that the texture's corners have to match the quad's corners) + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + + // Back Face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Left Of The Texture and Quad + + // Top Face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + + // Left Face + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.2f, -0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, -0.0f, 0.5f); // Bottom Left Of The Texture and Quad + + // Right face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + + glEnd(); // done with the polygon + + glRotatef(xrot,-1.0f, 0.0f, 0.0f); + glRotatef(yrot, 0.0f,-1.0f, 0.0f); + glRotatef(zrot, 0.0f, 0.0f,-1.0f); +} + +/* vim: set et sw=4 ts=4: */ + diff --git a/lesson02/openBracket.h b/lesson02/openBracket.h new file mode 100644 index 0000000..0ddccf9 --- /dev/null +++ b/lesson02/openBracket.h @@ -0,0 +1,11 @@ +#ifndef SLASH_H +#define SLASH_H + +/* + * Draw a textured 2 boxed sharp opening bracket + * rotate the object with the 3 args + */ + +void DrawOpenBracket(float xrot, float yrot, float zrot); + +#endif diff --git a/lesson02/slash.c b/lesson02/slash.c new file mode 100644 index 0000000..7260c2f --- /dev/null +++ b/lesson02/slash.c @@ -0,0 +1,86 @@ +#include // Header File For The GLUT Library +#include // Header File For The OpenGL32 Library +#include // Header File For The GLu32 Library + + +void DrawSlash(float xrot, float yrot, float zrot){ + + glRotatef(xrot, 1.0f, 0.0f, 0.0f); + glRotatef(yrot, 0.0f, 1.0f, 0.0f); + glRotatef(zrot, 0.0f, 0.0f, 1.0f); + + // draw a square (quadrilateral) + glBegin(GL_QUADS); // start drawing a polygon (4 sided) + + // Down + // Front Face (note that the texture's corners have to match the quad's corners) + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + + // Back Face + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Left Of The Texture and Quad + + // Bottom Face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Right Of The Texture and Quad + + // Right face + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.4f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.4f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + + // Left Face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, -0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, -0.5f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Top Left Of The Texture and Quad + + // Up + // Front Face (note that the texture's corners have to match the quad's corners) + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + + // Back Face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Left Of The Texture and Quad + + // Top Face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + + // Left Face + glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad + + // Right face + glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.2f, 0.0f, 0.5f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.2f, 0.0f, -0.5f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.4f, 0.5f, -0.5f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.4f, 0.5f, 0.5f); // Top Left Of The Texture and Quad + + glEnd(); // done with the polygon + + + glRotatef(xrot,-1.0f, 0.0f, 0.0f); + glRotatef(yrot, 0.0f,-1.0f, 0.0f); + glRotatef(zrot, 0.0f, 0.0f,-1.0f); +} + +/* vim: set et sw=4 ts=4: */ + diff --git a/lesson02/slash.h b/lesson02/slash.h new file mode 100644 index 0000000..61f10e1 --- /dev/null +++ b/lesson02/slash.h @@ -0,0 +1,11 @@ +#ifndef SLASH_H +#define SLASH_H + +/* + * Draw a textured 2 boxed slash + * rotate the object with the 3 args + */ + +void DrawSlash(float xrot, float yrot, float zrot); + +#endif diff --git a/lesson02/texture.bmp b/lesson02/texture.bmp index 59143707f897dcc17c96cc24f47978cbbd02354d..89184101b39154467ce0bd8369b54cc3863a3ff4 100644 GIT binary patch literal 196730 zcmeI5JCYp95kzOXB1I~^1@5p4B`Q3{3e>3Wd2ml~2A`Ul>dNX&kDo`Cj{%12?2O3B z=dTAa*na-__g^o+zr20@_4@O_Zx6ry`1#w*Ki^)xe*OOPkH5cs|M}zf%gZ1C`p^G< zJ~K)~iFw^&by4YZ}&o z(*H+*jaIzWwfEtH7N)PcF`xfDsR5JNrS<9n3?Elw)-1%GxfnAguZCt#!x|9y?*+M}kC(dkJ|)+mJTy#SbK`3NCjoM9vrFsMfs@ZRm08oU2BrRQ zd^$dOscY}UPcKYgbK^Sy`BOWY&@Qc4hm#?B-ZE<%)}Y9Lo@jtcywtV#0fsLr3Deiy zxWfOE2)qupOY7Ca>qZHE%$kNZNcTU1cH9wO>e~Cn-7%tbn7-!5x&BA6P3viw)~iF> zmAwu!YZ}%d(SI+PC4Icqwf8BxzVXm7ea(%t{5JxuEw@YS)uEOHe7afFum&mq!`v7O zz0|e$VW5G{5T>uWalHQ+F_J2~v|b%ZfM8>oH4SSJ>_3K!q{>TOdmj=Y*cflur~Qib zAHzjbWtY~g0|^jpjGqwh=Rbyvq{>TOdmj=Y*ck8EznT9SE|RME)FOX#oH>OA2sXy2 z3*O0p3>Qh&r_@UQCjo+uvB!8D|1n%7Rr}QH{3ii|jd6hS9{yvvNU9D}EApQN2sXws z#vAyL;UcLzPOZX!5+K+ZLyTAVAHzjbHB2qte-a?r7-twS?LUT#r0OiST>nXcU}HSN zcwPT7TqIRbQcLuo1PC_9bBq`DAHzjb^*psK|4D#gV@zSZqW>5!lB%iHQv4?Yf{ihY z@pArSxJasIQ;YYX1PC_90>*3kkKrPzT1YL}e-a?r7;6|WQh2e`=`zBtWn+LNIplAHzjb z6_Og{KM4?Qj3|us{$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