示例#1
0
void OpenGLFrameBuffer::Update()
{
	if (!CanUpdate()) 
	{
		GLRenderer->Flush();
		return;
	}

	Begin2D(false);

	DrawRateStuff();
	GLRenderer->Flush();

	if (GetTrueHeight() != GetHeight())
	{
		if (GLRenderer != NULL) 
			GLRenderer->ClearBorders();

		Begin2D(false);
	}
	if (gl_draw_sync || !swapped)
	{
		Swap();
	}
	swapped = false;
	Unlock();
	CheckBench();
}
示例#2
0
void OpenGLSWFrameBuffer::WipeEndScreen()
{
	if (!Accel2D)
	{
		Super::WipeEndScreen();
		return;
	}

	// Don't do anything if there is no starting point.
	if (InitialWipeScreen == NULL)
	{
		return;
	}

	// If the whole screen was drawn without 2D accel, get it in to
	// video memory now.
	if (!In2D)
	{
		Begin2D(true);
	}

	EndBatch();			// Make sure all batched primitives have been drawn.

	FinalWipeScreen = CopyCurrentScreen();

	// At this point, InitialWipeScreen holds the screen we are wiping from.
	// FinalWipeScreen holds the screen we are wiping to, which may be the
	// same texture as TempRenderTexture.
}
示例#3
0
void InitInterlace_()
{
	need_InitInterlace = 0;
	glDisable(GL_LINE_SMOOTH);
	glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
	Begin2D(width,height);
	glEnable(GL_STENCIL_TEST);
	glClearStencil(0);
	//glStencilMask(1);
	glClear (GL_STENCIL_BUFFER_BIT);
	

	glStencilFunc(GL_ALWAYS, 1, 1);
	glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
	
	glBegin(GL_LINES);
	for(int i=0;i<height;i+=2)
	{
		glVertex2f(0,i);
		glVertex2f(width,i);
	}
	glEnd();

	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
	glDisable(GL_STENCIL_TEST);
	End2D();
	glEnable(GL_LINE_SMOOTH);
	glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

}
示例#4
0
void OpenGLFrameBuffer::InitializeState()
{
	static bool first=true;

	if (first)
	{
		glewInit();
	}

	gl_LoadExtensions();
	Super::InitializeState();
	if (first)
	{
		first=false;
		// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
#ifdef _MSC_VER
		gl_PrintStartupLog();
#endif

	}
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glDepthFunc(GL_LESS);
	glShadeModel(GL_SMOOTH);

	glEnable(GL_DITHER);
	glEnable(GL_ALPHA_TEST);
	glDisable(GL_CULL_FACE);
	glDisable(GL_POLYGON_OFFSET_FILL);
	glEnable(GL_POLYGON_OFFSET_LINE);
	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_CLAMP_NV);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_LINE_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glAlphaFunc(GL_GEQUAL,0.5f);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	// This was to work around a bug in some older driver. Probably doesn't make sense anymore.
	glEnable(GL_FOG);
	glDisable(GL_FOG);

	glHint(GL_FOG_HINT, GL_FASTEST);
	glFogi(GL_FOG_MODE, GL_EXP);


	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int trueH = GetTrueHeight();
	int h = GetHeight();
	glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); 

	Begin2D(false);
	GLRenderer->Initialize();
}
示例#5
0
void OpenGLFrameBuffer::InitializeState()
{
	static bool first=true;

	if (first)
	{
		ogl_LoadFunctions();
	}

	gl_LoadExtensions();
	Super::InitializeState();

	if (first)
	{
		first=false;
		gl_PrintStartupLog();
	}

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glDepthFunc(GL_LESS);

	glEnable(GL_DITHER);
	glDisable(GL_CULL_FACE);
	glDisable(GL_POLYGON_OFFSET_FILL);
	glEnable(GL_POLYGON_OFFSET_LINE);
	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_CLAMP);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_LINE_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int trueH = GetTrueHeight();
	int h = GetHeight();
	glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); 

	Begin2D(false);
	GLRenderer->Initialize();
}
示例#6
0
void D3DFB::WipeEndScreen()
{
	if (!Accel2D)
	{
		Super::WipeEndScreen();
		return;
	}

	// Don't do anything if there is no starting point.
	if (InitialWipeScreen == NULL)
	{
		return;
	}

	// If the whole screen was drawn without 2D accel, get it in to
	// video memory now.
	if (!In2D)
	{
		Begin2D(true);
	}

	EndBatch();			// Make sure all batched primitives have been drawn.

	// Don't do anything if there is no ending point.
	if (OldRenderTarget == NULL)
	{
		return;
	}

	// If these are different, reverse their roles so we don't need to
	// waste time copying from TempRenderTexture to FinalWipeScreen.
	if (FinalWipeScreen != TempRenderTexture)
	{
		swapvalues(RenderTexture[CurrRenderTexture], FinalWipeScreen);
		TempRenderTexture = RenderTexture[CurrRenderTexture];
	}

	// At this point, InitialWipeScreen holds the screen we are wiping from.
	// FinalWipeScreen holds the screen we are wiping to, which may be the
	// same texture as TempRenderTexture.
}
示例#7
0
/*** Procesamiento de cada cuadro ***/
void Video( float elapsed )
{
    /* Limpio la pantalla */
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
    
    /* Perspectiva */
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective( 50.0f/zoom,                           // Ángulo de visión vertical
                   (GLfloat)WIDTH / (GLfloat)HEIGHT, // Aspecto
                   1.0f,                             // Plano cercano
                   2000.0f );                        // Plano lejano
    
    /* Cámara */
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    
    /* Espada */
    glPushMatrix();
    glMultTransposeMatrixf(volumesEspada.matrix);
    
  //  glTranslatef(cam.pos.x, cam.pos.y + 5, cam.pos.z + 10);
    glRotatef(angX, 1.0f, 0.0f, 0.0f);
    glRotatef(angY, 0.0f, 1.0f, 0.0f);
    glRotatef(angZ, 0.0f, 0.0f, 1.0f);
    
    glCallList(modeloEspada.modelList);
    glPopMatrix();
    /*________*/
    
    
    
   
    
        
    
    
       
    
    
	VECTOR dir = SumVector(cam.pos, cam.look);
    
    gluLookAt(  cam.pos.x, cam.pos.y,  cam.pos.z,       // Posición
                dir.x, dir.y, dir.z,                    // Dirección
                0.0f, 1.0f, 0.0f );                     // Arriba
    
    
    
    
    /*Luz*/
    glPushMatrix();
    SetDirLight(GL_LIGHT0, &dirLight);
    glEnable (GL_LIGHT0);
    glPopMatrix();
    
    
    /*Terreno*/
    glPushMatrix();
    SetMaterial( &terrain.material );
    glBindTexture(GL_TEXTURE_2D, terrain.textureID);
    glCallList( terrain.terrainList );
    glPopMatrix();
    
    
    

    /*agua*/
      /*
    glPushMatrix();
    glEnable(GL_BLEND);
    SetMaterial( &agua.material );
    glBindTexture(GL_TEXTURE_2D, agua.textureID);
    glCallList( agua.terrainList );
    glDisable(GL_BLEND);
    glPopMatrix();
    
    
*/
    
    
    
    
    
    /*texto fps*/
 //   RenderText(fpstex, arialfont, 0, 0, &fontColor, GL_FALSE);
    
    
    /*SkyBox*/
    glPushMatrix();
    RenderSkybox(&skybox, &skyboxBox, &skyboxColor);
    glPopMatrix();
    
    

    

    
  
  
    
    
    
    //**texturitas!!!**//
    
    
    /* subacuatica*/
    
    
    glPushMatrix();
    

    //glLoadIdentity();
    glEnable(GL_BLEND);
    SetMaterial(&aguaMtrl);
    
    glBindTexture(GL_TEXTURE_2D, UnderwaterTex);

    glTranslatef(cam.pos.x, vWater, cam.pos.z);
    glScalef(1000.0f, 1000.0f, 1000.0f);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
    //  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER    , );

    
    glBegin(GL_QUADS);
    //Cara posterior
    
    
    
    glNormal3f( 0.0f,  1.0f, 0.0f);

    
    glTexCoord2f    ( 0.0f,  1.0f + movWater);
    glVertex3f      (-1.0f,  0.0f, -1.0f);
    glTexCoord2f    ( 0.0f,  0.0f + movWater);
    glVertex3f      ( 1.0f,  0.0f, -1.0f);
    glTexCoord2f    ( 1.0f,  0.0f + movWater);
    glVertex3f      ( 1.0f,  0.0f,  1.0f);
    glTexCoord2f    ( 1.0f,  1.0f + movWater);
    glVertex3f      (-1.0f,  0.0f,  1.0f);

    glEnd();
 
    glDisable(GL_BLEND);

    
    glPopMatrix();
    
    //_______________//
    //Transparencia


    
    
    
    
    /*HUD*/
    Begin2D(WIDTH, HEIGHT);
    


    
    if ( !renderUnderwater){
            }
    
    if (under){
        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        Render2DTexture( UnderwaterTex, 0, 0, WIDTH, HEIGHT );
    }
    
    
    //RENDER DEL MAPA Y EL DOT
    glPushMatrix();
    glTranslatef(WIDTH*0.79 , HEIGHT * 0.79, 0);
    Render2DTexture( mapTex, 0, 0, mapWidth, mapHeight );
    Render2DTexture( dotTex, dotX, dotZ, dotX+10, dotZ+10  );

    glPopMatrix();
    Render2DTexture(hudNull, 0, 0, WIDTH, HEIGHT);
    Render2DTexture(oxBar, 0, 0, ox * 10.0f, 50.0f);
    End2D();


    
    
    
    
    
    
    
    /* Ejecutar comandos en cola */
    glFlush();
    
    /* BackBuffer=FrontBuffer(flip) */
    SDL_GL_SwapBuffers();
}