X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=4852a51833bdab7c197ce2516440fde0c0f28159;hb=71afe748d9068eefceef10fd828c95e3a4c65606;hp=c546975575f95eeaded7137d644d5d0da4bb476c;hpb=1974078227af3b4da18ff6813f9cf5ed231d9205;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index c546975..4852a51 100644 --- a/scene.c +++ b/scene.c @@ -1,9 +1,7 @@ -// compile this program using: -// gcc -O3 -Wall -std=c99 -o scene scene.c bitmap.c -lglut -// Or, with cygwin: (-mno-cygwin is only so the executable runs from windows) -// gcc -mno-cygwin -O3 -Wall -std=c99 -o scene scene.c bitmap.c -lglut32 -lglu32 -lopengl32 -// Or, use make via the supplied Makefile: (For cygwin, install the package for make) -// make +/** + * CITS2231 Graphics Scene Editor + * @author Ashley Tyndall (20915779) + */ #include #include @@ -460,13 +458,62 @@ void makeMenu() { glutAttachMenu(GLUT_RIGHT_BUTTON); } +/** + * Called when window is resized + * @param w New width + * @param h New height + */ +void windowReshape(int width, int height) { + glViewport(0, 0, (GLsizei)width, (GLsizei)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + if (width <= height) + gluPerspective(60, (GLfloat)width / (GLfloat) height, 0.1, 1000.0); + else + gluPerspective(60, (GLfloat)height / (GLfloat) width, 0.1, 1000.0); + glMatrixMode(GL_MODELVIEW); + + /*glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); /* switch matrix mode + glLoadIdentity(); + if (w <= h) + gluOrtho2D(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w, 2.0 * (GLfloat) h / (GLfloat) w); + else + gluOrtho2D(-2.0 * (GLfloat) w / (GLfloat) h, 2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0); + glMatrixMode(GL_MODELVIEW); /* return to modelview mode */ +} + +/** + * Called when mouse event occurs + * @param btn Mouse button + * @param state State of mouse button + * @param x Mouse x position + * @param y Mouse y position + */ +void mouse(int btn, int state, int x, int y) { + +} + /** * Display function */ void display() { - // You probably want to change both of the following. - glClear(GL_COLOR_BUFFER_BIT); - glFlush(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity(); + + glTranslatef(0.0f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 + + + glBegin(GL_QUADS); + glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red + 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(); + + glutSwapBuffers(); } /** @@ -488,12 +535,23 @@ int main(int argc, char **argv) { for(int i=0; i