void Draw (void)												// Draw The Scene
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.5);						// Set The Clear Color To Black
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	glLoadIdentity();											// Reset The View	
	RenderToTexture();											// Render To A Texture
	ProcessHelix();												// Draw Our Helix
	DrawBlur(25,0.02f);											// Draw The Blur Effect
	glFlush ();													// Flush The GL Rendering Pipeline
}
Exemple #2
0
void drawGLScene(void)											/* Draw The Scene */
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.5);						/* Set The Clear Color To Black */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			/* Clear Screen And Depth Buffer */
	glLoadIdentity();											/* Reset The View */
	RenderToTexture();											/* Render To A Texture */
	ProcessHelix();												/* Draw Our Helix */
	DrawBlur(25,0.02f);											/* Draw The Blur Effect */
	glFlush();													/* Flush The GL Rendering Pipeline */
}
void NEHE36::RenderToTexture(){
    glViewport(0,0,128,128);
	
    ProcessHelix();
	
    glBindTexture(GL_TEXTURE_2D,BlurTexture);
	
    // Copy Our ViewPort To The Blur Texture (From 0,0 To 128,128... No Border)
    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);
	
    glClearColor(0.0f, 0.0f, 0.5f, 0.5);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
    glViewport(0 , 0,640 ,480);
}
Exemple #4
0
void RenderToTexture()											// Renders To A Texture
{
  glViewport(0,0,128,128);									// Set Our Viewport (Match Texture Size)

  ProcessHelix();												// Render The Helix

  glBindTexture(GL_TEXTURE_2D,BlurTexture);					// Bind To The Blur Texture

  // Copy Our ViewPort To The Blur Texture (From 0,0 To 128,128... No Border)
  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);

  glClearColor(0.0f, 0.0f, 0.5f, 0.5);						// Set The Clear Color To Medium Blue
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			// Clear The Screen And Depth Buffer

  glViewport(0 , 0,wwidth ,wheight);									// Set Viewport (0,0 to 640x480)
}
Exemple #5
0
void RenderToTexture()											/* Renders To A Texture */
{
	unsigned int width,height;
	glViewport(0,0,128,128);									/* Set Our Viewport (Match Texture Size) */

	ProcessHelix();												/* Render The Helix */

	glBindTexture(GL_TEXTURE_2D,BlurTexture);					/* Bind To The Blur Texture */

	/* Copy Our ViewPort To The Blur Texture (From 0,0 To 128,128... No Border) */
	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);

	glClearColor(0.0f, 0.0f, 0.5f, 0.5);						/* Set The Clear Color To Medium Blue */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			/* Clear The Screen And Depth Buffer */
	getScreenSize(&width,&height);								/* Get actual window size */
	glViewport(0 , 0,width,height);								/* Set Viewport (0,0 to widthxheight) */
}
GLvoid NEHE36::DrawGLScene(){
	
    glClearColor(0.0f, 0.0f, 0.0f, 0.5);
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	RenderToTexture();
	ProcessHelix();
	DrawBlur(25,0.02f);
	
	
	//draw FPS text
	GLint matrixMode;
	GLboolean lightingOn;
	lightingOn= glIsEnabled(GL_LIGHTING);
	if (lightingOn) glDisable(GL_LIGHTING);
	glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glPushAttrib(GL_COLOR_BUFFER_BIT);
	
	glTranslatef(0.0f,0.0f,-1.0f);
	glColor3f(0.8f,0.8f,0.8f);
	computeFPS();
	Utils::drawText(-0.98f,-0.98f, GLUT_BITMAP_HELVETICA_12, FPSstr);
	
	glPopAttrib();
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(matrixMode);
	if (lightingOn) glEnable(GL_LIGHTING);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	
	glutSwapBuffers();
	
	angle += 0.5f;
	
}
Exemple #7
0
extern "C" void Draw (void)												// Draw The Scene
{
  static double ticks;
  static double lastticks;

  glEnable(GL_DEPTH_TEST);									// Enable Depth Testing

  GLfloat global_ambient[4]={0.2f, 0.2f,  0.2f, 1.0f};		// Set Ambient Lighting To Fairly Dark Light (No Color)
  GLfloat light0pos[4]=     {0.0f, 5.0f, 10.0f, 1.0f};		// Set The Light Position
  GLfloat light0ambient[4]= {0.2f, 0.2f,  0.2f, 1.0f};		// More Ambient Light
  GLfloat light0diffuse[4]= {0.3f, 0.3f,  0.3f, 1.0f};		// Set The Diffuse Light A Bit Brighter
  GLfloat light0specular[4]={0.8f, 0.8f,  0.8f, 1.0f};		// Fairly Bright Specular Lighting

  GLfloat lmodel_ambient[]= {0.2f,0.2f,0.2f,1.0f};			// And More Ambient Light
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);		// Set The Ambient Light Model

  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);		// Set The Global Ambient Light Model
  glLightfv(GL_LIGHT0, GL_POSITION, light0pos);				// Set The Lights Position
  glLightfv(GL_LIGHT0, GL_AMBIENT, light0ambient);			// Set The Ambient Light
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light0diffuse);			// Set The Diffuse Light
  glLightfv(GL_LIGHT0, GL_SPECULAR, light0specular);			// Set Up Specular Lighting
  glEnable(GL_LIGHTING);										// Enable Lighting
  glEnable(GL_LIGHT0);										// Enable Light0

  glShadeModel(GL_SMOOTH);									// Select Smooth Shading

  glMateriali(GL_FRONT, GL_SHININESS, 128);
  glClearColor(0.0f, 0.0f, 0.0f, 0.5);						// Set The Clear Color To Black


  ticks=SDL_GetTicks();
  if(Update (ticks - lastticks)) 
    return;
  lastticks = ticks;

  glClearColor(0.0f, 0.0f, 0.0f, 0.5);						// Set The Clear Color To Black
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
  glLoadIdentity();											// Reset The View
  RenderToTexture();											// Render To A Texture
  ProcessHelix();												// Draw Our Helix
  DrawBlur(25,0.02f);											// Draw The Blur Effect
}