1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back.
|
|
- Ursula Weaver
- 5 years ago
- Views:
Transcription
1 Karl Zachary Maier CSE 520 Homework 1 1. Write a shader program that animates the morphing of Figure 'A' to Figure 'B' and back. /* morph.cpp */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h> #define GLEW_STATIC 1 #include <GL/glew.h> #include <GL/glu.h> #include <GL/glut.h> #include <math.h> using namespace std; /* Global handles for the currently active program object, with its two shader objects */ GLuint programobject = 0; GLuint vertexshaderobject = 0; GLuint fragmentshaderobject = 0; static GLint win = 0; GLuint tparam; float tvalue; GLuint Vertex2Param; //parameters for sending to vertex shader int readshadersource(char *filename, GLchar **shader ) // Allocate memory to hold the source of our shaders. FILE *fp; int count, pos, shadersize; fp = fopen( filename, "r"); if (!fp ) pos = (int) ftell ( fp ); fseek ( fp, 0, SEEK_END ); shadersize = ( int ) ftell ( fp ) - pos; //move to end //calculates file size
2 fseek ( fp, 0, SEEK_SET ); //rewind to beginning if ( shadersize <= 0 ) printf("shader %s empty\n", filename); *shader = (GLchar *) malloc( shadersize + 1); // Read the source code count = (int) fread(*shader, 1, shadersize, fp); (*shader)[count] = '\0'; if (ferror(fp)) count = 0; fclose(fp); return 1; // public int installshaders(const GLchar *vertex, const GLchar *fragment) GLint vertcompiled, fragcompiled; // status values GLint linked; // Create a vertex shader object and a fragment shader object vertexshaderobject = glcreateshader(gl_vertex_shader); fragmentshaderobject = glcreateshader(gl_fragment_shader); // Load source code strings into shaders, compile and link glshadersource(vertexshaderobject, 1, &vertex, NULL); glshadersource(fragmentshaderobject, 1, &fragment, NULL); glcompileshader(vertexshaderobject); glgetshaderiv(vertexshaderobject, GL_COMPILE_STATUS, &vertcompiled); glcompileshader( fragmentshaderobject ); glgetshaderiv( fragmentshaderobject, GL_COMPILE_STATUS, &fragcompiled); if (!vertcompiled!fragcompiled) // Create a program object and attach the two compiled shaders
3 programobject = glcreateprogram(); glattachshader( programobject, vertexshaderobject); glattachshader( programobject, fragmentshaderobject); // Link the program object gllinkprogram(programobject); glgetprogramiv(programobject, GL_LINK_STATUS, &linked); if (!linked) // Install program object as part of current state gluseprogram(programobject); //check log GLchar log[1000]; GLsizei len; glgetshaderinfolog(vertexshaderobject, 1000, &len, log); printf("vert Shader Info Log: %s\n", log); glgetprograminfolog(programobject, 1000, &len, log); printf("program Info Log: %s\n", log); return 1; int init(void) glclearcolor(1, 1, 1, 1); const char *version; GLchar *VertexShaderSource, *FragmentShaderSource; int loadstatus = 0; version = (const char *) glgetstring(gl_version); if (version[0] < '2' version[1]!= '.') printf("this program requires OpenGL >= 2.x, found %s\n", version); exit(1); readshadersource( (char *) "morph.vert", &VertexShaderSource ); readshadersource((char *) "tests.frag", &FragmentShaderSource ); loadstatus = installshaders(vertexshadersource, FragmentShaderSource); printf("loadstatus=%d\n", loadstatus ); tparam = glgetuniformlocation ( programobject, "t" ); Vertex2Param = glgetattriblocation ( programobject, "Vertex2" );
4 return loadstatus; static void Reshape(int width, int height) glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); glfrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 25.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0f, 0.0f, -15.0f); void CleanUp(void) gldeleteshader(vertexshaderobject); gldeleteshader(fragmentshaderobject); gldeleteprogram(programobject); glutdestroywindow(win); static void Idle(void) //float t = glutget ( GLUT_ELAPSED_TIME ); // while ( t > 3000 ) t -= 3000; // gluniform1f( tparam, t ); //glutpostredisplay(); static void Key(unsigned char key, int x, int y) switch(key) case 27: CleanUp(); exit(0); break; case 't': if ( tvalue < 1 ) tvalue += 0.05; gluniform1f( tparam, tvalue ); printf("tvalue = %f\n", tvalue ); break; case 'T': if ( tvalue >= 0.05 ) tvalue -= 0.05; gluniform1f( tparam, tvalue ); break;
5 glutpostredisplay(); // void makefigures( float A[][3], float B[][3] ) A[0][0] = 0; A[0][1] = -6; A[1][0] = 1.5; A[1][1] = 0; A[2][0] = 4.5; A[2][1] = 0; A[3][0] = 6; A[3][1] = -6; A[4][0] = 4.25; A[4][1] = -6; A[5][0] = 4; A[5][1] = -4.5; A[6][0] = 2; A[6][1] = -4.5; A[7][0] = 1.75; A[7][1] = -6; A[8][0] = 0; A[8][1] = -6; B[0][0] = -1; B[0][1] = 2; B[1][0] = -1; B[1][1] = 5; B[2][0] = -1; B[2][1] = 8; B[3][0] = 2; B[3][1] = 8; B[4][0] = 2; B[4][1] = 5.25; B[5][0] = 0.5; B[5][1] = 5; B[6][0] = 2; B[6][1] = 4.75; B[7][0] = 2; B[7][1] = 2; B[8][0] = -1; B[8][1] = 2; void makecentertop( float C[][3], float D[][3]) C[0][0] = 2; C[0][1] = -3; C[1][0] = 2.5; C[1][1] = -1.75; C[2][0] = 3.5; C[2][1] = -1.75; C[3][0] = 4; C[3][1] = -3; C[4][0] = 2; C[4][1] = -3; D[0][0] = 0; D[0][1] = ; D[1][0] = 0; D[1][1] = 6.625; D[2][0] = 1; D[2][1] = 6.625; D[3][0] = 1; D[3][1] = ; D[4][0] = 0; D[4][1] = ; void makecenterbottom( float E[][3], float F[][3]) E[0][0] = 2; E[0][1] = -3; E[1][0] = 2.5; E[1][1] = -1.75; E[2][0] = 3.5; E[2][1] = -1.75; E[3][0] = 4; E[3][1] = -3; E[4][0] = 2; E[4][1] = -3; F[0][0] = 0; F[0][1] = 3.375; F[1][0] = 0; F[1][1] = ; F[2][0] = 1; F[2][1] = ; F[3][0] = 1; F[3][1] = 3.375; F[4][0] = 0; F[4][1] = 3.375; void display(void) GLfloat vec[4]; glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glclearcolor( 1.0, 1.0, 1.0, 0.0 ); //get white background color glcolor3f ( 1, 0, 0 ); //red, this will have no effect if shader is loaded
6 glpolygonmode( GL_FRONT, GL_LINE ); glpolygonmode( GL_BACK, GL_LINE ); int N = 9; int Nu = 5; GLfloat A[N][3], B[N][3]; //GLfloat C[N][3], D[N][3]; //GLfloat E[N][3], F[N][3]; GLfloat C[Nu][3], D[Nu][3]; GLfloat E[Nu][3], F[Nu][3]; makefigures( A, B ); makecentertop(c, D); makecenterbottom(e, F); gluniform1f ( tparam, tvalue ); glbegin ( GL_POLYGON ); for ( int i = 0; i < N; ++i ) glvertexattrib3fv ( Vertex2Param, &B[i][0] ); //send second object vertex to vertex shader glvertex2fv ( A[i] ); //vertex of first object glbegin ( GL_POLYGON ); for ( int i = 0; i < Nu; ++i ) glvertexattrib3fv ( Vertex2Param, &D[i][0] ); //send second object vertex to vertex shader glvertex2fv ( C[i] ); //vertex of first object glbegin ( GL_POLYGON ); for ( int i = 0; i < Nu; ++i ) glvertexattrib3fv ( Vertex2Param, &F[i][0] ); //send second object vertex to vertex shader glvertex2fv ( E[i] ); //vertex of first object glutswapbuffers(); glflush(); int main(int argc, char *argv[]) int success = 0; glutinit(&argc, argv); glutinitwindowposition( 0, 0); glutinitwindowsize(500, 500); glutinitdisplaymode(glut_rgb GLUT_DOUBLE GLUT_DEPTH); win = glutcreatewindow(argv[0]); glutreshapefunc(reshape); glutkeyboardfunc(key);
7 glutdisplayfunc(display); glutidlefunc(idle); // Initialize the "OpenGL Extension Wrangler" library glewinit(); success = init(); if ( success ) glutmainloop(); //morph.vert: morphing vertex uniform float t; //value provided by application program attribute vec4 Vertex2; void main(void) vec4 f = vec4 ( mix(gl_vertex.xy, Vertex2.xy, t ), 0.0, 1.0 ); //f = Vertex*(1-t) + Vertex2*t gl_position = gl_modelviewprojectionmatrix * f; //tests.frag //a minimal fragment shader void main(void) gl_fragcolor = vec4(0, 0, 1, 0); //blue
8
9 2. Write a shader program that animates the rotation of a square about the z-axis. (the square rotates when you are holding down the mouse and moving the mouse) / Karl Z Maier // HW1 Part 2 #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h> #define GLEW_STATIC 1 #include <GL/glew.h> #include <GL/glu.h> #include <GL/glut.h> #include <iostream> using namespace std; static float xrot = 0.0, yrot = 0.0, zrot = 0.0; // Angles to rotate the tetrahedron. GLuint programobject = 0; GLuint vertexshaderobject = 0; GLuint fragmentshaderobject = 0; static GLint win = 0; int readshadersource(char *filename, GLchar **shader ) // Allocate memory to hold the source of our shaders. FILE *fp; int count, pos, shadersize; fp = fopen( filename, "r"); if (!fp ) pos = (int) ftell ( fp ); fseek ( fp, 0, SEEK_END ); //move to end shadersize = ( int ) ftell ( fp ) - pos; //calculates file size fseek ( fp, 0, SEEK_SET ); //rewind to beginning if ( shadersize <= 0 ) printf("shader %s empty\n", filename);
10 *shader = (GLchar *) malloc( shadersize + 1); // Read the source code count = (int) fread(*shader, 1, shadersize, fp); (*shader)[count] = '\0'; if (ferror(fp)) count = 0; fclose(fp); return 1; void checkerror() char *infolog; int infolen, len; unsigned int shaders[2] = vertexshaderobject, fragmentshaderobject; char names[][50] = "Vertex shader", "Fragment shader"; for ( int i = 0; i < 2; i++ ) glgetshaderiv( shaders[i], GL_INFO_LOG_LENGTH, &infolen); if ( infolen > 0 ) infolog = (char *) malloc ( infolen + 1 ); glgetshaderinfolog ( shaders[i], infolen, &len, infolog ); printf("\n***** %s: %s\n", names[i], infolog ); delete infolog; // public int installshaders(const GLchar *vertex, const GLchar *fragment) GLint vertcompiled, fragcompiled; // status values GLint linked; // Create a vertex shader object and a fragment shader object vertexshaderobject = glcreateshader(gl_vertex_shader); fragmentshaderobject = glcreateshader(gl_fragment_shader); // Load source code strings into shaders, compile and link
11 glshadersource(vertexshaderobject, 1, &vertex, NULL); glshadersource(fragmentshaderobject, 1, &fragment, NULL); glcompileshader(vertexshaderobject); glgetshaderiv(vertexshaderobject, GL_COMPILE_STATUS, &vertcompiled); glcompileshader( fragmentshaderobject ); glgetshaderiv( fragmentshaderobject, GL_COMPILE_STATUS, &fragcompiled); checkerror(); printf("vertcompiled, fragcompiled: %d, %d\n", vertcompiled, fragcompiled); if (!vertcompiled!fragcompiled) // Create a program object and attach the two compiled shaders programobject = glcreateprogram(); glattachshader( programobject, vertexshaderobject); glattachshader( programobject, fragmentshaderobject); // Link the program object gllinkprogram(programobject); glgetprogramiv(programobject, GL_LINK_STATUS, &linked); printf("linked=%d\n"); if (!linked) // Install program object as part of current state gluseprogram(programobject); return 1; int init(void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glclearcolor( 1.0, 1.0, 1.0, 1.0 ); const char *version; GLchar *VertexShaderSource, *FragmentShaderSource; int loadstatus = 0; version = (const char *) glgetstring(gl_version); if (version[0] < '2' version[1]!= '.') printf("this program requires OpenGL > 2.x, found %s\n", version); exit(1); printf("version=%s\n", version );
12 readshadersource((char *) "vertex.vert", &VertexShaderSource ); readshadersource( (char *) "fragment.frag", &FragmentShaderSource ); loadstatus = installshaders(vertexshadersource, FragmentShaderSource); char names[][20] = "color0", "color1"; int loc[2]; for ( int i = 0; i < 3; i++ ) loc[i] = glgetuniformlocation (programobject, names[i] ); if ( loc[i] < 0 ) cout << "No such name: " << names[i] << endl; gluniform4f ( loc[0], 0.0, 1, 0, 1 ); gluniform4f ( loc[1], 0.0, 0.0, 1.0, 1 ); //Green //Blue return loadstatus; //drawing the Square void drawsquare() GLfloat vec[4]; int vertexvalueloc; vertexvalueloc = glgetattriblocation ( programobject, "vertexvalue" ); glbegin(gl_triangles); glvertexattrib1f(vertexvalueloc, 0.3); glvertex3f(1, 1, 1); glvertex3f(1, -1, 1); glvertex3f(-1, -1, 1); glvertexattrib1f(vertexvalueloc, 0.3); glvertex3f(-1, -1, 1); glvertex3f(-1, 1, 1); glvertex3f(1, 1, 1); static void Reshape(int width, int height) glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); glfrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0f, 0.0f, -15.0f);
13 void display(void) GLfloat vec[4]; glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glclearcolor( 1.0, 1.0, 1.0, 1.0 ); //white background color // Used to rotate glrotatef(zrot, 0.0f, 0.0f, 1.0f); drawsquare(); // Draws Square glutswapbuffers(); glflush(); void CleanUp(void) gldeleteshader(vertexshaderobject); gldeleteshader(fragmentshaderobject); gldeleteprogram(programobject); glutdestroywindow(win); // Making the square move void MouseMotion( int mousex, int mousey) GLint x = mousex; GLint y = mousey; if (x) zrot += 5.0; if (zrot > 360.0) zrot -= 360.0; glutpostredisplay(); glflush(); int main(int argc, char *argv[]) int success = 0; glutinit(&argc, argv); glutinitwindowposition( 0, 0); glutinitwindowsize(500, 500); glutinitdisplaymode(glut_rgb GLUT_DOUBLE GLUT_DEPTH); win = glutcreatewindow("hw1 Part 2"); glutreshapefunc(reshape); glutmotionfunc(mousemotion); glutdisplayfunc(display);
14 // Initialize the "OpenGL Extension Wrangler" library glewinit(); success = init(); printf("success=%d\n", success ); if ( success ) glutmainloop(); // prt2.vert attribute float vertexvalue; attribute float xaxis; attribute float yaxis; attribute float zaxis; varying float weight; //pass from vertex shader to fragment shader void main(void) vec4 v4; v4 = gl_vertex; mat4 m0 = mat4 ( 1, 0, 0, 0, // first col 0, 1, 0, 0, // 2nd col 0, 0, 1, 0, // 3rd col 0, 0, 0, 1 ); // 4th col weight = vertexvalue; v4 = m0 * v4; gl_position = gl_projectionmatrix * gl_modelviewmatrix * v4; //prt2.frag uniform vec4 color0; uniform vec4 color1; varying float weight; // from vertex shader void main(void) vec4 color = mix ( color0, color1, weight ); gl_fragcolor = color; // color
15
16 3. Write a vertex shader program that will bounce a sphere whose initial velocity and position are provided by the application program. Hint: You can use the reflect() function to compute the new direction of the ball after it hits the floor. Best if its vertical speed could be reduced by a constant value, the coefficient of restitutions, each time that it hits the floor. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h> #define GLEW_STATIC 1 #include <GL/glew.h> #include <GL/glu.h> #include <GL/glut.h> using namespace std; /* Global handles for the currently active program object, with its two shader objects */ GLuint programobject = 0; GLuint vertexshaderobject = 0; GLuint fragmentshaderobject = 0; static GLint win = 0; GLuint timeparam; GLuint velparam; //parameters for sending to vertex shader //parameters for sending to vertex shader int readshadersource(char *filename, GLchar **shader ) // Allocate memory to hold the source of our shaders. FILE *fp; int count, pos, shadersize; fp = fopen( filename, "r"); if (!fp ) pos = (int) ftell ( fp ); fseek ( fp, 0, SEEK_END ); shadersize = ( int ) ftell ( fp ) - pos; fseek ( fp, 0, SEEK_SET ); //move to end //calculates file size //rewind to beginning
17 if ( shadersize <= 0 ) printf("shader %s empty\n", filename); *shader = (GLchar *) malloc( shadersize + 1); // Read the source code count = (int) fread(*shader, 1, shadersize, fp); (*shader)[count] = '\0'; if (ferror(fp)) count = 0; fclose(fp); return 1; // public int installshaders(const GLchar *vertex, const GLchar *fragment) GLint vertcompiled, fragcompiled; // status values GLint linked; // Create a vertex shader object and a fragment shader object vertexshaderobject = glcreateshader(gl_vertex_shader); fragmentshaderobject = glcreateshader(gl_fragment_shader); // Load source code strings into shaders, compile and link glshadersource(vertexshaderobject, 1, &vertex, NULL); glshadersource(fragmentshaderobject, 1, &fragment, NULL); glcompileshader(vertexshaderobject); glgetshaderiv(vertexshaderobject, GL_COMPILE_STATUS, &vertcompiled); glcompileshader( fragmentshaderobject ); glgetshaderiv( fragmentshaderobject, GL_COMPILE_STATUS, &fragcompiled); if (!vertcompiled!fragcompiled) // Create a program object and attach the two compiled shaders programobject = glcreateprogram();
18 glattachshader( programobject, vertexshaderobject); glattachshader( programobject, fragmentshaderobject); // Link the program object gllinkprogram(programobject); glgetprogramiv(programobject, GL_LINK_STATUS, &linked); if (!linked) // Install program object as part of current state gluseprogram(programobject); //check log GLchar log[1000]; GLsizei len; glgetshaderinfolog(vertexshaderobject, 1000, &len, log); printf("vert Shader Info Log: %s\n", log); glgetprograminfolog(programobject, 1000, &len, log); printf("program Info Log: %s\n", log); return 1; int init(void) const char *version; GLchar *VertexShaderSource, *FragmentShaderSource; int loadstatus = 0; version = (const char *) glgetstring(gl_version); if (version[0]!= '2' version[1]!= '.') printf("this program requires OpenGL 2.x, found %s\n", version); // exit(1); readshadersource( (char *) "particle.vert", &VertexShaderSource ); readshadersource((char *) "tests.frag", &FragmentShaderSource ); loadstatus = installshaders(vertexshadersource, FragmentShaderSource); timeparam = glgetuniformlocation ( programobject, "time" ); velparam = glgetattriblocation ( programobject, "vel" ); return loadstatus; static void Reshape(int width, int height)
19 glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); glfrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 25.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0f, 0.0f, -15.0f); void CleanUp(void) gldeleteshader(vertexshaderobject); gldeleteshader(fragmentshaderobject); gldeleteprogram(programobject); glutdestroywindow(win); static void Idle(void) float t = glutget ( GLUT_ELAPSED_TIME ); while ( t > 3000 ) t -= 3000; gluniform1f( timeparam, t ); glutpostredisplay(); static void Key(unsigned char key, int x, int y) switch(key) case 27: CleanUp(); exit(0); break; glutpostredisplay(); void display(void) GLfloat vec[4]; glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glclearcolor( 1.0, 1.0, 1.0, 0.0 ); //get white background color glcolor3f ( 0, 0, 1 ); // Ball glpointsize ( 20 ); //"shoot" a particle at 45 degrees glenable(gl_point_smooth); //Smooths Point to a sphere
20 glbegin ( GL_POINTS ); //need "GL_POINTS"; "GL_POINT" does not work glvertexattrib3f ( velparam, 10, 10, 0 ); //send vel to vertex shader glvertex2f ( -15, 0 ); //starting position of particle glutswapbuffers(); glflush(); int main(int argc, char *argv[]) int success = 0; glutinit(&argc, argv); glutinitwindowposition( 0, 0); glutinitwindowsize(500, 500); glutinitdisplaymode(glut_rgb GLUT_DOUBLE GLUT_DEPTH); win = glutcreatewindow("ball"); glutreshapefunc(reshape); glutkeyboardfunc(key); glutdisplayfunc(display); glutidlefunc(idle); // Initialize the "OpenGL Extension Wrangler" library glewinit(); success = init(); if ( success ) glutmainloop(); //vert uniform float time; attribute vec3 vel; //value provided by application program //value provided by application program void main(void) float s = ; //scale factor float g = -10.0; float t; t = time / s; //time in ms vec4 object_pos = gl_vertex; //starting position object_pos.x = object_pos.x + vel.x*t; object_pos.y = object_pos.y + vel.y*t + g/(2.0)*t*t;
21 object_pos.z = object_pos.z + vel.z*t; gl_position = gl_modelviewprojectionmatrix * object_pos;
22 4. Approximate the shape of America by a polygon. Find from the Internet or other sources the population density of America. Write a shader program to show briefly America's population distribution with red color indicating an area densely populated, green indicating moderately populated, and white indicating sparsely populated. glcolor3f(1, 0, 0); glbegin (GL_POLYGON); glvertex2f(25, 25); glvertex2f(20, 25); glvertex2f(15, 35); glvertex2f(10, 40); glvertex2f(5, 50); glvertex2f(5, 60); glvertex2f(7.5, 70); glvertex2f(7.5, 80); glvertex2f(5, 85); glvertex2f(10, 90); glvertex2f(25, 90); glvertex2f(25, 25); glcolor3f(0, 1, 0); glbegin(gl_polygon); glvertex2f(25, 60); glvertex2f(65, 60); glvertex2f(65, 15); glvertex2f(60, 10); glvertex2f(55, 15); glvertex2f(50, 25); glvertex2f(45, 25); glvertex2f(40, 20); glvertex2f(35, 20); glvertex2f(25, 25); glvertex2f(25, 60); glcolor3f(1, 1, 1); glbegin(gl_polygon); glvertex2f(25, 60); glvertex2f(25, 90); glvertex2f(80, 90); glvertex2f(90, 87.5); glvertex2f(85, 80); glvertex2f(85, 40);
23 glvertex2f(65, 40); glvertex2f(65, 60); glvertex2f(25, 60); glcolor3f(1, 0, 0); glbegin(gl_polygon); glvertex2f(65, 15); glvertex2f(65, 40); glvertex2f(110, 40); glvertex2f(110, 15); glvertex2f(105, 15); glvertex2f(105, 20); glvertex2f(95, 20); glvertex2f(90, 15); glvertex2f(85, 15); glvertex2f(80, 5); glvertex2f(70, 15); glvertex2f(65, 15); glcolor3f(0, 1, 0); glbegin(gl_polygon); glvertex2f(85, 40); glvertex2f(85, 80); glvertex2f(95, 85); glvertex2f(100, 80); glvertex2f(105, 85); glvertex2f(100, 80); glvertex2f(110, 70); glvertex2f(110, 40); glvertex2f(85, 40); glcolor3f(1, 0, 0); glbegin(gl_polygon); glvertex2f(110, 55); glvertex2f(110, 80); glvertex2f(115, 85); glvertex2f(115, 70); glvertex2f(125, 80); glvertex2f(130, 80); glvertex2f(135, 85); glvertex2f(145, 85); glvertex2f(150, 80); glvertex2f(155, 70); glvertex2f(155, 65); glvertex2f(145, 55); glvertex2f(110, 55);
24 glcolor3f(1, 1, 1); glbegin(gl_polygon); glvertex2f(135, 85); glvertex2f(140, 95); glvertex2f(140, 100); glvertex2f(145, 105); glvertex2f(150, 100); glvertex2f(150, 90); glvertex2f(145, 85); glvertex2f(135, 80); glcolor3f(0, 1, 0); glbegin(gl_polygon); glvertex2f(110, 55); glvertex2f(145, 55); glvertex2f(155, 45); glvertex2f(155, 40); glvertex2f(145, 30); glvertex2f(110, 30); glvertex2f(110, 55); glcolor3f(1, 0, 0); glbegin(gl_polygon); glvertex2f(110, 15); glvertex2f(110, 30); glvertex2f(145, 30); glvertex2f(140, 25); glvertex2f(155, 15); glvertex2f(155, 5); glvertex2f(150, 5); glvertex2f(140, 10); glvertex2f(130, 20); glvertex2f(125, 15); glvertex2f(120, 20); glvertex2f(110, 15); // prt4.vertex attribute float vertexvalue; varying float weight; //pass from vertex shader to fragment shader void main(void)
25 vec4 v4; v4 = gl_vertex; mat4 m0 = mat4 ( 1, 0, 0, 0, // first col 0, 1, 0, 0, // 2nd col 0, 0, 1, 0, // 3rd col 0, 0, 0, 1 ); // 4th col weight = vertexvalue; v4 = m0 * v4; gl_position = gl_projectionmatrix * gl_modelviewmatrix * v4; I have completed all parts of the homework. Because my work is not perfect, I am giving myself 57 points.
Philip Calderon CSE 520 Lab 3 Color Shader
Philip Calderon CSE 520 Lab 3 Color Shader Summary: The purpose of lab 4 is to produce a pyramid tetrahedron that we are able to rotate it when clicked. Part 1: Color Tetrahedron Part 2: Rotation to show
More informationErik Anchondo cse 520 lab 4
Erik Anchondo 2-6-19 cse 520 lab 4 1. Wrote a glsl program that displays a colored tetrahedron. The tetrahedron starts to rotate on the x axis when the mouse button is clicked once. If the mouse button
More information2a. The triangles scale increases (expands) when the 'e' key is pressed and decreases (contracts) when the 'c' key is pressed.
Erik Anchondo 1-29-19 cse 520 lab 3 1. Wrote a shader program to display three colored triangles, with one of each triangle being red, green, and blue. The colors change which triangle they are applied
More information1)Write a shader program that renders a regular pentagon with textured image like the one shown below.
Andrew Yenalavitch CSE520 Winter 2015 Quiz 2 Report 1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Use the following provided image for the texture:
More information1) Here is the various stages of the tetrahedron:
Andrew Yenalavitch Homework 3 CSE 520 - Winter 2015 1) ( 20 points ) Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape.
More informationAn Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June
An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June Appendix D OpenGL Shading Language (GLSL) D.1 Extending OpenGL The OpenGL architecture we have presented
More informationYazhuo Liu Homework 3
Yazhuo Liu Homework 3 Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape. While it is shrinking and expanding, the color
More informationDuc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1
Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1 1. The endpoints of a given line are (0, 0) and (18, 6). Compute the first 4 values of y manually using Bresenham's Line Algorithm as x steps
More informationCS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008
CS559: Computer Graphics Lecture 12: OpenGL Li Zhang Spring 2008 Reading Redbook Ch 1 & 2 So far: 3D Geometry Pipeline Model Space (Object Space) Rotation Translation Resizing World Space M Rotation Translation
More informationComp 410/510 Computer Graphics Spring Programming with OpenGL Part 3: Shaders
Comp 410/510 Computer Graphics Spring 2018 Programming with OpenGL Part 3: Shaders Objectives Basic shaders - Vertex shader - Fragment shader Programming shaders with GLSL Finish first program void init(void)
More informationLecture 3. Understanding of OPenGL programming
Lecture 3 Understanding of OPenGL programming What is OpenGL GL: stands for Graphic Library Software interface for rendering purposes for 2D or 3D geometric data objects. Various Pieces gl: The basic libraries.
More informationSource code: #include <iostream>
Andrew Yenalavitch Homework 4 CSE 520 - Winter 2015 1. ( 10 points ) Write a program that finds the knot vector ( u 0,..., u n-1 ) of a B-spline. It asks for 'number of control points' and 'degree of spline'
More informationFAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL
FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM 3213 - INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4 C++ - OpenGL Part 1- C++ - Texture Mapping 1. Download texture file and put it into your current folder
More informationThis Lecture. Why OpenGL? Introduction to OpenGL. Programmer s View
Foundations of Computer Graphics Overview and Motivation This Lecture Introduction to OpenGL and simple demo code mytest1.cpp ; you compiled mytest3.cpp for HW 0 I am going to show (and write) actual code
More informationC++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson
C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson Syllabus 1) First program and introduction to data types and control structures with applications for games learning how to use the programming
More informationComputer Graphics (CS 543) Lecture 3b: Shader Setup & GLSL Introduction
Computer Graphics (CS 543) Lecture 3b: Shader Setup & GLSL Introduction Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) OpenGL function format function name gluniform3f(x,y,z)
More informationTo Do. Demo: Surreal (HW 3) This Lecture. Introduction to OpenGL. Outline. Foundations of Computer Graphics (Spring 2012)
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 6: OpenGL 1 http://inst.eecs.berkeley.edu/~cs184 To Do HW 1 due on Thu Must find partners for HW 2 (if problems, speak to TAs during section).
More informationExercise 1 Introduction to OpenGL
Exercise 1 Introduction to OpenGL What we are going to do OpenGL Glut Small Example using OpenGl and Glut Alexandra Junghans 2 What is OpenGL? OpenGL Two Parts most widely used and supported graphics API
More informationObjectives. Programming with OpenGL Part 5: More GLSL. Program Object. Reading a Shader. Shader Reader. Linking Shaders with Application
Objectives Programming with OpenGL Part : More GLSL CS Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Coupling shaders to applications - Reading - Compiling - Linking
More informationGraphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++
Computer Graphics Graphics Programming August 31, 2005 Contents Our Goal in This Chapter Programming of the Sierpinski gasket How To? Programming with OpenGL and C/C++ OpenGL API (Application Programmer
More informationAn Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June
An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June Chapter 19 OpenGL Shading Language (GLSL) 19.1 Extending OpenGL The OpenGL architecture we have
More informationUsing OpenGL with CUDA
Using OpenGL with CUDA Installing OpenGL and GLUT; compiling with nvcc Basics of OpenGL and GLUT in C Interoperability between OpenGL and CUDA OpenGL = Open Graphic Library creation of 3D graphic primitives
More informationTo Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)
Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1 http://www.cs.columbia.edu/~cs4160 To Do Start thinking (now) about HW 3. Milestones are due soon. Course Course 3D Graphics Pipeline 3D Graphics
More informationCS621 Lab 1 Name: Ihab Zbib
CS621 Lab 1 Name: Ihab Zbib 1) The program draw.cpp draws two rectangles and two triangles. The program compiles and executes successfully. What follows are the snap shots of the output. Illustration 1:
More informationCS 4204 Computer Graphics
CS 4204 Computer Graphics OpenGL Basics Yong Cao Virginia Tech References: 2001 Siggraph, An Interactive Introduction to OpenGL Programming, Dave Shreiner,Ed Angel, Vicki Shreiner Official Presentation
More information20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:
1 1. 1 #include 2 #include 3 Program 1 (OpenGL Sample016) 4 // 5 static int MouseX = 0; // X 6 static int MouseY = 0; // Y 7 static float SpinX = 0; // X 8 static float SpinY = 0;
More informationDrawing Primitives. OpenGL basics
CSC 706 Computer Graphics / Dr. N. Gueorguieva 1 OpenGL Libraries Drawing Primitives OpenGL basics OpenGL core library OpenGL32 on Windows GL on most unix/linux systems (libgl.a) OpenGL Utility Library
More information6. Make use of glviewport() to display two sine curves on the same screen, one on the
Duc Nguyen CSE-420: Computer Graphics 10/17/18 1. Modify lines.cpp to display lines in the following patterns: a. a long dash and a dot, (.. ) b. two close dots followed by a distant dot (...... ) 2. Modify
More informationCS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008
CS559: Computer Graphics Lecture 2: OpenGL Transformation Li Zhang Spring 28 Today Transformation in OpenGL Reading Chapter 3 Last time Primitive Details glpolygonmode(glenum face, GLenum mode); face:
More informationProgramming with OpenGL Part 5: More GLSL. Ed Angel Professor Emeritus of Computer Science University of New Mexico
Programming with OpenGL Part 5: More GLSL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 Objectives Coupling shaders to applications - Reading - Compiling - Linking Vertex Attributes
More informationOpenGL for dummies hello.c #include int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize (250, 250); glutinitwindowposition
More informationUNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M
UNIT 7 LIGHTING AND SHADING 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M Ans: Phong developed a simple model that can be computed rapidly It considers three
More informationIntroduction to Computer Graphics with OpenGL/GLUT
Introduction to Computer Graphics with OpenGL/GLUT What is OpenGL? A software interface to graphics hardware Graphics rendering API (Low Level) High-quality color images composed of geometric and image
More informationComputer Graphics Introduction to OpenGL
Computer Graphics 2015 3. Introduction to OpenGL Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-09-28 2. 2D Graphics Algorithms (cont.) Rasterization Computer Graphics @ ZJU Hongxin Zhang,
More informationAssignment 1. Simple Graphics program using OpenGL
Assignment 1 Simple Graphics program using OpenGL In this assignment we will use basic OpenGL functions to draw some basic graphical figures. Example: Consider following program to draw a point on screen.
More informationLectures OpenGL Introduction
Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is
More informationAnnouncement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12
Announcement Homework 1 has been posted in dropbox and course website Due: 1:15 pm, Monday, September 12 Today s Agenda Primitives Programming with OpenGL OpenGL Primitives Polylines GL_POINTS GL_LINES
More informationToday s Agenda. Shaders fundamentals. Programming with shader-based OpenGL
Today s Agenda Shaders fundamentals Programming with shader-based OpenGL Shaders Like a function call data are passed in, processed, and passed back out -- Shreiner et al, OpenGL Programming Guide GLSL
More informationTeacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using
Teacher Assistant : Tamir Grossinger email: tamirgr@gmail.com Reception hours: by email - Building 37 / office -102 Assignments: 4 programing using C++ 1 theoretical You can find everything you need in
More informationCSE 4431/ M Advanced Topics in 3D Computer Graphics. TA: Margarita Vinnikov
CSE 4431/5331.03M Advanced Topics in 3D Computer Graphics TA: Margarita Vinnikov mvinni@cse.yorku.ca What do we need to do to use shaders in our program? Shaders Work flow For multiple shaders 1. Create
More information1 /* 4 C:\opencv\build\include. 6 C:\opencv\build\x86\vc10\lib
1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - > 8 (240 O p e n C V ) 9 opencv_core240d.lib 10 opencv_imgproc240d.lib
More informationChapter 13 Selection and Feedback
OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 13 Selection and Feedback Chapter Objectives After reading this chapter, you ll be able to do the following: Create applications that
More informationProgramming with OpenGL Part 3: Three Dimensions
Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Objectives Develop a more sophisticated
More informationComputer Graphics. OpenGL
Computer Graphics OpenGL What is OpenGL? OpenGL (Open Graphics Library) is a library for computer graphics It consists of several procedures and functions that allow a programmer to specify the objects
More informationComputer graphics MN1
Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? How do I use it? Rendering pipeline Points, vertices, lines,, polygons Matrices and transformations Lighting and shading Code
More informationThis Lecture. Introduction to OpenGL. Outline. Why OpenGL? Programmer s View. Foundations of Computer Graphics
Foundations of Computer Graphics Overview and Motivation This Lecture Introduction to OpenGL and simple demo code mytest1.cpp ; you compiled mytest3.cpp for HW 0 I am going to show (and write) actual code
More informationBasic Graphics Programming
15-462 Computer Graphics I Lecture 2 Basic Graphics Programming Graphics Pipeline OpenGL API Primitives: Lines, Polygons Attributes: Color Example January 17, 2002 [Angel Ch. 2] Frank Pfenning Carnegie
More informationPrecept 2 Aleksey Boyko February 18, 2011
Precept 2 Aleksey Boyko February 18, 2011 Getting started Initialization Drawing Transformations Cameras Animation Input Keyboard Mouse Joystick? Textures Lights Programmable pipeline elements (shaders)
More informationBooks, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D
Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D CS334 Spring 2012 Daniel G. Aliaga Department of Computer Science Purdue University Computer Graphics Pipeline Geometric Primitives
More informationAndrew Yenalavitch Homework 1 CSE Fall 2014
Andrew Yenalavitch Homework 1 CSE 420 - Fall 2014 1.) ( 20 points ) In the class, we have discussed how to draw a line given by y = m x + b using Besenham's algorithm with m 1. Extend the algorithm to
More informationC OMPUTER G RAPHICS Thursday
C OMPUTER G RAPHICS 2017.04.27 Thursday Professor s original PPT http://calab.hanyang.ac.kr/ Courses Computer Graphics practice3.pdf TA s current PPT not uploaded yet GRAPHICS PIPELINE What is Graphics
More informationRECITATION - 1. Ceng477 Fall
RECITATION - 1 Ceng477 Fall 2007-2008 2/ 53 Agenda General rules for the course General info on the libraries GLUT OpenGL GLUI Details about GLUT Functions Probably we will not cover this part 3/ 53 General
More informationInformation Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)
11(40) Information Coding / Computer Graphics, ISY, LiTH OpenGL where it fits what it contains how you work with it 11(40) OpenGL The cross-platform graphics library Open = Open specification Runs everywhere
More informationIntroduction to OpenGL
Introduction to OpenGL Tutorial 1: Create a window and draw a 2D square Introduction: The aim of the first tutorial is to introduce you to the magic world of graphics based on the OpenGL and GLUT APIs.
More informationLecture 3. Programming with OpenGL GLUT + GLEW. CS 354 Computer Graphics Sunday, January 20, 13
Lecture 3 Programming with OpenGL 3.1 + GLUT + GLEW OpenGL The success of GL lead to OpenGL (1992), a platform-independent API that was - Easy to use - Close enough to the hardware to get excellent performance
More informationThe GLSL API. Mike Bailey. Oregon State University. Geometry Shader. Program. The GLSL Shader-creation Process. create. compile. Vertex.
The GLSL API Mike Bailey Oregon State University Program The GLSL -creation Process create compile Source read Source read Program link Use create compile Source read create compile 1 Initializing the
More informationBooks, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt
Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt CS334 Fall 2015 Daniel G. Aliaga Department of Computer Science Purdue University Books (and by now means complete ) Interactive Computer
More informationComputer Graphics Primitive Attributes
Computer Graphics 2015 4. Primitive Attributes Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-10-12 Previous lessons - Rasterization - line - circle /ellipse? => homework - OpenGL and
More information2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-
2.1 What is OpenGL? -23-2. OpenGL -I - Device-independent, application program interface (API) to graphics hardware - 3D-oriented - Event-driven Things OpenGL can do: - wireframe models - depth-cuing effect
More informationDisplay Lists in OpenGL
Display Lists in OpenGL Display lists are a mechanism for improving performance of interactive OpenGL applications. A display list is a group of OpenGL commands that have been stored for later execution.
More informationAnnouncements OpenGL. Computer Graphics. Spring CS4815
Computer Graphics Spring 2017-2018 Outline 1 2 Tutes and Labs Tute02, vector review (see matrix) Week02 lab Lab Marking 10 labs in total each lab worth 3% of overall grade marked on attendance and completion
More informationGraphics Programming
Graphics Programming 3 rd Week, 2011 OpenGL API (1) API (application programming interface) Interface between an application program and a graphics system Application Program OpenGL API Graphics Library
More informationCMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013
CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013 Reading: See any standard reference on OpenGL or GLUT. Basic Drawing: In the previous lecture, we showed how to create a window in GLUT,
More information// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations
#include int main(int argc, char** argv) { glutinit(&argc, argv); Typical OpenGL/GLUT Main Program // GLUT, GLU, and OpenGL defs // program arguments // initialize glut and gl // double buffering
More informationLecture 09: Shaders (Part 1)
Lecture 09: Shaders (Part 1) CSE 40166 Computer Graphics Peter Bui University of Notre Dame, IN, USA November 9, 2010 OpenGL Rendering Pipeline OpenGL Rendering Pipeline (Pseudo-Code) 1 f o r gl_vertex
More informationAnnouncements OpenGL. Computer Graphics. Autumn 2009 CS4815
Computer Graphics Autumn 2009 Outline 1 Labs 2 Labs Outline 1 Labs 2 Labs Labs Week02 lab Marking 8 10 labs in total each lab worth 2 3% of overall grade marked on attendance and completion of lab completed
More informationTo Do. Demo: Surreal (now 15+ years ago) This Lecture. Outline. Computer Graphics. CSE 167 [Win 19], Lecture 6: OpenGL 1 Ravi Ramamoorthi
Computer Graphics CSE 167 [Win 19], Lecture 6: OpenGL 1 Ravi Ramamoorthi http://viscomp.ucsd.edu/classes/cse167/wi19 To Do HW 2 (much) more difficult than HW 1 Will cover all needed material mostly Tue
More informationIntroduction to OpenGL: Part 2
Introduction to OpenGL: Part 2 Introduction to OpenGL: Part 2 A more complex example recursive refinement Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous
More information... Print PROGRAMS\Final Project final\planes\planeshoot.c 1
... Print PROGRAMS\Final Project final\planes\planeshoot.c 1 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include
More informationComputer Graphics. Making Pictures. Computer Graphics CSC470 1
Computer Graphics Making Pictures Computer Graphics CSC470 1 Getting Started Making Pictures Graphics display: Entire screen (a); windows system (b); [both have usual screen coordinates, with y-axis y
More informationCameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field
Cameras (and eye) Ideal Pinhole Real Pinhole Real + lens Depth of field 1 Z-buffer How do we draw objects? Polygon Based Fast Raytracing Ray/Object intersections Slow Copyright Pixar 2 Raytracing for each
More informationCOMPUTER GRAPHICS LAB # 3
COMPUTER GRAPHICS LAB # 3 Chapter 2: COMPUTER GRAPHICS by F.S HILLs. Initial steps in drawing figures (polygon, rectangle etc) Objective: Basic understanding of simple code in OpenGL and initial steps
More informationFourier Series. Given a periodic function, x(t), (-T <t <T): + b n sin n t T. a n cos n t T. 2 a 0 + Z T. a n = 1 T. x(t) cos n t T. b n = 1 T.
x(t) = 1 1X 2 a 0 + Fourier Series Given a periodic function, x(t), (-T
More informationInteraction Computer Graphics I Lecture 3
15-462 Computer Graphics I Lecture 3 Interaction Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations January 21, 2003 [Angel Ch. 3] Frank Pfenning Carnegie Mellon
More informationCS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008
CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008 2008/2/3 Slide 2 I Am Your TA Name : Wei-Wen Wen Feng 4th Year Graduate Student in Graphics I will be Holding discussion/tutorial
More informationBasic Graphics Programming
CSCI 480 Computer Graphics Lecture 2 Basic Graphics Programming January 11, 2012 Jernej Barbic University of Southern California http://www-bcf.usc.edu/~jbarbic/cs480-s12/ Graphics Pipeline OpenGL API
More informationComputer Graphics. Bing-Yu Chen National Taiwan University
Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering
More informationObjectives. Open GL Shading Language (GLSL)
Open GL Shading Language (GLSL) Objectives Shader applications Vertex shaders Fragment shaders Programming shaders Cg GLSL Coupling GLSL to Applications Example applications 1 Vertex Shader Applications
More information11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)
CSCI 420 Computer Graphics Lecture 2 Basic Graphics Programming Teaching Assistant Yijing Li Office hours TBA Jernej Barbic University of Southern California Graphics Pipeline OpenGL API Primitives: Lines,
More informationComputer Graphics Course 2005
Computer Graphics Course 2005 Introduction to GLUT, GLU and OpenGL Administrative Stuff Teaching Assistant: Rony Goldenthal Reception Hour: Wed. 18:00 19:00 Room 31 (Ross 1) Questions: E-mail: cg@cs Newsgroups:
More informationGL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW
OpenGL Syntax Functions have prefix gl and initial capital letters for each word glclearcolor(), glenable(), glpushmatrix() glu for GLU functions glulookat(), gluperspective() constants begin with GL_,
More informationComp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program
Comp 410/510 Computer Graphics Spring 2017 Programming with OpenGL Part 2: First Program Objectives Refine the first program Introduce a standard program structure - Initialization Program Structure Most
More informationProgramming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall
Programming with OpenGL Part 2: Complete Programs 91.427 Computer Graphics I, Fall 2008 1 1 Objectives Refine first program Alter default values Introduce standard program structure Simple viewing 2-D
More informationLecture 4 of 41. Lab 1a: OpenGL Basics
Lab 1a: OpenGL Basics William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/courses/cis636 Instructor
More informationCS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu
CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II Emmanuel Agu Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize toolkit, set display mode and create window glutinit(&argc,
More informationERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL
ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO SANTA BARBARA SANTA CRUZ EECS 104 Fundamentals of Computer Graphics OpenGL Slides courtesy of Dave Shreine, Ed Angel and Vicki Shreiner
More informationOpenGL/GLUT Intro. Week 1, Fri Jan 12
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner OpenGL/GLUT Intro Week 1, Fri Jan 12 http://www.ugrad.cs.ubc.ca/~cs314/vjan2007 News Labs start next week Reminder:
More informationLectures Display List
Lectures Display List By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is it? What
More informationBOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR
COMPUTER GRAPHICS LECTURE 07 BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM /* * GL07BouncingBall.cpp: A ball bouncing inside the window */ #include // for MS Windows #include
More informationby modifying the glutinitwindowsize() function you can change the screen size to whatever you please.
Zoe Veale Lab 2 Draw2 part 1: I edited the glutinitwindowsize() function tom change the size of my screen window. int main(int argc, char** argv) glutinit(&argc, argv); //initialize toolkit glutinitdisplaymode
More informationCSE4030 Introduction to Computer Graphics
CSE4030 Introduction to Computer Graphics Dongguk University Jeong-Mo Hong Week 2 The first step on a journey to the virtual world An introduction to computer graphics and interactive techniques How to
More informationInteraction. CSCI 480 Computer Graphics Lecture 3
CSCI 480 Computer Graphics Lecture 3 Interaction January 18, 2012 Jernej Barbic University of Southern California Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations
More informationComputer Graphics (CS 4731) & 2D Graphics Systems
Computer Graphics (CS 4731) Lecture 4: Shader Setup & 2D Graphics Systems Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Recall: OpenGL Program: Shader Setup initshader(
More informationOpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders
OpenGL pipeline Evolution and OpenGL Shading Language (GLSL) Part 2/3 Vertex and Fragment Shaders Prateek Shrivastava CS12S008 shrvstv@cse.iitm.ac.in 1 GLSL Data types Scalar types: float, int, bool Vector
More informationGraphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:
Graphics Programming Chapter 2 Introduction: - Our approach is programming oriented. - Therefore, we are going to introduce you to a simple but informative problem: the Sierpinski Gasket - The functionality
More informationChapter 7 Display Lists
OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 7 Display Lists Chapter Objectives After reading this chapter, you ll be able to do the following: Understand how display lists can
More informationAn Overview GLUT GLSL GLEW
OpenGL, GLUT, GLEW, GLSL An Overview GLUT GLEW GLSL Objectives Give you an overview of the software that you will be using this semester OpenGL, GLUT, GLEW, GLSL What are they? How do you use them? What
More informationBob s Concise Introduction to Doxygen
Bob s Concise Introduction to Doxygen by Robert S Laramee Visual and Interactive Computing Group Department of Computer Science Swansea University Swansea, Wales, UK 1 Comment Standard February 14, 2011
More informationOpenGL refresher. Advanced Computer Graphics 2012
Advanced Computer Graphics 2012 What you will see today Outline General OpenGL introduction Setting up: GLUT and GLEW Elementary rendering Transformations in OpenGL Texture mapping Programmable shading
More informationgvirtualxray Tutorial 01: Creating a Window and an OpenGL Context Using GLUT
gvirtualxray Tutorial 01: Creating a Window and an OpenGL Context Using GLUT Dr Franck P. Vidal 4 th September 2014 1 Contents Table of contents 2 List of figures 3 List of listings 3 1 Introduction 4
More information