fish_working

fish_working - / / main.cpp / Template code for drawing an...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
//////////////////////////////////////////////////// // main.cpp // Template code for drawing an articulated figure. // CS 174A //////////////////////////////////////////////////// #ifdef _WIN32 #include <windows.h> #endif #include <GL/gl.h> #include <GL/glu.h> #include <math.h> #include <iostream> using namespace std; #include <GL/glut.h> #include "Ball.h" #include "FrameSaver.h" #include "Timer.h" /* Global Variables. The use of global variables is not considered good practice in programming and in most cases they can be avoided. However for graphics applications the need for global resources arises very frequently for you may require some data that is shared, by all callbacks. The best way to deal with this problem is to use a Singleton design pattern, yet we stick with globals here for simplicity. */ FrameSaver g_frameSaver; Timer g_timer; BallData *g_arcBall = NULL; int g_width = 300; int g_height = 300; int g_button = -1; float g_zoom = 1; int g_previousY = 0; int g_animate = 0; int g_recording = 0; void resetArcball(); void save_image(); void instructions(); void set_color(float r, float g, float b); const int STRLEN = 100; typedef char STR[STRLEN]; float AngleY=0.0; float OscY=0.0; float AngleTail=0.0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#define X 0 #define Y 1 #define Z 2 // The eye point and look-at point. double g_eye[3] = {0, 0.0, 50.0}; double g_ref[3] = {0.0, 0.0, 0.0}; double g_time = 0.0 ; ///////////////////////////////////////////////////// // PROC: drawCylinder() // DOES: this function // render a solid cylinder oriented along the Z axis. Both bases are of radius 1. // The bases of the cylinder are placed at Z = 0, and at Z = 1. // // // Don't change. ////////////////////////////////////////////////////// void drawCylinder(void) { static GLUquadricObj *cyl = NULL ; if( cyl == NULL ) { cyl = gluNewQuadric() ; } if( cyl == NULL ) { cerr << "Cannot allocate cylinder." << endl; return ; } gluQuadricDrawStyle(cyl,GLU_FILL) ; gluQuadricNormals(cyl,GLU_SMOOTH) ; gluCylinder(cyl,1.0,1.0,1.0,10,10) ; } ////////////////////////////////////////////////////// // PROC: drawCone() // DOES: this function // render a solid cone oriented along the Z axis with base radius 1. // The base of the cone is placed at Z = 0, and the top at Z = 1. // // Don't change. ////////////////////////////////////////////////////// void drawCone(void) { glutSolidCone(1,1,20,20) ; }
Background image of page 2
////////////////////////////////////////////////////// // PROC: drawSquareTex() // DOES: this function // draws a tesselated square. // // Don't change. ////////////////////////////////////////////////////// void drawSquareTex() { float i,j ; int NSUB = 50 ; float d = 1.0 / NSUB ; for( i = -0.5 ; i < 0.5 ; i += d ) for( j = -0.5 ; j < 0.5 ; j+= d ) { glBegin(GL_POLYGON) ; glNormal3f(0,0,1) ; float r = 1.0 ; //r = 0.5 + i+j ; float radius = 0.5 ; r = 0.5 + cos((i*i+j*j)*20*3.14) ; set_color(r,0.5,0.1) ; glVertex3f(i,j,0) ; glVertex3f(i+d,j,0) ; glVertex3f(i+d,j+d,0) ; glVertex3f(i,j+d,0) ; glEnd() ; } } ////////////////////////////////////////////////////// // PROC: drawCube()
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2011 for the course CS 174A taught by Professor Mayer during the Fall '10 term at UCLA.

Page1 / 11

fish_working - / / main.cpp / Template code for drawing an...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online