diff --git a/GL/matrix.c b/GL/matrix.c index d4ce3ff..771b82c 100644 --- a/GL/matrix.c +++ b/GL/matrix.c @@ -88,8 +88,8 @@ static void transpose(GLfloat* m) { static void recalculateNormalMatrix() { memcpy(NORMAL_MATRIX, stack_top(MATRIX_STACKS + (GL_MODELVIEW & 0xF)), sizeof(matrix_t)); - inverse((GLfloat*) NORMAL_MATRIX); transpose((GLfloat*) NORMAL_MATRIX); + inverse((GLfloat*) NORMAL_MATRIX); } void APIENTRY glMatrixMode(GLenum mode) { diff --git a/samples/lerabot01/main.c b/samples/lerabot01/main.c index 07333a1..173052e 100644 --- a/samples/lerabot01/main.c +++ b/samples/lerabot01/main.c @@ -151,6 +151,7 @@ void InitGL(int Width, int Height) // We call this right after our OpenG glEnable(GL_LIGHTING); glDisable(GL_LIGHT0); glEnable(GL_LIGHT1); + glEnable(GL_LIGHT2); GLfloat l1_pos[] = {5.0, 0.0, 1.0, 1.0}; GLfloat l1_diff[] = {1.0, 0.0, 0.0, 1.0}; @@ -160,8 +161,19 @@ void InitGL(int Width, int Height) // We call this right after our OpenG glLightfv(GL_LIGHT1, GL_DIFFUSE, l1_diff); glLightfv(GL_LIGHT1, GL_POSITION, l1_pos); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.0f); - glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0001); - glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.00001); + glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0003); + glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.000007); + + GLfloat l2_pos[] = {5.0, 0.0, 1.0, 1.0}; + GLfloat l2_diff[] = {0.0, 0.0, 1.0, 1.0}; + GLfloat l2_amb[] = {0.5, 0.5, 0.5, 1.0}; + + //glLightfv(GL_LIGHT1, GL_AMBIENT, l1_amb); + glLightfv(GL_LIGHT2, GL_DIFFUSE, l2_diff); + glLightfv(GL_LIGHT2, GL_POSITION, l2_pos); + glLightf(GL_LIGHT2, GL_CONSTANT_ATTENUATION, 1.0f); + glLightf(GL_LIGHT2, GL_LINEAR_ATTENUATION, 0.0003); + glLightf(GL_LIGHT2, GL_QUADRATIC_ATTENUATION, 0.000007); } /* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */ @@ -258,18 +270,28 @@ void DrawGLScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The View +<<<<<<< HEAD + //glTranslatef(-5.0f, -5.0f, -10.0f); + glTranslatef(-100.0f, 0.0f, -400.0f); +======= glTranslatef(-50.0f, 0.0f, -100.0f); GLfloat l1_pos[] = {50 + sin(delta) * 100.0f, 6.0, 5.0, 1.0}; delta += 0.03; +>>>>>>> 6942e597f4f2f8983d463b6358a069e2d0bfcb82 + GLfloat l1_pos[] = {100 + sin(delta) * 200.0f, 25.0, 1.0, 1.0}; glLightfv(GL_LIGHT1, GL_POSITION, l1_pos); - //glLightfv(GL_LIGHT1, GL_SPOT_EXPONENT, 3); DrawTexturedQuad(texture[0], l1_pos[0], l1_pos[1], l1_pos[2]); + GLfloat l2_pos[] = {100, 50 + sin(delta/2) * -150.0f, 1.0, 1.0}; + glLightfv(GL_LIGHT1, GL_POSITION, l2_pos); + DrawTexturedQuad(texture[0], l2_pos[0], l2_pos[1], l2_pos[2]); + + delta+= 0.03; for (int i = 0; i < 5; i++) - DrawTexturedQuad(texture[0], i * 20, 0.0f, 0.0f); // Draw the textured quad. + DrawTexturedQuad(texture[0], i * 50, 0.0f, 0.0f); // Draw the textured quad. // swap buffers to display, since we're double buffered. glKosSwapBuffers(); diff --git a/samples/nehe02/romdisk/flag1.png b/samples/nehe02/romdisk/flag1.png new file mode 100755 index 0000000..cb21e57 Binary files /dev/null and b/samples/nehe02/romdisk/flag1.png differ diff --git a/samples/textured_light_array/main.c b/samples/textured_light_array/main.c new file mode 100644 index 0000000..a609278 --- /dev/null +++ b/samples/textured_light_array/main.c @@ -0,0 +1,70 @@ +#include "gl.h" +#include "glu.h" +#include "glkos.h" + +/* A general OpenGL initialization function. Sets all of the initial parameters. */ +void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. +{ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black + glClearDepth(1.0); // Enables Clearing Of The Depth Buffer + glDepthFunc(GL_LESS); // The Type Of Depth Test To Do + glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); // Reset The Projection Matrix + + gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window + + glMatrixMode(GL_MODELVIEW); +} + +/* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */ +void ReSizeGLScene(int Width, int Height) +{ + if (Height == 0) // Prevent A Divide By Zero If The Window Is Too Small + Height = 1; + + glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); + glMatrixMode(GL_MODELVIEW); +} + + +/* The main drawing function. */ +void DrawGLScene() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer + glLoadIdentity(); // Reset The View + + for (int i = 0; i < 5; i++) { + glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units + // draw a square (quadrilateral) + glBegin(GL_QUADS); // start drawing a polygon (4 sided) + glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left + glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right + glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right + glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left + glEnd(); // done with the polygon + } + // swap buffers to display, since we're double buffered. + glKosSwapBuffers(); +} + +int main(int argc, char **argv) +{ + glKosInit(); + + InitGL(640, 480); + ReSizeGLScene(640, 480); + + while(1) { + DrawGLScene(); + } + + return 0; +}