Exemplo n.º 1
0
void draw_temporary_translucent_polygons ( void )
{

	int
		vertex_index,
		count;

	//
	// No need to set the default blending mode, as each buffered polygon will set it itself
	//

	vertex_index = 0;

	set_d3d_int_state ( D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD );

	//
	// Flush any buffered vertex buffers
	//

	finalise_primitives ();

	for ( count = 0; count < number_of_temporary_polygons; count++ )
	{

		LPD3DTLVERTEX
			vertices;

		set_d3d_int_state ( D3DRENDERSTATE_SRCBLEND, temporary_polygons[count].source_alpha_blend );
		set_d3d_int_state ( D3DRENDERSTATE_DESTBLEND, temporary_polygons[count].destination_alpha_blend );

		if ( temporary_polygons[count].texture )
		{

			set_d3d_texture ( 0, load_hardware_texture_map ( temporary_polygons[count].texture ) );
			set_d3d_texture_stage_state ( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );

			set_d3d_texture_stage_state ( 0, D3DTSS_ADDRESSU, temporary_polygons[count].texture_u_address );
			set_d3d_texture_stage_state ( 0, D3DTSS_ADDRESSV, temporary_polygons[count].texture_v_address );
			set_d3d_texture_stage_state ( 0, D3DTSS_MAGFILTER, temporary_polygons[count].texture_mag );
			set_d3d_texture_stage_state ( 0, D3DTSS_MINFILTER, temporary_polygons[count].texture_mag );
			set_d3d_texture_stage_state ( 0, D3DTSS_MIPFILTER, temporary_polygons[count].texture_min );
		}
		else
		{

			set_d3d_texture_stage_state ( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
			set_d3d_texture ( 0, NULL );
		}


		if ( temporary_polygons[count].number_of_vertices > 2 )
		{

			vertices = get_d3d_vertices_points_address ( temporary_polygons[count].number_of_vertices );

			memcpy ( vertices, &temporary_vertices[vertex_index], sizeof ( D3DTLVERTEX ) * temporary_polygons[count].number_of_vertices );

			draw_fan_primitive ( temporary_polygons[count].number_of_vertices, vertices );
		}
		else
		{

			vertices = get_d3d_line_vertices_points_address ();

			memcpy ( vertices, &temporary_vertices[vertex_index], sizeof ( D3DTLVERTEX ) * 2 );

			draw_line_primitive ( vertices );
		}

		vertex_index += temporary_polygons[count].number_of_vertices;
	}
}
Exemplo n.º 2
0
void draw_terrain_3d_buffered_polygons ( void )
{


	if ( vertex_buffer != -1 )
	{

		//
		// Finalise the last vertex buffer used
		//

		unlock_d3d_alpha_vertex_buffer ( vertex_buffer );

		vertex_buffer_indices[vertex_buffer].number = base_index - vertex_buffer_indices[vertex_buffer].base_index;

		if ( base_index )
		{

			int
				count;

			//
			// Flush any buffered primitives
			//

			finalise_primitives ();

			//
			// Set the alpha blend modes
			//

			set_d3d_alpha_fog_zbuffer ( TRUE, FALSE, TRUE, FALSE );

			//
			// Set the texture handle
			//

			set_d3d_texture ( 0, load_hardware_texture_map ( terrain_buffered_polygons_texture ) );

			//
			// Draw all the buffered vertex buffers
			//


			for ( count = 0; count <= vertex_buffer; count++ )
			{
#ifdef _WIN32
				unsigned int
					d3drval;

				d3drval = IDirect3DDevice7_DrawIndexedPrimitiveVB ( d3d.device, D3DPT_TRIANGLELIST, d3d.alpha_vertex_buffer[count],
																						0,
																						vertex_buffer_indices[count].number_of_vertices_buffered,
																						&buffered_indices[ vertex_buffer_indices[count].base_index ],
																						vertex_buffer_indices[count].number,
																						( unsigned long ) ( 0 ) );

				if ( d3drval != DD_OK )
				{

					debug_log ( "Unable to draw buffered triangles: %s", get_ddraw_error_message ( d3drval ) );
				}
#endif

Transform();



glVertexPointer(3, GL_FLOAT, sizeof(D3DTLVERTEX), 0);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(D3DTLVERTEX), (GLvoid *) offsetof(D3DTLVERTEX, r));
glTexCoordPointer(2, GL_FLOAT, sizeof(D3DTLVERTEX), (GLvoid *) offsetof(D3DTLVERTEX, tu));

glDrawElements(GL_TRIANGLES,vertex_buffer_indices[count].number,GL_UNSIGNED_SHORT, (GLvoid *) buffered_indices[ vertex_buffer_indices[count].base_index]);
      //  OpenGlDrawIndexedBuffer(GL_TRIANGLES,d3d.alpha_vertex_buffer[count],0,vertex_buffer_indices[count].number_of_vertices_buffered,
        //                       buffered_indices[ vertex_buffer_indices[count].base_index]);

			}

			//
			// Turn the blend mode off
			//

			set_d3d_alpha_fog_zbuffer ( FALSE, TRUE, TRUE, TRUE );
		}

		//
		// Reset the things!
		//

		reset_terrain_3d_buffered_polygons ();
	}

}
Exemplo n.º 3
0
void draw_terrain_3d_buffered_polygons ( void )
{

	if ( vertex_buffer != -1 )
	{

		//
		// Finalise the last vertex buffer used
		//

		unlock_d3d_alpha_vertex_buffer ( vertex_buffer );

		vertex_buffer_indices[vertex_buffer].number = base_index - vertex_buffer_indices[vertex_buffer].base_index;

		if ( base_index )
		{

			int
				count;

			//
			// Flush any buffered primitives
			//

			finalise_primitives ();

			//
			// Set the alpha blend modes
			//
	
			set_d3d_alpha_fog_zbuffer ( TRUE, FALSE, TRUE, FALSE );
	
			//
			// Set the texture handle
			//
	
			set_d3d_texture ( 0, terrain_buffered_polygons_texture );
	
			//
			// Draw all the buffered vertex buffers
			//

			for ( count = 0; count <= vertex_buffer; count++ )
			{
				f3d_draw_vb ( D3DPT_TRIANGLELIST, d3d.alpha_vertex_buffer[count],
																						0,
																						vertex_buffer_indices[count].number_of_vertices_buffered,
																						&buffered_indices[ vertex_buffer_indices[count].base_index ],
																						vertex_buffer_indices[count].number );
			}

			//
			// Turn the blend mode off
			//
	
			set_d3d_alpha_fog_zbuffer ( FALSE, TRUE, TRUE, TRUE );
		}

		//
		// Reset the things!
		//

		reset_terrain_3d_buffered_polygons ();
	}
}