Пример #1
0
		private void PrepareStageTexturing(MaterialStage stage, DrawSurface surface, Vertex[] position)
		{
			// set privatePolygonOffset if necessary
			if(stage.PrivatePolygonOffset > 0)
			{
				// TODO: Gl.glEnable(Gl.GL_POLYGON_OFFSET_FILL);
				// TODO: Gl.glPolygonOffset(idE.CvarSystem.GetFloat("r_offsetFactor"), idE.CvarSystem.GetFloat("r_offsetUnits") * stage.PrivatePolygonOffset);
			}

			// set the texture matrix if needed
			if(stage.Texture.HasMatrix == true)
			{
				LoadMaterialTextureMatrix(surface.MaterialRegisters, stage.Texture);
			}

			// texgens
			if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.DiffuseCube)
			{
				idConsole.Warning("TODO: TexGen DiffuseCube");
				// TODO: Gl.glTexCoordPointer(3, Gl.GL_FLOAT, sizeof( idVertex ), new float[] { position.Normal.X, position.Normal.Y, position.Normal.Z });
			}
			else if((stage.Texture.TextureCoordinates == TextureCoordinateGeneration.SkyboxCube) || (stage.Texture.TextureCoordinates == TextureCoordinateGeneration.WobbleSkyCube))
			{
				idConsole.Warning("TODO: TexGen SkyboxCube | WobbleSky");
				// TODO: Gl.glTexCoordPointer(3, Gl.GL_FLOAT, 0, vertexCache.Position( surf->dynamicTexCoords));
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.Screen)
			{
				idConsole.Warning("TODO: TexGen Screen");

				/*qglEnable( GL_TEXTURE_GEN_S );
				qglEnable( GL_TEXTURE_GEN_T );
				qglEnable( GL_TEXTURE_GEN_Q );

				float	mat[16], plane[4];
				myGlMultMatrix( surf->space->modelViewMatrix, backEnd.viewDef->projectionMatrix, mat );

				plane[0] = mat[0];
				plane[1] = mat[4];
				plane[2] = mat[8];
				plane[3] = mat[12];
				qglTexGenfv( GL_S, GL_OBJECT_PLANE, plane );

				plane[0] = mat[1];
				plane[1] = mat[5];
				plane[2] = mat[9];
				plane[3] = mat[13];
				qglTexGenfv( GL_T, GL_OBJECT_PLANE, plane );

				plane[0] = mat[3];
				plane[1] = mat[7];
				plane[2] = mat[11];
				plane[3] = mat[15];
				qglTexGenfv( GL_Q, GL_OBJECT_PLANE, plane );*/
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.Screen2)
			{
				idConsole.Warning("TODO: TexGen Screen2");
				/*qglEnable( GL_TEXTURE_GEN_S );
				qglEnable( GL_TEXTURE_GEN_T );
				qglEnable( GL_TEXTURE_GEN_Q );

				float	mat[16], plane[4];
				myGlMultMatrix( surf->space->modelViewMatrix, backEnd.viewDef->projectionMatrix, mat );

				plane[0] = mat[0];
				plane[1] = mat[4];
				plane[2] = mat[8];
				plane[3] = mat[12];
				qglTexGenfv( GL_S, GL_OBJECT_PLANE, plane );

				plane[0] = mat[1];
				plane[1] = mat[5];
				plane[2] = mat[9];
				plane[3] = mat[13];
				qglTexGenfv( GL_T, GL_OBJECT_PLANE, plane );

				plane[0] = mat[3];
				plane[1] = mat[7];
				plane[2] = mat[11];
				plane[3] = mat[15];
				qglTexGenfv( GL_Q, GL_OBJECT_PLANE, plane );*/
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.GlassWarp)
			{
				idConsole.Warning("TODO: TexGen GlassWarp");

				/*if ( tr.backEndRenderer == BE_ARB2) {
					qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_GLASSWARP );
					qglEnable( GL_FRAGMENT_PROGRAM_ARB );

					GL_SelectTexture( 2 );
					globalImages->scratchImage->Bind();

					GL_SelectTexture( 1 );
					globalImages->scratchImage2->Bind();

					qglEnable( GL_TEXTURE_GEN_S );
					qglEnable( GL_TEXTURE_GEN_T );
					qglEnable( GL_TEXTURE_GEN_Q );

					float	mat[16], plane[4];
					myGlMultMatrix( surf->space->modelViewMatrix, backEnd.viewDef->projectionMatrix, mat );

					plane[0] = mat[0];
					plane[1] = mat[4];
					plane[2] = mat[8];
					plane[3] = mat[12];
					qglTexGenfv( GL_S, GL_OBJECT_PLANE, plane );

					plane[0] = mat[1];
					plane[1] = mat[5];
					plane[2] = mat[9];
					plane[3] = mat[13];
					qglTexGenfv( GL_T, GL_OBJECT_PLANE, plane );

					plane[0] = mat[3];
					plane[1] = mat[7];
					plane[2] = mat[11];
					plane[3] = mat[15];
					qglTexGenfv( GL_Q, GL_OBJECT_PLANE, plane );

					GL_SelectTexture( 0 );
				}*/
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.ReflectCube)
			{
				idConsole.Warning("TODO: TexGen ReflectCube");

				/*if ( tr.backEndRenderer == BE_ARB2 ) {
					// see if there is also a bump map specified
					const shaderStage_t *bumpStage = surf->material->GetBumpStage();
					if ( bumpStage ) {
						// per-pixel reflection mapping with bump mapping
						GL_SelectTexture( 1 );
						bumpStage->texture.image->Bind();
						GL_SelectTexture( 0 );

						qglNormalPointer( GL_FLOAT, sizeof( idDrawVert ), ac->normal.ToFloatPtr() );
						qglVertexAttribPointerARB( 10, 3, GL_FLOAT, false, sizeof( idDrawVert ), ac->tangents[1].ToFloatPtr() );
						qglVertexAttribPointerARB( 9, 3, GL_FLOAT, false, sizeof( idDrawVert ), ac->tangents[0].ToFloatPtr() );

						qglEnableVertexAttribArrayARB( 9 );
						qglEnableVertexAttribArrayARB( 10 );
						qglEnableClientState( GL_NORMAL_ARRAY );

						// Program env 5, 6, 7, 8 have been set in RB_SetProgramEnvironmentSpace

						qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_BUMPY_ENVIRONMENT );
						qglEnable( GL_FRAGMENT_PROGRAM_ARB );
						qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_BUMPY_ENVIRONMENT );
						qglEnable( GL_VERTEX_PROGRAM_ARB );
					} else {
						// per-pixel reflection mapping without a normal map
						qglNormalPointer( GL_FLOAT, sizeof( idDrawVert ), ac->normal.ToFloatPtr() );
						qglEnableClientState( GL_NORMAL_ARRAY );

						qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_ENVIRONMENT );
						qglEnable( GL_FRAGMENT_PROGRAM_ARB );
						qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_ENVIRONMENT );
						qglEnable( GL_VERTEX_PROGRAM_ARB );
					}
				} else {
					qglEnable( GL_TEXTURE_GEN_S );
					qglEnable( GL_TEXTURE_GEN_T );
					qglEnable( GL_TEXTURE_GEN_R );
					qglTexGenf( GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT );
					qglTexGenf( GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT );
					qglTexGenf( GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT );
					qglEnableClientState( GL_NORMAL_ARRAY );
					qglNormalPointer( GL_FLOAT, sizeof( idDrawVert ), ac->normal.ToFloatPtr() );

					qglMatrixMode( GL_TEXTURE );
					float	mat[16];

					R_TransposeGLMatrix( backEnd.viewDef->worldSpace.modelViewMatrix, mat );

					qglLoadMatrixf( mat );
					qglMatrixMode( GL_MODELVIEW );
				}*/
			}
		}
