Ejemplo n.º 1
0
  void ChangeSize(int w, int h){
    if(h == 0)  { h = 1; }
    glViewport(0, 0, w, h);      
    viewFrustum.SetPerspective(35.0f, float(w)/float(h), 1.0f, 1000.0f);
    projection.LoadMatrix(viewFrustum.GetProjectionMatrix());
	geometryPipeline.SetMatrixStacks(modelView, projection);
   }
///////////////////////////////////////////////////////////////////////////////
// This is called at least once and before any rendering occurs. If the screen
// is a resizeable window, then this will also get called whenever the window
// is resized.
void ChangeSize(int nWidth, int nHeight)
{
	glViewport(0, 0, nWidth, nHeight);
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
 
	viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	modelViewMatrix.LoadIdentity();

	// update screen sizes
	screenWidth = nWidth;
	screenHeight = nHeight;

	glBindRenderbuffer(GL_RENDERBUFFER, depthBufferName);
#ifndef ANGLE
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, screenWidth, screenHeight);
#else
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, screenWidth, screenHeight);
#endif
	glBindRenderbuffer(GL_RENDERBUFFER, renderBufferNames[0]);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, screenWidth, screenHeight);
	glBindRenderbuffer(GL_RENDERBUFFER, renderBufferNames[1]);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, screenWidth, screenHeight);
	glBindRenderbuffer(GL_RENDERBUFFER, renderBufferNames[2]);
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, screenWidth, screenHeight);
}
Ejemplo n.º 3
0
void changeSize(int w, int h)
{
    if (h == 0) h = 1;
    glViewport(0, 0, w, h);
    frustum.SetPerspective(35, (float)w/h, 1, 100);
    projectionM.LoadMatrix(frustum.GetProjectionMatrix());
}
Ejemplo n.º 4
0
///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
{
    glViewport(0, 0, w, h);
    viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f);
    projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    modelViewMatrix.LoadIdentity();
}
Ejemplo n.º 5
0
///////////////////////////////////////////////////////////////////////////////
// This is called at least once and before any rendering occurs. If the screen
// is a resizeable window, then this will also get called whenever the window
// is resized.
void ChangeSize(int nWidth, int nHeight)
{
	glViewport(0, 0, nWidth, nHeight);
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
 	viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	modelViewMatrix.LoadIdentity();

	// update screen sizes
	screenWidth = nWidth;
	screenHeight = nHeight;

	// reset screen aligned quad
	gltGenerateOrtho2DMat(screenWidth, screenHeight, orthoMatrix, screenQuad);

	free(pixelData);
	pixelDataSize = screenWidth*screenHeight*3*sizeof(unsigned int);
	pixelData = (void*)malloc(pixelDataSize);

	//  Resize PBOs
#ifndef OPENGL_ES
	glBindBuffer(GL_PIXEL_PACK_BUFFER, pixBuffObjs[0]);
	glBufferData(GL_PIXEL_PACK_BUFFER, pixelDataSize, pixelData, GL_DYNAMIC_COPY);
	glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
#endif

	gltCheckErrors();
}
Ejemplo n.º 6
0
///////////////////////////////////////////////////////////////////////////////
// Window has changed size, or has just been created. In either case, we need
// to use the window dimensions to set the viewport and the projection matrix.
void ChangeSize(int w, int h)
	{
	glViewport(0, 0, w, h);
	viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 500.0f);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
	}
Ejemplo n.º 7
0
void Reshape(int w,int h)
{
	if(h == 0) h = 1;
	glViewport(0,0,w,h);

	viewFrustum.SetPerspective(35.0,(float) w /(float) h,1.0,2000.0);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	transformPipeLine.SetMatrixStacks(modelViewMatrix,projectionMatrix);
}
Ejemplo n.º 8
0
void ChangeSize(int nWidth, int nHeight)
    {
	glViewport(0, 0, nWidth, nHeight);
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
	
	viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	modelViewMatrix.LoadIdentity();
	}
Ejemplo n.º 9
0
///////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {		        
    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         
    // Everything is white
    GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f };
#ifndef OPENGL_ES
    shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite);
    
    // Draw small stars
    glPointSize(1.0f);
#else
	glUseProgram(pointSizeShader);
	GLint iTransform, iColor, iPointSize;
	iTransform = glGetUniformLocation(pointSizeShader, "mvpMatrix");
	glUniformMatrix4fv(iTransform, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());

	iColor = glGetUniformLocation(pointSizeShader, "vColor");
	glUniform4fv(iColor, 1, vWhite);

	iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize");
	glUniform1f(iPointSize, 1.0f);
