#5979: Cubemap support for opengl2.

This commit is contained in:
SmileTheory 2013-09-16 00:54:26 -07:00
parent 68a616c7f1
commit 7e875c6941
23 changed files with 1268 additions and 516 deletions

View file

@ -99,7 +99,7 @@ void R_AddPolygonSurfaces( void ) {
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse );
R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse, 0 /*cubeMap*/ );
}
}
@ -283,36 +283,9 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, flo
RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue );
}
/*
@@@@@@@@@@@@@@@@@@@@@
RE_RenderScene
Draw a 3D view into a part of the window, then return
to 2D drawing.
Rendering a scene may require multiple views to be rendered
to handle mirrors,
@@@@@@@@@@@@@@@@@@@@@
*/
void RE_RenderScene( const refdef_t *fd ) {
viewParms_t parms;
int startTime;
if ( !tr.registered ) {
return;
}
GLimp_LogComment( "====== RE_RenderScene =====\n" );
if ( r_norefresh->integer ) {
return;
}
startTime = ri.Milliseconds();
if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) {
ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel");
}
void RE_BeginScene(const refdef_t *fd)
{
Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) );
tr.refdef.x = fd->x;
@ -466,6 +439,49 @@ void RE_RenderScene( const refdef_t *fd ) {
// each scene / view.
tr.frameSceneNum++;
tr.sceneCount++;
}
void RE_EndScene()
{
// the next scene rendered in this frame will tack on after this one
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
r_firstSceneEntity = r_numentities;
r_firstSceneDlight = r_numdlights;
r_firstScenePoly = r_numpolys;
}
/*
@@@@@@@@@@@@@@@@@@@@@
RE_RenderScene
Draw a 3D view into a part of the window, then return
to 2D drawing.
Rendering a scene may require multiple views to be rendered
to handle mirrors,
@@@@@@@@@@@@@@@@@@@@@
*/
void RE_RenderScene( const refdef_t *fd ) {
viewParms_t parms;
int startTime;
if ( !tr.registered ) {
return;
}
GLimp_LogComment( "====== RE_RenderScene =====\n" );
if ( r_norefresh->integer ) {
return;
}
startTime = ri.Milliseconds();
if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) {
ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel");
}
RE_BeginScene(fd);
// SmileTheory: playing with shadow mapping
if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2)
@ -487,6 +503,21 @@ void RE_RenderScene( const refdef_t *fd ) {
R_RenderSunShadowMaps(fd, 2);
}
// playing with cube maps
// this is where dynamic cubemaps would be rendered
if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ))
{
int i, j;
for (i = 0; i < tr.numCubemaps; i++)
{
for (j = 0; j < 6; j++)
{
R_RenderCubemapSide(i, j, qtrue);
}
}
}
// setup view parms for the initial view
//
// set up viewport
@ -522,11 +553,7 @@ void RE_RenderScene( const refdef_t *fd ) {
if(!( fd->rdflags & RDF_NOWORLDMODEL ))
R_AddPostProcessCmd();
// the next scene rendered in this frame will tack on after this one
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
r_firstSceneEntity = r_numentities;
r_firstSceneDlight = r_numdlights;
r_firstScenePoly = r_numpolys;
RE_EndScene();
tr.frontEndMsec += ri.Milliseconds() - startTime;
}