Пример #2
0
		private void FinishStageTexturing(MaterialStage stage, DrawSurface surface, Vertex[] position)
		{
			// unset privatePolygonOffset if necessary
			if((stage.PrivatePolygonOffset > 0) && (surface.Material.TestMaterialFlag(MaterialFlags.PolygonOffset) == false))
			{
				// TODO: Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL);
			}

			if((stage.Texture.TextureCoordinates == TextureCoordinateGeneration.DiffuseCube) || (stage.Texture.TextureCoordinates == TextureCoordinateGeneration.SkyboxCube) || (stage.Texture.TextureCoordinates == TextureCoordinateGeneration.WobbleSkyCube))
			{
				idConsole.Warning("TODO: FinishStageTexturing DiffuseCube");

				// TODO qglTexCoordPointer( 2, GL_FLOAT, sizeof( idDrawVert ), (void *)&ac->st );
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.Screen)
			{
				idConsole.Warning("TODO: TexCoord Screen");

				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_S);
				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_T);
				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_Q);
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.Screen2)
			{
				idConsole.Warning("TODO: TexCoord Screen2");

				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_S);
				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_T);
				// TODO: Gl.glDisable(Gl.GL_TEXTURE_GEN_Q);
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.GlassWarp)
			{
				idConsole.Warning("TODO: FinishStageTexturing GlassWarp");

				/*if ( tr.backEndRenderer == BE_ARB2) {
					GL_SelectTexture( 2 );
					globalImages->BindNull();

					GL_SelectTexture( 1 );
					if ( pStage->texture.hasMatrix ) {
						RB_LoadShaderTextureMatrix( surf->shaderRegisters, &pStage->texture );
					}
					qglDisable( GL_TEXTURE_GEN_S );
					qglDisable( GL_TEXTURE_GEN_T );
					qglDisable( GL_TEXTURE_GEN_Q );
					qglDisable( GL_FRAGMENT_PROGRAM_ARB );
					globalImages->BindNull();
					GL_SelectTexture( 0 );
				}*/
			}
			else if(stage.Texture.TextureCoordinates == TextureCoordinateGeneration.ReflectCube)
			{
				idConsole.Warning("TODO: FinishStageTexturing ReflectCube");
				/*if ( tr.backEndRenderer == BE_ARB2 ) {
					// see if there is also a bump map specified
					const shaderStage_t *bumpStage = surf->material->GetBumpStage();
					if ( bumpStage ) {
						// per-pixel reflection mapping with bump mapping
						GL_SelectTexture( 1 );
						globalImages->BindNull();
						GL_SelectTexture( 0 );

						qglDisableVertexAttribArrayARB( 9 );
						qglDisableVertexAttribArrayARB( 10 );
					} else {
						// per-pixel reflection mapping without bump mapping
					}

					qglDisableClientState( GL_NORMAL_ARRAY );
					qglDisable( GL_FRAGMENT_PROGRAM_ARB );
					qglDisable( GL_VERTEX_PROGRAM_ARB );
					// Fixme: Hack to get around an apparent bug in ATI drivers.  Should remove as soon as it gets fixed.
					qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, 0 );
				} else {
					qglDisable( GL_TEXTURE_GEN_S );
					qglDisable( GL_TEXTURE_GEN_T );
					qglDisable( GL_TEXTURE_GEN_R );
					qglTexGenf( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
					qglTexGenf( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
					qglTexGenf( GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
					qglDisableClientState( GL_NORMAL_ARRAY );

					qglMatrixMode( GL_TEXTURE );
					qglLoadIdentity();
					qglMatrixMode( GL_MODELVIEW );
				}*/
			}

			if(stage.Texture.HasMatrix == true)
			{
				//Gl.glMatrixMode(Gl.GL_TEXTURE);
				//Gl.glLoadIdentity();
				//Gl.glMatrixMode(Gl.GL_MODELVIEW);
			}
		}