#endif
    smallStarBatch.Draw();
            
    // Draw medium sized stars
#ifdef OPENGL_ES
	iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize");
	glUniform1f(iPointSize, 4.0f);
#else
    glPointSize(4.0f);
#endif
	mediumStarBatch.Draw();
    
    // Draw largest stars
#ifdef OPENGL_ES
	iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize");
	glUniform1f(iPointSize, 8.0f);
#else
    glPointSize(8.0f);
#endif
    largeStarBatch.Draw();
        
    // Draw the "moon"
    moonBatch.Draw();

    // Draw distant horizon
    glLineWidth(3.5);
    mountainRangeBatch.Draw();
    
    moonBatch.Draw();

    // Swap buffers
    glutSwapBuffers();
    }
Ejemplo n.º 10
0
void changeSize(int w, int h)
{
	glViewport(0, 0, w, h);

	if(h <= 0) {h = 1;}

	viewFrustum.SetPerspective(35.0f, float(w)/float(h), 1.0f, 100.0f);
	projectionStack.LoadMatrix(viewFrustum.GetProjectionMatrix());
	tPipeline.SetMatrixStacks(modelViewStack, projectionStack);
}
///////////////////////////////////////////////////
// Screen changes size or is initialized
void ChangeSize(int nWidth, int nHeight)
    {
	glViewport(0, 0, nWidth, nHeight);
	
    // Create the projection matrix, and load it on the projection matrix stack
	viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    
    // Set the transformation pipeline to use the two matrix stacks 
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
    }
Ejemplo n.º 12
0
void ResizeWindow(int nWidth, int nHeight)
{
	glViewport(0, 0, nWidth, nHeight);

	// Create the projection matrix, and load it on the projection matrix stack
	viewFrustum.SetPerspective(FRUSTUM_FIELD_OF_VIEW, float(nWidth)/float(nHeight), FRUSTUM_NEAR_PLANE, FRUSTUM_FAR_PLANE);
	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());

	// Set the transformation pipeline to use the two matrix stacks 
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
}
Ejemplo n.º 13
0
void Reshape(int width,int height)
{
    glViewport(0,0,width,height);
    transformPipeline.SetMatrixStacks(modelViewMatrix,projectionMatrix);

    viewFrustum.SetPerspective(35.0f,float(width)/float(height),1.0f,100.0f);
    projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    modelViewMatrix.LoadIdentity();

    screenHeight = height;
    screenWidth = width;
}
Ejemplo n.º 14
0
void ChangeSize(int w, int h)
{
	if (h <= 0)
	{
		h = 1;
	}

	glViewport(0, 0, w, h);
	viewFrustum.SetPerspective(80.0f, float(w) / float(h), 1.0f, 120.0f);
	projctionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	transformPipeLine.SetMatrixStacks(modelViewMatrix, projctionMatrix);
}
Ejemplo n.º 15
0
///////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {		        
	static CStopWatch timer;

    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT);
         
    // Everything is white
    GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f };

	glBindTexture(GL_TEXTURE_2D, starTexture);
	glUseProgram(starFieldShader);
    glUniformMatrix4fv(locMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
    glUniform1i(locStarTexture, 0);
    
	// Draw small stars
    glPointSize(4.0f);
    smallStarBatch.Draw();
            
    // Draw medium sized stars
    glPointSize(8.0f);
    mediumStarBatch.Draw();
    
    // Draw largest stars
    glPointSize(12.0f);
    largeStarBatch.Draw();
        
    // Draw distant horizon
	shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite);
    glLineWidth(3.5);
    mountainRangeBatch.Draw();
    
	// Draw the "moon"
	glBindTexture(GL_TEXTURE_2D_ARRAY, moonTexture);
	glUseProgram(moonShader);
    glUniformMatrix4fv(locMoonMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
    glUniform1i(locMoonTexture, 0);

	// fTime goes from 0.0 to 28.0 and recycles
	float fTime = timer.GetElapsedSeconds();
	fTime = fmod(fTime, 28.0f);
    glUniform1f(locTimeStamp, fTime);

    moonBatch.Draw();


    // Swap buffers
    glutSwapBuffers();

	glutPostRedisplay();
    }
