X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=b2ff6fb24091873e2e5f55027dd81f22f6f36246;hb=89f36d1ec3b4333aff27279598bf116a5a4a1256;hp=c546975575f95eeaded7137d644d5d0da4bb476c;hpb=1974078227af3b4da18ff6813f9cf5ed231d9205;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index c546975..b2ff6fb 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,49 @@ void makeMenu() { glutAttachMenu(GLUT_RIGHT_BUTTON); } +/** + * Called when window is resized + * @param width New width + * @param height New height + */ +void windowReshape(int width, int height) { + glViewport(0, 0, (GLsizei)width, (GLsizei)height); + printf("Width: %d, height: %d\n", width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60, 1, 0.1, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +/** + * 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 +522,23 @@ int main(int argc, char **argv) { for(int i=0; i