Question 1: Texturing
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
float flargest[] = new float[]; gl.glGetFloatv(GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, fLargest[0]); gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT,fLargest[0]);
Question 2: Texture Co-ordinates
Assuming texture co-ordinates start at 0,0 in the bottom left of the image, define texture co-ordinates for the following situations.gl.glVertex3d(-1, -1, -1.0); gl.glVertex3d(1, -1, -1.0); gl.glVertex3d(1, 1, -1.0); gl.glVertex3d(-1, 1, -1.0);
gl.glVertex3d(-10.0, -10.0, 0.0); gl.glVertex3d(10.0, -10.0, 0.0); gl.glVertex3d(0.0, -5.0, 0.0);
gl.glBegin(GL2.GL_QUAD_STRIP);{ for(int i=0; i<= NUM_SLICES; i++){ double angle = i*angleIncrement; double xPos = Math.cos(angle); double yPos = Math.sin(angle); gl.glNormal3d(xPos, yPos, 0); gl.glVertex3d(xPos,yPos,zFront); gl.glVertex3d(xPos,yPos,zBack); } }gl.glEnd();
Question 3: Vertex Buffer Objects and Texture Co-ordinates
Suppose you have the following code setting up a VBO for a quad.private float vertices[] = { -10,0,0, 10,0,0, 10,10,0, -10,10,0 }; private FloatBuffer vertexBuffer = Buffers.newDirectFloatBuffer(vertices); public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); //do init stuff //etc bufferIds = new int[1]; gl.glGenBuffers(1,bufferIds,0); gl.glBufferData(GL.GL_ARRAY_BUFFER,vertices.length*4,vertexBuffer,GL2.GL_STATIC_DRAW); } public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); //do display stuff //etc //draw the quad }
Question 4: Assignment
If there is any time left, discuss the assignment. Please make sure you ask any questions about the format of the json file and in particular the representation of the terrain. That is the most important thing in the early stages of the assignment.