Ejemplo n.º 16
0
void ChangeSize(int w, int h)
{
    // Prevent a divide by zero
    if(h == 0)
        h = 1;

    // Set Viewport to window dimensions
    glViewport(0, 0, w, h);

    viewFrustum.SetPerspective(35.0f, float(w)/float(h), 1.0f, 100.0f);

    projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
}
Ejemplo n.º 17
0
void ChangeSize(int w, int h)
	{
	// Prevent a divide by zero
	if(h == 0)
		h = 1;

	// Set Viewport to window dimensions
    glViewport(0, 0, w, h);

    viewFrustum.SetOrthographic(-130.0f, 130.0f, -130.0f, 130.0f, -130.0f, 130.0f);
    
    projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    transformPipeline.SetMatrixStacks(modelViewMatix, projectionMatrix);
	}
Ejemplo n.º 18
0
/**
 * Window has changed size, or has just been created. In either case, we need to use the window 
 * dimensions to set the viewport and the projection matrix.
 */
void ChangeSize(int w, int h)
{
	// Prevent a divide by zero
	if ( h == 0 ) {
		h = 1;
	}

	// Set viewport to window dimensions
	glViewport(0, 0, w, h);

	GLfloat fAspect = (GLfloat)w/(GLfloat)h;
	// Produce the perspective projection
	viewFrustum.setPerspective(80.0f, fAspect, 1.0f, 120.0f);
	projectionMatrix.setMatrix(viewFrustum.GetProjectionMatrix());
	transformPipeline.setMatrixStacks(modelViewMatrix, projectionMatrix);
}
Ejemplo n.º 19
0
void RenderScene(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	glEnable( GL_DEPTH_TEST ) ;
	glUseProgram(shader);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	float angle = timer.GetElapsedSeconds();

	M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f}; 
	M3DVector3f at = {0,0,0}; 
	M3DVector3f up = {0.0f,0.0f,1.0f};

	GLFrame cameraFrame;
	LookAt(cameraFrame, eye, at, up);
	cameraFrame.GetCameraMatrix(cameraMatrix);
	
	m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix);

	M3DMatrix44f tMatrix;
	m3dTranslationMatrix44(tMatrix, 0, 0, 0);
	m3dMatrixMultiply44(matrix, tMatrix, matrix);

	if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) {
		debugMatrix44(matrix);
	}

	glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix);

//	drawGrid(0.1);
	drawPyramid();

	glutSwapBuffers();
	glutPostRedisplay();
}
Ejemplo n.º 20
0
// Called to draw scene
void RenderScene(void)
  {
  static CStopWatch timer;

  // Clear the window and the depth buffer
  glClear(GL_COLOR_BUFFER_BIT);

    // Turn on additive blending
  glEnable(GL_BLEND);
  glBlendFunc(GL_ONE, GL_ONE);

    // Let the vertex program determine the point size
  glEnable(GL_PROGRAM_POINT_SIZE);

    // Bind to our shader, set uniforms
    glUseProgram(starFieldShader);
    glUniformMatrix4fv(locMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix());
    glUniform1i(locTexture, 0);

  // fTime goes from 0.0 to 999.0 and recycles
  float fTime = timer.GetElapsedSeconds() * 10.0f;
  fTime = fmod(fTime, 999.0f);
    glUniform1f(locTimeStamp, fTime);

    // Draw the stars
    starsBatch.Draw();

    glutSwapBuffers();
  glutPostRedisplay();
  }
Ejemplo n.º 21
0
void render()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  
  glUseProgram(shader);
  
  updateCamera();
  
  GLGeometryTransform geometryPipeline;
  GLMatrixStack modelViewStack;
  GLMatrixStack projectionStack;
  geometryPipeline.SetMatrixStacks(modelViewStack, projectionStack);
  projectionStack.LoadMatrix(frustum.GetProjectionMatrix());
  M3DMatrix44f cameraMatrix;
  frame.GetCameraMatrix(cameraMatrix);
  modelViewStack.PushMatrix(cameraMatrix);
  
  glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, geometryPipeline.GetProjectionMatrix());
  glUniformMatrix4fv(modelViewMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix());
  glUniformMatrix4fv(normalMatrixLocation, 1, GL_FALSE, geometryPipeline.GetNormalMatrix());
  
  modelViewStack.PushMatrix();
  modelViewStack.Translate(0.0, 1.0, 0.0);
  glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, geometryPipeline.GetProjectionMatrix());
  glUniformMatrix4fv(modelViewMatrixLocation, 1, GL_FALSE, geometryPipeline.GetModelViewMatrix());
  glUniformMatrix4fv(normalMatrixLocation, 1, GL_FALSE, geometryPipeline.GetNormalMatrix());
  glDrawElements(GL_TRIANGLES, 3 * n_faces, GL_UNSIGNED_INT, 0);
  modelViewStack.PopMatrix();
  
  glutSwapBuffers();
  glutPostRedisplay();
}
Ejemplo n.º 22
0
///////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {		        
    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         
    // Everything is white
    GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f };
    shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite);
    
    // Draw small stars
    glPointSize(1.0f);
    smallStarBatch.Draw();
            
    // Draw medium sized stars
    glPointSize(4.0f);
    mediumStarBatch.Draw();
    
    // Draw largest stars
    glPointSize(8.0f);
    largeStarBatch.Draw();
        
    // Draw the "moon"
    moonBatch.Draw();

    // Draw distant horizon
    glLineWidth(3.5);
    mountainRangeBatch.Draw();
    
    moonBatch.Draw();

    // Swap buffers
    glutSwapBuffers();
    }
