CS293: Java Graphics with JOGL, Solutions
|
|
- Elvin Hardy
- 6 years ago
- Views:
Transcription
1 UNIVERSITY OF SURREY c B.Sc. Undergraduate Programmes in Computing B.Sc. Undergraduate Programmes in Mathematical Studies Level HE2 Examination CS293: Java Graphics with JOGL, s Time allowed: 2 hours Spring Semester 2007 Answer THREE out of FOUR questions. All questions have equal weight and there are 33 marks for each question.
2 CS/2293/13/SS06 Page 1 The following list of JOGL methods and fields may or may not prove useful in the exam questions. In this list we have stuck with the conventions for object names that were used in the labs. GL gl = drawable.getgl() GLU glu = new GLU() GLUT glut = new GLUT() glshademodel glloadidentity glviewport(x,y,h,w) glu.glulookat (camerax, cameray, cameraz, lookatx, lookaty, lookatz, upx, upy, upz) glutwireteapot glmatrixmode gluperspective glbegin glvertex3f gltranslatef glrotated glpushmatrix glpopmatrix GL.GL PROJECTION GL.GL MODELVIEW glmaterialfv GL.GL SPECULAR GL.GL SHININESS gllightfv glenable SEE NEXT PAGE
3 CS/2293/13/SS06 Page 2 1. (a) Consider the following JOGL code snipet: public void init(glautodrawable drawable) { /* missing code here */ Modify this method so that it sets the clear colour to black and sets the shading model to flat [5 marks] public void init(glautodrawable drawable) { GL gl = drawable.getgl(); // gl.glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); gl.glshademodel(gl.gl_flat); (b) Consider the following JOGL code snipet: public void reshape(glautodrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getgl( ); GLU glu = new GLU(); Modify this code snipet so that it correctly defines the perspective for the OpenGL canvas so that near is -1.0, far is 2.0, the aspect ratio is 1.0 and the field of view is 30. Also modify the code so that it defines the view port to map the canvas origin to (0,0) and scales the canvas to fit the width and height of the frame that it will appear in. Dont forget that the matrix mode needs to be set to projection when modifying perspectives, and reset to model view mode afterwards. [10 marks] public void reshape(glautodrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getgl( ); GLU glu = new GLU(); QUESTION 1 CONTINUES ON NEXT PAGE
4 CS/2293/13/SS06 Page 3 gl.glviewport(0, 0, width, height); gl.glmatrixmode(gl.gl_projection); gl.glloadidentity (); glu.gluperspective(30.0, 1.0, -1.0, 2.0); gl.glmatrixmode (GL.GL_MODELVIEW); (c) Modify the following code snippet so that it causes JOGL to display a wire teapot at the origin of width 3.0. [18 marks] public void display(glautodrawable drawable) { /* missing code goes here */ 3 marks per correct line of code till we hit 18 (so if they mess up on one line still get 18) public void display(glautodrawable drawable) { GL gl = drawable.getgl( ); GLU glu = new GLU(); GLUT glut = new GLUT(); gl.glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); gl.glclear(gl.gl_color_buffer_bit); gl.glcolor3f(1.0f, 1.0f, 1.0f); glut.glutwireteapot(0.3); SEE NEXT PAGE
5 CS/2293/13/SS06 Page 4 2. (a) Consider the following JOGL method: public synchronized void display(glautodrawable drawable) { GL gl = drawable.getgl(); gl.glclear(gl.gl_color_buffer_bit); gl.glloadidentity(); glu.glulookat(12,2,12, 0,0,0, 0,1,0); gl.glcolor3f(0.0f, 1.0f, 0.0f); float tor_dim1 = 0.9f; float tor_dim2 = 2.0f; int tor_simplex = 20; glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); This causes a single wire torus to appear on screen, with center at the origin. Modify the code so that three tori appear next to each other. The left torus must be the result of translating the original torus 5.5f to the left along the x-axis. The right torus must be the result of translating the original torus 5.5f to right along the x-axis. [10 marks] glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); gl.gltranslatef(tor_dist, 0, 0); glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); gl.gltranslatef(-1.0f * tor_dist, 0, 0); glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); QUESTION 2 CONTINUES ON NEXT PAGE
6 CS/2293/13/SS06 Page 5 (b) Next modify the display method so that if the JOGL code were run with an FPSanimator object, then the whole scene would rotate about the origin. To do this change the glulookat code in the display method so that the point of view will rotate around a circle radius 12.0, with origin at point (0, 0, 0), and constantly looking at the origin, with the y-axis as up. [10 marks] /* new fields added to start protected float rot_view = 0f, rot_add = 0.05f; */ gl.glloadidentity(); glu.glulookat(12*math.cos(rot_view / (Math.PI*2)), 2, 12*Math.sin(rot_view / (Math.PI*2)), 0,0,0, // what im looking at 0,1,0); // up vector addrot(); //new method listed below /* end of snipet for display method */ private void addrot() { rot_view += rot_add; if (rot_view > 360f) rot_view -= 360; (c) Finally modify the display method so that if the JOGL code were run with an FPSanimator object, then each torus would spin around its own center, but remains at the same relative location with respect to the other tori in the scene. [13 marks] /* as above but with these additional lines added to the tori, where spin is added as a new field to class */ gl.glcolor3f(0.0f, 1.0f, 0.0f); gl.glrotatef(-1.0f *spin, 0.0f, 0.0f, 1.0f); glut.glutwiretorus(tor_dim1, QUESTION 2 CONTINUES ON NEXT PAGE
7 CS/2293/13/SS06 Page 6 tor_dim2, tor_simplex, tor_simplex); gl.glcolor3f(0.0f, 0.0f, 1.0f); gl.gltranslatef(tor_dist, 0, 0); gl.glrotatef(spin, 0.0f, 0.0f, 1.0f); glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); gl.glcolor3f(1.0f, 0.0f, 0.0f); gl.gltranslatef(-1.0f * tor_dist, 0, 0); gl.glrotatef( spin, 0.0f, 0.0f, 1.0f); glut.glutwiretorus(tor_dim1, tor_dim2, tor_simplex, tor_simplex); spin += 0.2f; // or some other small amount SEE NEXT PAGE
8 CS/2293/13/SS06 Page 7 3. (a) Consider the following method: public void init_lights (GL gl) { FloatBuffer light_position1 = FloatBuffer.wrap(new float[] { 1.0f, 1.0f, 1.0f, 0.0f ); FloatBuffer light_ambient1 = FloatBuffer.wrap(new float[] { 0.99f, 0.0f, 0.0f, 1.0f ); gl.glshademodel(gl.gl_smooth); gl.gllightfv(gl.gl_light1, GL.GL_POSITION, light_position1); /* missing code goes here */ Complete the missing code so that the method properly enables lighting in JOGL for light source 1. Ensure that the light source has ambient settings as defined by light ambient1, and is set in position light position1. Make sure that the effect of using this method within the init method for a JOGL application would be to switch on lighting as indicated. Also make sure that all material is also given some appropriate ambient parameters so that it will reflect light from the light source. [10 marks] FloatBuffer mat_ambient1 = FloatBuffer.wrap(new float[] { 0.35f, 0.0f, 0.0f, 1.0f ); gl.glmaterialfv(gl.gl_front, GL.GL_AMBIENT, mat_ambient1); gl.gllightfv(gl.gl_light1, GL.GL_AMBIENT, light_ambient1); gl.gllightfv(gl.gl_light1, GL.GL_POSITION, light_position1); gl.glenable(gl.gl_light1); gl.glenable(gl.gl_lighting); (b) Next modify your code for init lights so that it also sets up a second light source. This time make the second light source have diffuse parameters set to RGBA values of {1.0f, 1.0f, 1.0f, 0.0f. Choose the position for the light source to be different from the first. Also give the material diffuse parameters of {1.0f, 0.0f, 0.0f, 0.0f. [10 marks] /* inserted before the gl.glenable(gl.gl_lighting); */ FloatBuffer light_position0 = FloatBuffer.wrap(new float[] { 1.0f, -1.0f, -1.0f, 0.0f ); QUESTION 3 CONTINUES ON NEXT PAGE
9 CS/2293/13/SS06 Page 8 FloatBuffer light_diffuse0 = FloatBuffer.wrap(new float[] { 1.0f, 1.0f, 1.0f, 0.0f ); FloatBuffer mat_diffuse0 = FloatBuffer.wrap(new float[] { 1.0f, 0.0f, 0.0f, 1.0f ); gl.glmaterialfv(gl.gl_front, GL.GL_DIFFUSE, mat_diffuse0); gl.gllightfv(gl.gl_light0, GL.GL_DIFFUSE, light_diffuse0); gl.gllightfv(gl.gl_light0, GL.GL_POSITION, light_position0); gl.glenable(gl.gl_light0); (c) Use the following JOGL fields: GL.GL FOG GL.GL FOG MODE GL.GL EXP GL.GL FOG COLOR GL.GL FOG DENSITY GL.GL FOG HINT GL.GL DONT CARE to fill in the missing values from the fogon method to produce a method for switching fog on within the display method of a JOGL application. [13 marks] public void fogon(gl gl) { gl.glenable(/* missing */); FloatBuffer fogcolor = FloatBuffer.wrap(new float[] {0.0f, 0.0f, 0.0f, 1.0f); gl.glfogi(/* missing */, /* missing */); gl.glfogfv(/* missing */, fogcolor); gl.glfogf(/* missing */, 0.2f); gl.glhint(/* missing */, /* missing */); gl.glclearcolor(0.0f, 0.0f, 0.0f, 1.0f); public void fogon(gl gl) { gl.glenable(gl.gl_fog); FloatBuffer fogcolor = FloatBuffer.wrap(new float[] {0.0f, 0.0f, 0.0f, 1.0f); gl.glfogi(gl.gl_fog_mode, GL.GL_EXP); gl.glfogfv(gl.gl_fog_color, fogcolor); gl.glfogf(gl.gl_fog_density, 0.2f); QUESTION 3 CONTINUES ON NEXT PAGE
10 CS/2293/13/SS06 Page 9 gl.glhint(gl.gl_fog_hint, GL.GL_DONT_CARE); gl.glclearcolor(0.0f, 0.0f, 0.0f, 1.0f); SEE NEXT PAGE
11 CS/2293/13/SS06 Page 10 Figure 1: Texture mapping example 4. Suppose we want to have a JOGL application that loads in four images and attaches them to geometric objects and then displays them as in Figure 1 (a) Change the init method below so that it uses a quadratic object to hold all the necessary parameters for texture mapping GLUT library objects. Use the GLU.GLU SMOOTH vlaue for setting the normal vector generator method. This will require three extra lines of code where shown. [8 marks] public void init(glautodrawable gldrawable) { GL gl = gldrawable.getgl(); displayversions (gl, glu); initlights(gl); // Initialize OpenGL Light try { loadgltextures(gl); // all textures propely loaded catch (IOException e) { throw new RuntimeException(e); gl.glshademodel(gl.gl_smooth); QUESTION 4 CONTINUES ON NEXT PAGE
12 CS/2293/13/SS06 Page 11 gl.glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); gl.glcleardepth(1.0); gl.glenable(gl.gl_depth_test); gl.gldepthfunc(gl.gl_lequal); gl.glhint(gl.gl_perspective_correction_hint, GL.GL_NICEST); /* set up quadratic */ /* set up normal vectors */ /* switch on automatic calculation for quadratic textures */ public void init(glautodrawable gldrawable) { GL gl = gldrawable.getgl(); displayversions (gl, glu); initlights(gl); // Initialize OpenGL Light try { loadgltextures(gl); // all textures propely loaded catch (IOException e) { throw new RuntimeException(e); gl.glshademodel(gl.gl_smooth); gl.glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); gl.glcleardepth(1.0); gl.glenable(gl.gl_depth_test); gl.gldepthfunc(gl.gl_lequal); gl.glhint(gl.gl_perspective_correction_hint, GL.GL_NICEST); quadratic = glu.glunewquadric(); glu.gluquadricnormals(quadratic, GLU.GLU_SMOOTH); glu.gluquadrictexture(quadratic, true); (b) For your new version of init what additional three lines of code are required to enable 2D texture mapping, and enable spherical mapping for all geometric objects. Recall that this will require setting values for GL S and GL T so that their texture generation mode is spherical mapping mode. [8 marks] QUESTION 4 CONTINUES ON NEXT PAGE
13 CS/2293/13/SS06 Page 12 gl.glenable(gl.gl_texture_2d); gl.gltexgeni(gl.gl_s, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP); gl.gltexgeni(gl.gl_t, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP); (c) The following code is meant to make a texture be attached to a square as shown by the middle square in Figure 1. Fill in the missing parts to correct the code. gl.glbindtexture(gl.gl_texture_2d, textures[1]); gl.gltranslatef(0.0f, 0.0f, bck -39.0f); gl.glscalef( ((float)imagew[filter])/((float)imageh[filter]), 1.0f, 1.0f); gl.glbegin(gl.gl_quads); gl.glnormal3f(0.0f, 0.0f, 1.0f); gl.gltexcoord2f(/* missing */); gl.glvertex3f(-15.0f, -15.0f, 15.0f); /* missing */; gl.glvertex3f(15.0f, -15.0f, 15.0f); /* missing */; gl.glvertex3f(15.0f, 15.0f, 15.0f); /* missing */; gl.glvertex3f(-15.0f, 15.0f, 15.0f); gl.glend(); Correct the code. [17 marks] gl.glbindtexture(gl.gl_texture_2d, textures[1]); gl.gltranslatef(0.0f, 0.0f, bck -39.0f); gl.glscalef( ((float)imagew[filter])/((float)imageh[filter]), 1.0f, 1.0f); gl.glbegin(gl.gl_quads); gl.glnormal3f(0.0f, 0.0f, 1.0f); gl.gltexcoord2f(0.0f, 0.0f); QUESTION 4 CONTINUES ON NEXT PAGE
14 CS/2293/13/SS06 Page 13 gl.glvertex3f(-15.0f, -15.0f, 15.0f); gl.gltexcoord2f(1.0f, 0.0f); gl.glvertex3f(15.0f, -15.0f, 15.0f); gl.gltexcoord2f(1.0f, 1.0f); gl.glvertex3f(15.0f, 15.0f, 15.0f); gl.gltexcoord2f(0.0f, 1.0f); gl.glvertex3f(-15.0f, 15.0f, 15.0f); gl.glend();
JOGL 3D GRAPHICS. Drawing a 3D line. In this chapter, let us see how to deal with 3D graphics.
http://www.tutorialspoint.com/jogl/jogl_3d_graphics.htm JOGL 3D GRAPHICS Copyright tutorialspoint.com In this chapter, let us see how to deal with 3D graphics. Drawing a 3D line Let us draw a simple line
More informationINF555. Fundamentals of 3D. Lecture 4: Debriefing: ICP (kd-trees) Homography Graphics pipeline. Frank Nielsen
INF555 Fundamentals of 3D Lecture 4: Debriefing: ICP (kd-trees) Homography Graphics pipeline Frank Nielsen nielsen@lix.polytechnique.fr ICP: Algorithm at a glance Start from a not too far initial transformation
More informationChapter 3 - Basic Mathematics for 3D Computer Graphics
Chapter 3 - Basic Mathematics for 3D Computer Graphics Three-Dimensional Geometric Transformations Affine Transformations and Homogeneous Coordinates OpenGL Matrix Logic Translation Add a vector t Geometrical
More informationAn Introduction to 2D OpenGL
An Introduction to 2D OpenGL January 23, 2015 OpenGL predates the common use of object-oriented programming. It is a mode-based system in which state information, modified by various function calls as
More informationFundamentals of 3D. Lecture 4: Debriefing: ICP (kd-trees) Homography Graphics pipeline. Frank Nielsen 5 octobre 2011
INF555 Fundamentals of 3D Lecture 4: Debriefing: ICP (kd-trees) Homography Graphics pipeline Frank Nielsen 5 octobre 2011 nielsen@lix.polytechnique.fr ICP: Iterative Closest Point Algorithm at a glance
More information3D Graphics in Java with Java Open GL - JOGL 2
3D Graphics in Java with Java Open GL - JOGL 2 Introduction Installing JOGL on Windows JOGL connection to Java: JOGL event listener Geometric transformations: viewport, projection, viewing transformations
More informationPearce Outline. OpenGL Background and History. Other Graphics Technology. Platform Specifics. The Drawing Process
Outline 433-380 Graphics and Computation Introduction to OpenGL OpenGL Background and History Other Graphics Technology Drawing Viewing and Transformation Lighting JOGL and GLUT Resources Some images in
More informationCOMP3421 Computer Graphics
COMP3421 Computer Graphics Introduction Angela Finlayson Email: angf@cse.unsw.edu.au Computer Graphics Algorithms to automatically render images from models. Light Camera hi mum Objects model image Computer
More informationDescribe the Orthographic and Perspective projections. How do we combine together transform matrices?
Aims and objectives By the end of the lecture you will be able to Work with multiple transform matrices Describe the viewing process in OpenGL Design and build a camera control APIs Describe the Orthographic
More informationMORE OPENGL. Pramook Khungurn CS 4621, Fall 2011
MORE OPENGL Pramook Khungurn CS 4621, Fall 2011 SETTING UP THE CAMERA Recall: OpenGL Vertex Transformations Coordinates specified by glvertex are transformed. End result: window coordinates (in pixels)
More informationCOMP3421. Introduction to 3D Graphics
COMP3421 Introduction to 3D Graphics 3D coordinates Moving to 3D is simply a matter of adding an extra dimension to our points and vectors: 3D coordinates 3D coordinate systems can be left or right handed.
More informationCOMP3421. Introduction to 3D Graphics
COMP3421 Introduction to 3D Graphics 3D coodinates Moving to 3D is simply a matter of adding an extra dimension to our points and vectors: 3D coordinates 3D coordinate systems can be left or right handed.
More informationCIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011
CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011 Lab 1a of 7 OpenGL Setup and Basics Fri 28 Jan 2011 Part 1a (#1 5) due: Thu 03 Feb 2011 (before midnight) The purpose of this
More informationComputer Graphics. Transformations. CSC 470 Computer Graphics 1
Computer Graphics Transformations CSC 47 Computer Graphics 1 Today s Lecture Transformations How to: Rotate Scale and Translate 2 Introduction An important concept in computer graphics is Affine Transformations.
More informationCS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.
CS4202: Test Name: 1. Write the letter corresponding to the library name next to the statement or statements that describe library. (4 points) A. GLUT contains routines that use lower level OpenGL commands
More informationSpring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013
Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013 PROJECT GOAL: Write a restricted OpenGL library. The goal of the project is to compute all the transformation matrices with your
More informationOpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL
OpenGL (euske) 1 OpenGL - 1.1 OpenGL 1. Client-Server Model 2. 3. 1.2 3D OpenGL (Depth-Buffer Algorithm Z-Buffer Algorithm) (polygon ) ( rendering) Client-Server Model X Window System ( GL ) GL (Indy O
More informationJOGL: An OpenGL Based Graphics Domain for PtolemyII Yasemin Demir
JOGL: An OpenGL Based Graphics Domain for PtolemyII Yasemin Demir JOGL Domain JOGL is a new experimental domain under development in PtolemyII. Handles geometry and transformation of 3D objects which relies
More informationNew topic for Java course: Introduction to 3D graphics programming
New topic for Java course: Introduction to 3D graphics programming with JOGL Dejan Mitrović Prof. Dr Mirjana Ivanović AGENDA 1. Motivation and goals 2. JOGL 3. Proposed subjects 4. Conclusions 2/29 1 1.1.
More informationAPI for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3
OpenGL Introduction Introduction OpenGL OpenGL is an API for computer graphics. Hardware-independent Windowing or getting input is not included in the API Low-level Only knows about triangles (kind of,
More informationIntroduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou
Introduction to OpenGL Transformations, Viewing and Lighting Ali Bigdelou Modeling From Points to Polygonal Objects Vertices (points) are positioned in the virtual 3D scene Connect points to form polygons
More informationCONSTRUCTION AND SIMULATION OF A ROBOT ARM WITH OPENGL
CENTRO UNIVERSITÁRIO DE BARRA MANSA ACADEMIC PRO-RECTORY COMPUTER ENGINEERING COURSE CONSTRUCTION AND SIMULATION OF A ROBOT ARM WITH OPENGL By: Leniel Braz de Oliveira Macaferi Wellington Magalhães Leite
More information1 (Practice 1) Introduction to OpenGL
1 (Practice 1) Introduction to OpenGL This first practical is intended to get you used to OpenGL command. It is mostly a copy/paste work. Try to do it smartly by tweaking and messing around with parameters,
More informationProgramming of Graphics
Peter Mileff PhD Programming of Graphics Introduction to OpenGL University of Miskolc Department of Information Technology OpenGL libraries GL (Graphics Library): Library of 2D, 3D drawing primitives and
More informationTransformations. Overview. Standard Transformations. David Carr Fundamentals of Computer Graphics Spring 2004 Based on Slides by E.
INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Transformations David Carr Fundamentals of Computer Graphics Spring 24 Based on Slides by E. Angel Feb-1-4 SMD159, Transformations 1 L Overview
More informationOverview CS Plans for this semester. References. CS 4600 Fall Prerequisites
Overview CS 4600 What is CS 4600? What should know (pre reqs)? What will you get out of this course? Chuck Hansen Website: www.eng.utah.edu/~cs4600 Thanks to Ed Angel and Jeff Parker for slides and materials
More informationCS Computer Graphics: Illumination and Shading I
CS 543 - Computer Graphics: Illumination and Shading I by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Illumination and Shading Problem: Model light/surface point interactions to determine
More informationCS Computer Graphics: Illumination and Shading I
CS 543 - Computer Graphics: Illumination and Shading I by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Illumination and Shading Problem: Model light/surface point interactions to determine
More informationGraphics and Visualization
International University Bremen Spring Semester 2006 Recap Representing graphic objects by homogenous points and vectors Using affine transforms to modify objects Using projections to display objects
More informationTransformations. Standard Transformations. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E. Angel
INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Transformations David Carr Virtual Environments, Fundamentals Spring 25 Based on Slides by E. Angel Jan-27-5 SMM9, Transformations 1 L Overview
More informationCS 591B Lecture 9: The OpenGL Rendering Pipeline
CS 591B Lecture 9: The OpenGL Rendering Pipeline 3D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination Spring 2007 Rui Wang 3D Polygon Rendering Many applications
More informationCS Simple Raytracer for students new to Rendering
CS 294-13 Simple Raytracer for students new to Rendering Ravi Ramamoorthi This assignment should be done only by those small number of students who have not yet written a raytracer. For those students
More informationOutline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process
Outline 433-380 Graphics and Computation Introduction to OpenGL OpenGL Background and History Other Graphics Technology Drawing Viewing and Transformation Lighting GLUT Resources Some images in these slides
More informationGraphics and Computation Introduction to OpenGL
433-380 Graphics and Computation Introduction to OpenGL Some images in these slides are taken from The OpenGL Programming Manual, which is copyright Addison Wesley and the OpenGL Architecture Review Board.
More informationComputer Graphics Lighting
Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?
More informationComputer Graphics Lighting. Why Do We Care About Lighting?
Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?
More informationCOMP3421. Introduction to 3D Graphics
COMP3421 Introduction to 3D Graphics 3D coodinates Moving to 3D is simply a matter of adding an extra dimension to our points and vectors: 3D coordinates 3D coordinate systems can be left or right handed.
More informationViewing Transformation
CS38: Computer Graphics Viewing Transformation Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg/ Class Objectives Know camera setup parameters Understand viewing and projection processes
More informationIntMu.Lab5. Download all the files available from
IntMu.Lab5 0. Download all the files available from http://www.dee.isep.ipp.pt/~jml/intmu/lab5: wget http://www.dee.isep.ipp.pt/~jml/intmu/lab5/makefile make getall Analyze the program windmill.c. Compile
More informationINSTANCE VARIABLES (1/2) P. 1
SHADOWS: THE CODE 1 OUTLINE 2 INSTANCE VARIABLES (1/2) P. 1 private GLCanvas mycanvas; private Material thismaterial; private String[] vblinn1shadersource, vblinn2shadersource, fblinn2shadersource; private
More informationIntroduction to OpenGL
Introduction to OpenGL Banafsheh Azari http://www.uni-weimar.de/cms/medien/cg.html What You ll See Today What is OpenGL? Related Libraries OpenGL Command Syntax B. Azari http://www.uni-weimar.de/cms/medien/cg.html
More informationUsing GLU/GLUT Objects
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutwirecone glutwirecube glucylinder glutwireteapot GLU/GLUT Objects Each glu/glut object has its default size, position, and orientation
More informationSHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming
SHADER PROGRAMMING Based on Jian Huang s lecture on Shader Programming What OpenGL 15 years ago could do http://www.neilturner.me.uk/shots/opengl-big.jpg What OpenGL can do now What s Changed? 15 years
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 informationAndroid and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg
Android and OpenGL Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 1. Februar 2016 Outline 1 OpenGL Introduction 2 Displaying Graphics 3 Interaction 4
More informationOpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University
OpenGL Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University Background Software interface to graphics hardware 250+ commands Objects (models) are built from geometric primitives
More informationGATAV 9. Goodby flatland Welcome to 3D!
GATAV 9. Goodby flatland Welcome to 3D! TOC 1. OpenGL ES the 3D-API 2. The buffer concept - a technical necessity 3. Introducing GLSurfaceView the 3D-View 4. GLSurfaceView.Renderer the interface to 3D-content
More informationCMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Readings Computer Graphics Programming in OpenGL with Java
CMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Show how to program full OpenGL in JOGL Start on shader programing Readings Computer Graphics Programming in OpenGL with
More informationComputer Graphics. Chapter 10 Three-Dimensional Viewing
Computer Graphics Chapter 10 Three-Dimensional Viewing Chapter 10 Three-Dimensional Viewing Part I. Overview of 3D Viewing Concept 3D Viewing Pipeline vs. OpenGL Pipeline 3D Viewing-Coordinate Parameters
More informationCSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science
CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming OpenGL 3D Drawing 2 3D Graphics Projections Getting 3D to 2D 3D scene 2D image 3 Projections Orthographic
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 informationVisualizing Molecular Dynamics
Visualizing Molecular Dynamics Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Department of Computer Science Department of Physics & Astronomy Department of Chemical Engineering & Materials
More informationCOMP3421. Hidden surface removal Illumination
COMP3421 Hidden surface removal Illumination Revision Write a snippet of jogl code to draw a triangle with vertices: (2,1,-4) (0,-1,-3) (-2,1,-4) Assume back face culling is on. Make sure you specify normals
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 informationGL_MODELVIEW transformation
lecture 3 view transformations model transformations GL_MODELVIEW transformation view transformations: How do we map from world coordinates to camera/view/eye coordinates? model transformations: How do
More informationCS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:
CS38: Computer Graphics Viewing Transformation Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg/ Class Objectives Know camera setup parameters Understand viewing and projection processes
More informationComputer Graphics. Chapter 7 2D Geometric Transformations
Computer Graphics Chapter 7 2D Geometric Transformations Chapter 7 Two-Dimensional Geometric Transformations Part III. OpenGL Functions for Two-Dimensional Geometric Transformations OpenGL Geometric Transformation
More information1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1
Transformations 1-1 Transformations are used within the entire viewing pipeline: Projection from world to view coordinate system View modifications: Panning Zooming Rotation 1-2 Transformations can also
More informationThe Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes
The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes What is it? The viewing pipeline is the procession of operations that are applied to the OpenGL matrices, in order to create a 2D representation
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 informationCS 184: Assignment 2 Scene Viewer
CS 184: Assignment 2 Scene Viewer Ravi Ramamoorthi 1 Goals and Motivation This is a more substantial assignment than homework 1, including more transformations, shading, and a viewer for a scene specified
More informationOUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system
GRAPHICS PIPELINE 1 OUTLINE Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system 2 IMAGE FORMATION REVISITED Can we mimic the synthetic
More informationCS 184: Assignment 4 Simple Raytracer
CS 184: Assignment 4 Simple Raytracer Ravi Ramamoorthi 1 Introduction This assignment asks you to write a first simple raytracer. Raytracers can produce some of the most impressive renderings, with high
More informationOpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL
OpenGL: Open Graphics Library Introduction to OpenGL Part II CS 351-50 Graphics API ( Application Programming Interface) Software library Layer between programmer and graphics hardware (and other software
More information7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky
7. 3D Viewing Projection: why is projection necessary? 1 7. 3D Viewing Projection: why is projection necessary? Because the display surface is 2D 2 7.1 Projections Perspective projection 3 7.1 Projections
More informationGetting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.
Overview (1): Getting Started Setting up OpenGL/GLUT on Windows/Visual Studio COSC 4431/5331 Computer Graphics Thursday January 22, 2004 Overview Introduction Camera analogy Matrix operations and OpenGL
More informationLighting. Chapter 5. Chapter Objectives. After reading this chapter, you'll be able to do the following:
Chapter 5 Lighting Chapter Objectives After reading this chapter, you'll be able to do the following: Understand how real-world lighting conditions are approximated by OpenGL Render illuminated objects
More informationUnderstand how real-world lighting conditions are approximated by OpenGL
OpenGL Programming Guide (Addison-Wesley Publishing Company) Chapter 5 Lighting Chapter Objectives After reading this chapter, you ll be able to do the following: Understand how real-world lighting conditions
More informationCS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer
CS 48: Interactive Computer Graphics Basic Shading in WebGL Eric Shaffer Some slides adapted from Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 205 Phong Reflectance Model Blinn-Phong
More informationcs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands
cs123 Lab 3 OpenGL Part One Introduction to Computer Graphics 1 Introduction From now on, our weekly labs will focus on the use of OpenGL. While the lectures and projects will let you get a deeper understanding
More informationComputer Viewing Computer Graphics I, Fall 2008
Computer Viewing 1 Objectives Introduce mathematics of projection Introduce OpenGL viewing functions Look at alternate viewing APIs 2 Computer Viewing Three aspects of viewing process All implemented in
More information3D computer graphics: geometric modeling of objects in the computer and rendering them
SE313: Computer Graphics and Visual Programming Computer Graphics Notes Gazihan Alankus, Spring 2012 Computer Graphics 3D computer graphics: geometric modeling of objects in the computer and rendering
More informationOpenGL. Toolkits.
http://www.opengl.org OpenGL Open Graphics Library Graphics API Delivered with UNIX, Win9x/2000/Me/Nt/Xp, Mac OS Direct3D (DirectX) is only Windows Utilizes the window system and event handling of the
More informationScientific Visualization Basics
Scientific Visualization Basics Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Dept. of Computer Science, Dept. of Physics & Astronomy, Dept. of Chemical Engineering & Materials Science,
More informationOpenGL Transformations
OpenGL Transformations R. J. Renka Department of Computer Science & Engineering University of North Texas 02/18/2014 Introduction The most essential aspect of OpenGL is the vertex pipeline described in
More informationComputer graphics MN1
Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? HowdoI useit? Rendering pipeline Points, vertices, lines, polygons Matrices and transformations Lighting and shading Code examples
More informationScene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed
CS4620/5620: Lecture 7 Scene Graphs 1 Announcements HW 1 out PA 1 will be out on Wed Next week practicum will have an office hour type session on Open GL 2 Example Can represent drawing with flat list
More informationSE313: Computer Graphics and Visual Programming. Computer Graphics Notes Gazihan Alankus, Fall 2011
SE313: Computer Graphics and Visual Programming Computer Graphics Notes Gazihan Alankus, Fall 2011 Computer Graphics Geometrical model on the computer -> Image on the screen How it works in your computer
More informationLecture 2 2D transformations Introduction to OpenGL
Lecture 2 2D transformations Introduction to OpenGL OpenGL where it fits what it contains how you work with it OpenGL parts: GL = Graphics Library (core lib) GLU = GL Utilities (always present) GLX, AGL,
More informationINTRODUCTION. Computer Graphics
INTRODUCTION Computer Graphics 1 INTRODUCTION: THE OUTLINE I. Image Processing / Computer Graphics II. Advantages III. Representative Uses IV. Classification of Applications V. History VI. Conceptual Framework
More informationAdvanced Computer Graphics (CS & SE )
Advanced Computer Graphics (CS & SE 233.420) Topics Covered Picking Pipeline Viewing and Transformations Rendering Modes OpenGL can render in one of three modes selected by glrendermode(mode) GL_RENDER
More informationCSE Intro to Computer Graphics. ANSWER KEY: Midterm Examination. November 18, Instructor: Sam Buss, UC San Diego
CSE 167 - Intro to Computer Graphics ANSWER KEY: Midterm Examination November 18, 2003 Instructor: Sam Buss, UC San Diego Write your name or initials on every page before beginning the exam. You have 75
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 informationModeling with Transformations
Modeling with Transformations Prerequisites This module requires some understanding of 3D geometry, particularly a sense of how objects can be moved around in 3-space. The student should also have some
More informationJOGL-ES 1. Rotating Boxes
JOGL-ES 1. Rotating Boxes With the release of the Java Wireless Toolkit (WTK) 2.5, developers now have two 3D APIs to play with in their MIDlets the familiar M3G (also known as Mobile 3D, and JSR-184),
More information3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy
3D Graphics Pipeline II Clipping Instructor Stephen J. Guy 3D Rendering Pipeline (for direct illumination) 3D Geometric Primitives 3D Model Primitives Modeling Transformation 3D World Coordinates Lighting
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 informationOpenGL Tutorial. Ceng 477 Introduction to Computer Graphics
OpenGL Tutorial Ceng 477 Introduction to Computer Graphics Adapted from: http://www.cs.princeton.edu/courses/archive/spr06/cos426/assn3/opengl_tutorial.ppt OpenGL IS an API OpenGL IS nothing more than
More informationTwo possible ways to specify transformations. Each part of the object is transformed independently relative to the origin
Transformations Two possible ways to specify transformations Each part of the object is transformed independently relative to the origin - Not convenient! z y Translate the base by (5,0,0); Translate the
More informationCOMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision
COMP3421 Week 2 - Transformations in 2D and Vector Geometry Revision Exercise 1. Write code to draw (an approximation) of the surface of a circle at centre 0,0 with radius 1 using triangle fans. 2. At
More informationExtreme Swing. Romain Guy Sun Microsystems.
Extreme Swing Romain Guy Sun Microsystems Overall Presentation Goal Learn how to create modern user interfaces with Swing Agenda About user interfaces Add a new dimension Swing and Java2D Going further
More informationIntroduction to OpenGL
OpenGL is an alternative to Direct3D for 3D graphics rendering Originally developed by Silicon Graphics Inc (SGI), turned over to multi-vendor group (OpenGL Architecture Review Board) in 1992 Unlike DirectX,
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 informationOverview of Projections: From a 3D world to a 2D screen.
Overview of Projections: From a 3D world to a 2D screen. Lecturer: Dr Dan Cornford d.cornford@aston.ac.uk http://wiki.aston.ac.uk/dancornford CS2150, Computer Graphics, Aston University, Birmingham, UK
More informationTransformation Pipeline
Transformation Pipeline Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space Coordinate
More informationCOMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision
COMP3421 Week 2 - Transformations in 2D and Vector Geometry Revision Exercise 1. Write code to draw (an approximation) of the surface of a circle at centre 0,0 with radius 1 using triangle fans. Transformation
More informationThe feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):
Ray Tracing exercise TAU, Computer Graphics, 0368.3014, semester B Go to the Updates and FAQ Page Overview The objective of this exercise is to implement a ray casting/tracing engine. Ray tracing is a
More informationCS 428: Fall Introduction to. OpenGL primer. Andrew Nealen, Rutgers, /13/2010 1
CS 428: Fall 2010 Introduction to Computer Graphics OpenGL primer Andrew Nealen, Rutgers, 2010 9/13/2010 1 Graphics hardware Programmable {vertex, geometry, pixel} shaders Powerful GeForce 285 GTX GeForce480
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 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 information