Ejemplo n.º 23
0
void GetViewProjectionMatrix(float *viewProjectionMatrix)
{	
	M3DMatrix44f viewMatrix;
	cameraFrame.GetCameraMatrix(viewMatrix);

	m3dMatrixMultiply44(viewProjectionMatrix, viewFrustum.GetProjectionMatrix(), viewMatrix);
}
Ejemplo n.º 24
0
void SetupRC() {
	glEnable(GL_DEPTH_TEST);
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

	shader = gltLoadShaderPairWithAttributes("pass_thru_shader.vp", "pass_thru_shader.fp", 
		2, GLT_ATTRIBUTE_VERTEX, "vVertex", GLT_ATTRIBUTE_NORMAL, "vNormal");
	fprintf(stdout, "GLT_ATTRIBUTE_VERTEX : %d\nGLT_ATTRIBUTE_NORMAL : %d \n",
            GLT_ATTRIBUTE_VERTEX, GLT_ATTRIBUTE_NORMAL);
	
	MVMatrixLocation = glGetUniformLocation(shader, "MVMatrix");
	if(MVMatrixLocation == -1) {
		fprintf(stdout, "Hej ho, hej ho, uniformy nie dzia³aj¹ MVMatrix\n");
	}

	PMatrixLocation = glGetUniformLocation(shader, "PMatrix");
	if(PMatrixLocation == -1) {
		fprintf(stdout, "Hej ho, hej ho, uniformy nie dzia³aj¹ PMatrix\n");
	}

	ambientLightLocation = glGetUniformLocation(shader, "ambientLight");

	light.positionLocation = glGetUniformLocation(shader, "light1.position");
	light.colorLocation = glGetUniformLocation(shader, "light1.color");
	light.angleLocation = glGetUniformLocation(shader, "light1.angle");
	light.attenuation0Location = glGetUniformLocation(shader, "light1.attenuation0");
	light.attenuation1Location = glGetUniformLocation(shader, "light1.attenuation1");
	light.attenuation2Location = glGetUniformLocation(shader, "light1.attenuation2");

	small_light.positionLocation = glGetUniformLocation(shader, "light2.position");
	small_light.colorLocation = glGetUniformLocation(shader, "light2.color");
	small_light.angleLocation = glGetUniformLocation(shader, "light2.angle");
	small_light.attenuation0Location = glGetUniformLocation(shader, "light2.attenuation0");
	small_light.attenuation1Location = glGetUniformLocation(shader, "light2.attenuation1");
	small_light.attenuation2Location = glGetUniformLocation(shader, "light2.attenuation2");

	material.ambientColorLocation = glGetUniformLocation(shader, "material.ambientColor");
	material.diffuseColorLocation = glGetUniformLocation(shader, "material.diffuseColor");
	material.specularColorLocation = glGetUniformLocation(shader, "material.specularColor");
	material.specularExponentLocation = glGetUniformLocation(shader, "material.specularExponent");

	viewFrustum.SetPerspective(15.0f,(float)800.0/(float)600.0,0,1000);

	glGenBuffers(1,&vertex_buffer);
	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);

	readVertices();
	glBufferData(GL_ARRAY_BUFFER,n_vertices*sizeof(float)*7,&ico_vertices[0],GL_STATIC_DRAW);
	glVertexAttribPointer(GLT_ATTRIBUTE_VERTEX,4,GL_FLOAT,GL_FALSE,sizeof(float)*7,(const GLvoid *)0);
	glVertexAttribPointer(GLT_ATTRIBUTE_NORMAL,3,GL_FLOAT,GL_FALSE,sizeof(float)*7,(const GLvoid *)(4*sizeof(float)) );

	glEnableVertexAttribArray(GLT_ATTRIBUTE_VERTEX);
	glEnableVertexAttribArray(GLT_ATTRIBUTE_NORMAL);

	glGenBuffers(1,&faces_buffer);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,faces_buffer);
	readFaces();
	glBufferData(GL_ELEMENT_ARRAY_BUFFER,n_faces*sizeof(GLuint)*3,&ico_faces[0],GL_STATIC_DRAW);
	
}
Ejemplo n.º 25
0
///////////////////////////////////////////////////////////////////////////////
// This is called at least once and before any rendering occurs. If the screen
// is a resizeable window, then this will also get called whenever the window
// is resized.
void ChangeSize(int nWidth, int nHeight)
{
    glViewport(0, 0, nWidth, nHeight);
    transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
 
    viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
    projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
    modelViewMatrix.LoadIdentity();

    // update screen sizes
    screenWidth = nWidth;
    screenHeight = nHeight;

    glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, hdrTextures[0]);
    glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGB16F, screenWidth, screenHeight, GL_FALSE);

    GenerateOrtho2DMat(nWidth, nHeight);
    glUseProgram(0);
}
Ejemplo n.º 26
0
void ChangeSize(int w, int h)
  {
  // Prevent a divide by zero
  if(h == 0)
    h = 1;

  // Set Viewport to window dimensions
    glViewport(0, 0, w, h);

    viewFrustum.SetPerspective(35.0f, float(w)/float(h), 1.0f, 1000.0f);
  }
Ejemplo n.º 27
0
void ChangeSize(int w, int h) {

	GLfloat nRange = 500.0f;
	windowWidth = w;
	windowHeight = h;

	// Verhindere eine Division durch Null
	if (h == 0) {
		h = 1;
	}
	// Setze den Viewport gemaess der Window-Groesse
	glViewport(0, 0, w, h);
	// Ruecksetzung des Projection matrix stack
	projectionMatrix.LoadIdentity();

	if (bPerspectiveProj) {
		// Definiere das viewing volume (left, right, bottom, top, near, far)
		if (w <= h) {
			viewFrustum.SetPerspective(30.0f, h/w, 1, 3000);
		}
		else {
			viewFrustum.SetPerspective(30.0f, w / h, 1, 3000);
		}
	}

	else {
		// Definiere das viewing volume (left, right, bottom, top, near, far)
		if (w <= h) {
			viewFrustum.SetOrthographic(-nRange, nRange, -nRange*h / w, nRange*h / w, -nRange, nRange);
		}
		else {
			viewFrustum.SetOrthographic(-nRange*w / h, nRange*w / h, -nRange, nRange, -nRange, nRange);
		}
	}

	projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
	// Ruecksetzung des Model view matrix stack
	modelViewMatrix.LoadIdentity();

	TwWindowSize(w, h);
}
Ejemplo n.º 28
0
/**
 * Window has changed size, or has just been created. In either case, we need to use the window 
 * dimensions to set the viewport and the projection matrix.
 */
void ChangeSize(int w, int h)
{
	glViewport(0, 0, w, h);
	transformPipeline.setMatrixStacks(modelViewMatrix, projectionMatrix);

	viewFrustum.setPerspective(35.0f, float(w) / float(h), 1.0f, 100.0f);
	projectionMatrix.setMatrix(viewFrustum.GetProjectionMatrix());
	modelViewMatrix.identity();

	GenerateOrtho2DMat(w, h);

	screenWidth = w;
	screenHeight = h;

	// resize texture
	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, depthTextureName);
	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_DEPTH_COMPONENT24, w, h, GL_FALSE);

	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msTexture[0]);
	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA8, w, h, GL_FALSE);
}
Ejemplo n.º 29
0
void ChangeSize(int w, int h)
    {
    // Prevent a divide by zero
    if(h == 0)
        h = 1;

    // Set Viewport to window dimensions
    glViewport(0, 0, w, h);

    // Establish clipping volume (left, right, bottom, top, near, far)
    viewFrustum.SetOrthographic(0.0f, SCREEN_X, 0.0f, SCREEN_Y, -1.0f, 1.0f);
    }
void ChangeSize(int w, int h)
{
	//prevent divide by 0
	if (h == 0)
	{
		h = 1;
	}

	//
	glViewport(0, 0, w, h);

	viewFrustum.SetPerspective(35.0f, float(w) / float(h), 1.0f, 1000.0f);

}