Use vertex arrays when possible.
This commit is contained in:
parent
2d6a3fcc22
commit
1eaee42399
|
@ -836,42 +836,36 @@ GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface,
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_primitive_start_GL(D3DPRIMITIVETYPE d3dpt)
|
static GLenum convert_D3D_ptype_to_GL(D3DPRIMITIVETYPE d3dpt)
|
||||||
{
|
{
|
||||||
switch (d3dpt) {
|
switch (d3dpt) {
|
||||||
case D3DPT_POINTLIST:
|
case D3DPT_POINTLIST:
|
||||||
TRACE("Start POINTS\n");
|
TRACE(" primitive type is POINTS\n");
|
||||||
glBegin(GL_POINTS);
|
return GL_POINTS;
|
||||||
break;
|
|
||||||
|
|
||||||
case D3DPT_LINELIST:
|
case D3DPT_LINELIST:
|
||||||
TRACE("Start LINES\n");
|
TRACE(" primitive type is LINES\n");
|
||||||
glBegin(GL_LINES);
|
return GL_LINES;
|
||||||
break;
|
|
||||||
|
|
||||||
case D3DPT_LINESTRIP:
|
case D3DPT_LINESTRIP:
|
||||||
TRACE("Start LINE_STRIP\n");
|
TRACE(" primitive type is LINE_STRIP\n");
|
||||||
glBegin(GL_LINE_STRIP);
|
return GL_LINE_STRIP;
|
||||||
break;
|
|
||||||
|
|
||||||
case D3DPT_TRIANGLELIST:
|
case D3DPT_TRIANGLELIST:
|
||||||
TRACE("Start TRIANGLES\n");
|
TRACE(" primitive type is TRIANGLES\n");
|
||||||
glBegin(GL_TRIANGLES);
|
return GL_TRIANGLES;
|
||||||
break;
|
|
||||||
|
|
||||||
case D3DPT_TRIANGLESTRIP:
|
case D3DPT_TRIANGLESTRIP:
|
||||||
TRACE("Start TRIANGLE_STRIP\n");
|
TRACE(" primitive type is TRIANGLE_STRIP\n");
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
return GL_TRIANGLE_STRIP;
|
||||||
break;
|
|
||||||
|
|
||||||
case D3DPT_TRIANGLEFAN:
|
case D3DPT_TRIANGLEFAN:
|
||||||
TRACE("Start TRIANGLE_FAN\n");
|
TRACE(" primitive type is TRIANGLE_FAN\n");
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
return GL_TRIANGLE_FAN;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("Unhandled primitive %08x\n", d3dpt);
|
FIXME("Unhandled primitive %08x\n", d3dpt);
|
||||||
break;
|
return GL_POINTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,7 +1299,8 @@ static void draw_primitive_strided(IDirect3DDeviceImpl *This,
|
||||||
BOOLEAN vertex_lighted = FALSE;
|
BOOLEAN vertex_lighted = FALSE;
|
||||||
IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
|
IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
|
||||||
int num_active_stages = 0;
|
int num_active_stages = 0;
|
||||||
|
int num_tex_index = ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
|
||||||
|
|
||||||
/* I put the trace before the various locks... So as to better understand where locks occur :-) */
|
/* I put the trace before the various locks... So as to better understand where locks occur :-) */
|
||||||
if (TRACE_ON(ddraw)) {
|
if (TRACE_ON(ddraw)) {
|
||||||
TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
|
TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
|
||||||
|
@ -1356,167 +1351,228 @@ static void draw_primitive_strided(IDirect3DDeviceImpl *This,
|
||||||
draw_primitive_handle_GL_state(This,
|
draw_primitive_handle_GL_state(This,
|
||||||
(d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ,
|
(d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ,
|
||||||
vertex_lighted);
|
vertex_lighted);
|
||||||
draw_primitive_start_GL(d3dptPrimitiveType);
|
|
||||||
|
|
||||||
/* Some fast paths first before the generic case.... */
|
/* First, see if we can use the OpenGL vertex arrays... This is very limited
|
||||||
if ((d3dvtVertexType == D3DFVF_VERTEX) && (num_active_stages <= 1)) {
|
for now to some 'special' cases where we can do a direct mapping between D3D
|
||||||
int index;
|
types and GL types.
|
||||||
|
|
||||||
for (index = 0; index < dwIndexCount; index++) {
|
Note that in the future all calls will go through vertex arrays but the arrays
|
||||||
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
will be generated by this function. */
|
||||||
D3DVALUE *normal =
|
if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) && /* Standard XYZ vertices */
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
(((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == 0) || /* Either no colours */
|
||||||
D3DVALUE *tex_coord =
|
(((d3dvtVertexType & D3DFVF_DIFFUSE) != 0) && /* Or diffuse only but the Alpha component is not used */
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);
|
(This->state_block.render_state[D3DRENDERSTATE_ALPHATESTENABLE - 1] == FALSE) &&
|
||||||
D3DVALUE *position =
|
(This->state_block.render_state[D3DRENDERSTATE_ALPHABLENDENABLE - 1] == FALSE)))) {
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
int tex_stage;
|
||||||
|
TRACE(" using GL vertex arrays for performance !\n");
|
||||||
handle_normal(normal);
|
/* First, the vertices (we are sure we have some :-) */
|
||||||
handle_texture(tex_coord);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
handle_xyz(position);
|
glVertexPointer(3, GL_FLOAT, lpD3DDrawPrimStrideData->position.dwStride, lpD3DDrawPrimStrideData->position.lpvData);
|
||||||
|
/* Then the normals */
|
||||||
TRACE_(ddraw_geom)(" %f %f %f / %f %f %f (%f %f)\n",
|
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
||||||
position[0], position[1], position[2],
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
normal[0], normal[1], normal[2],
|
glNormalPointer(GL_FLOAT, lpD3DDrawPrimStrideData->normal.dwStride, lpD3DDrawPrimStrideData->normal.lpvData);
|
||||||
tex_coord[0], tex_coord[1]);
|
|
||||||
}
|
}
|
||||||
} else if ((d3dvtVertexType == D3DFVF_TLVERTEX) && (num_active_stages <= 1)) {
|
/* Then the diffuse colour */
|
||||||
int index;
|
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
for (index = 0; index < dwIndexCount; index++) {
|
glColorPointer(3, GL_UNSIGNED_BYTE, lpD3DDrawPrimStrideData->normal.dwStride,
|
||||||
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
((char *) lpD3DDrawPrimStrideData->diffuse.lpvData));
|
||||||
DWORD *color_d =
|
}
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
/* Then the various textures */
|
||||||
DWORD *color_s =
|
for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) {
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF;
|
||||||
D3DVALUE *tex_coord =
|
if (tex_index >= num_tex_index) {
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);
|
WARN("Default texture coordinate not handled in the vertex array path !!!\n");
|
||||||
D3DVALUE *position =
|
tex_index = num_tex_index - 1;
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
|
||||||
|
|
||||||
handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, TRUE);
|
|
||||||
handle_texture(tex_coord);
|
|
||||||
handle_xyzrhw(position);
|
|
||||||
|
|
||||||
TRACE_(ddraw_geom)(" %f %f %f %f / %02lx %02lx %02lx %02lx - %02lx %02lx %02lx %02lx (%f %f)\n",
|
|
||||||
position[0], position[1], position[2], position[3],
|
|
||||||
(*color_d >> 16) & 0xFF,
|
|
||||||
(*color_d >> 8) & 0xFF,
|
|
||||||
(*color_d >> 0) & 0xFF,
|
|
||||||
(*color_d >> 24) & 0xFF,
|
|
||||||
(*color_s >> 16) & 0xFF,
|
|
||||||
(*color_s >> 8) & 0xFF,
|
|
||||||
(*color_s >> 0) & 0xFF,
|
|
||||||
(*color_s >> 24) & 0xFF,
|
|
||||||
tex_coord[0], tex_coord[1]);
|
|
||||||
}
|
|
||||||
} else if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) ||
|
|
||||||
((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)) {
|
|
||||||
/* This is the 'slow path' but that should support all possible vertex formats out there...
|
|
||||||
Note that people should write a fast path for all vertex formats out there...
|
|
||||||
*/
|
|
||||||
int index;
|
|
||||||
int num_tex_index = ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);
|
|
||||||
static const D3DVALUE no_index[] = { 0.0, 0.0, 0.0, 0.0 };
|
|
||||||
|
|
||||||
for (index = 0; index < dwIndexCount; index++) {
|
|
||||||
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
|
||||||
int tex_stage;
|
|
||||||
|
|
||||||
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
|
||||||
D3DVALUE *normal =
|
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
|
||||||
handle_normal(normal);
|
|
||||||
}
|
}
|
||||||
if ((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) {
|
if (GL_extensions.glClientActiveTexture) {
|
||||||
DWORD *color_d =
|
GL_extensions.glClientActiveTexture(GL_TEXTURE0_WINE + tex_stage);
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
|
||||||
DWORD *color_s =
|
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
|
||||||
handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, vertex_lighted);
|
|
||||||
} else {
|
|
||||||
if (d3dvtVertexType & D3DFVF_SPECULAR) {
|
|
||||||
DWORD *color_s =
|
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
|
||||||
handle_specular(&(This->state_block), color_s, vertex_lighted);
|
|
||||||
} else if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
|
||||||
DWORD *color_d =
|
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
|
||||||
handle_diffuse(&(This->state_block), color_d, vertex_lighted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) {
|
glTexCoordPointer(2, GL_FLOAT, lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride,
|
||||||
int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF;
|
lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData);
|
||||||
if (tex_index >= num_tex_index) {
|
}
|
||||||
handle_textures((D3DVALUE *) no_index, tex_stage);
|
if (dwIndices != NULL) {
|
||||||
} else {
|
glDrawElements(convert_D3D_ptype_to_GL(d3dptPrimitiveType), dwIndexCount, GL_UNSIGNED_SHORT, dwIndices);
|
||||||
D3DVALUE *tex_coord =
|
} else {
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) +
|
glDrawArrays(convert_D3D_ptype_to_GL(d3dptPrimitiveType), 0, dwIndexCount);
|
||||||
i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);
|
}
|
||||||
handle_textures(tex_coord, tex_stage);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
||||||
}
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
}
|
||||||
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
|
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
||||||
D3DVALUE *position =
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
}
|
||||||
handle_xyz(position);
|
for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) {
|
||||||
} else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
|
if (GL_extensions.glClientActiveTexture) {
|
||||||
D3DVALUE *position =
|
GL_extensions.glClientActiveTexture(GL_TEXTURE0_WINE + tex_stage);
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
|
||||||
handle_xyzrhw(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TRACE_ON(ddraw_geom)) {
|
|
||||||
int tex_index;
|
|
||||||
|
|
||||||
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
|
|
||||||
D3DVALUE *position =
|
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]);
|
|
||||||
} else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
|
|
||||||
D3DVALUE *position =
|
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]);
|
|
||||||
}
|
|
||||||
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
|
||||||
D3DVALUE *normal =
|
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]);
|
|
||||||
}
|
|
||||||
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
|
||||||
DWORD *color_d =
|
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
|
|
||||||
(*color_d >> 16) & 0xFF,
|
|
||||||
(*color_d >> 8) & 0xFF,
|
|
||||||
(*color_d >> 0) & 0xFF,
|
|
||||||
(*color_d >> 24) & 0xFF);
|
|
||||||
}
|
|
||||||
if (d3dvtVertexType & D3DFVF_SPECULAR) {
|
|
||||||
DWORD *color_s =
|
|
||||||
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
|
|
||||||
(*color_s >> 16) & 0xFF,
|
|
||||||
(*color_s >> 8) & 0xFF,
|
|
||||||
(*color_s >> 0) & 0xFF,
|
|
||||||
(*color_s >> 24) & 0xFF);
|
|
||||||
}
|
|
||||||
for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) {
|
|
||||||
D3DVALUE *tex_coord =
|
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) +
|
|
||||||
i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);
|
|
||||||
TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]);
|
|
||||||
}
|
|
||||||
TRACE_(ddraw_geom)("\n");
|
|
||||||
}
|
}
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ERR(" matrix weighting not handled yet....\n");
|
glBegin(convert_D3D_ptype_to_GL(d3dptPrimitiveType));
|
||||||
|
|
||||||
|
/* Some fast paths first before the generic case.... */
|
||||||
|
if ((d3dvtVertexType == D3DFVF_VERTEX) && (num_active_stages <= 1)) {
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = 0; index < dwIndexCount; index++) {
|
||||||
|
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
||||||
|
D3DVALUE *normal =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
||||||
|
D3DVALUE *tex_coord =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
|
||||||
|
handle_normal(normal);
|
||||||
|
handle_texture(tex_coord);
|
||||||
|
handle_xyz(position);
|
||||||
|
|
||||||
|
TRACE_(ddraw_geom)(" %f %f %f / %f %f %f (%f %f)\n",
|
||||||
|
position[0], position[1], position[2],
|
||||||
|
normal[0], normal[1], normal[2],
|
||||||
|
tex_coord[0], tex_coord[1]);
|
||||||
|
}
|
||||||
|
} else if ((d3dvtVertexType == D3DFVF_TLVERTEX) && (num_active_stages <= 1)) {
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = 0; index < dwIndexCount; index++) {
|
||||||
|
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
||||||
|
DWORD *color_d =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||||
|
DWORD *color_s =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
||||||
|
D3DVALUE *tex_coord =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
|
||||||
|
handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, TRUE);
|
||||||
|
handle_texture(tex_coord);
|
||||||
|
handle_xyzrhw(position);
|
||||||
|
|
||||||
|
TRACE_(ddraw_geom)(" %f %f %f %f / %02lx %02lx %02lx %02lx - %02lx %02lx %02lx %02lx (%f %f)\n",
|
||||||
|
position[0], position[1], position[2], position[3],
|
||||||
|
(*color_d >> 16) & 0xFF,
|
||||||
|
(*color_d >> 8) & 0xFF,
|
||||||
|
(*color_d >> 0) & 0xFF,
|
||||||
|
(*color_d >> 24) & 0xFF,
|
||||||
|
(*color_s >> 16) & 0xFF,
|
||||||
|
(*color_s >> 8) & 0xFF,
|
||||||
|
(*color_s >> 0) & 0xFF,
|
||||||
|
(*color_s >> 24) & 0xFF,
|
||||||
|
tex_coord[0], tex_coord[1]);
|
||||||
|
}
|
||||||
|
} else if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) ||
|
||||||
|
((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)) {
|
||||||
|
/* This is the 'slow path' but that should support all possible vertex formats out there...
|
||||||
|
Note that people should write a fast path for all vertex formats out there...
|
||||||
|
*/
|
||||||
|
int index;
|
||||||
|
static const D3DVALUE no_index[] = { 0.0, 0.0, 0.0, 0.0 };
|
||||||
|
|
||||||
|
for (index = 0; index < dwIndexCount; index++) {
|
||||||
|
int i = (dwIndices == NULL) ? index : dwIndices[index];
|
||||||
|
int tex_stage;
|
||||||
|
|
||||||
|
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
||||||
|
D3DVALUE *normal =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
||||||
|
handle_normal(normal);
|
||||||
|
}
|
||||||
|
if ((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) {
|
||||||
|
DWORD *color_d =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||||
|
DWORD *color_s =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
||||||
|
handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, vertex_lighted);
|
||||||
|
} else {
|
||||||
|
if (d3dvtVertexType & D3DFVF_SPECULAR) {
|
||||||
|
DWORD *color_s =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
||||||
|
handle_specular(&(This->state_block), color_s, vertex_lighted);
|
||||||
|
} else if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
||||||
|
DWORD *color_d =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||||
|
handle_diffuse(&(This->state_block), color_d, vertex_lighted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) {
|
||||||
|
int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF;
|
||||||
|
if (tex_index >= num_tex_index) {
|
||||||
|
handle_textures((D3DVALUE *) no_index, tex_stage);
|
||||||
|
} else {
|
||||||
|
D3DVALUE *tex_coord =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) +
|
||||||
|
i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);
|
||||||
|
handle_textures(tex_coord, tex_stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
handle_xyz(position);
|
||||||
|
} else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
handle_xyzrhw(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TRACE_ON(ddraw_geom)) {
|
||||||
|
int tex_index;
|
||||||
|
|
||||||
|
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]);
|
||||||
|
} else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
|
||||||
|
D3DVALUE *position =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]);
|
||||||
|
}
|
||||||
|
if (d3dvtVertexType & D3DFVF_NORMAL) {
|
||||||
|
D3DVALUE *normal =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]);
|
||||||
|
}
|
||||||
|
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
|
||||||
|
DWORD *color_d =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
|
||||||
|
(*color_d >> 16) & 0xFF,
|
||||||
|
(*color_d >> 8) & 0xFF,
|
||||||
|
(*color_d >> 0) & 0xFF,
|
||||||
|
(*color_d >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
if (d3dvtVertexType & D3DFVF_SPECULAR) {
|
||||||
|
DWORD *color_s =
|
||||||
|
(DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
|
||||||
|
(*color_s >> 16) & 0xFF,
|
||||||
|
(*color_s >> 8) & 0xFF,
|
||||||
|
(*color_s >> 0) & 0xFF,
|
||||||
|
(*color_s >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) {
|
||||||
|
D3DVALUE *tex_coord =
|
||||||
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) +
|
||||||
|
i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);
|
||||||
|
TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]);
|
||||||
|
}
|
||||||
|
TRACE_(ddraw_geom)("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ERR(" matrix weighting not handled yet....\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
/* Whatever the case, disable the color material stuff */
|
/* Whatever the case, disable the color material stuff */
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
|
@ -4203,6 +4259,7 @@ d3ddevice_init_at_startup(void *gl_handle)
|
||||||
/* We query the ARB version to be the most portable we can... */
|
/* We query the ARB version to be the most portable we can... */
|
||||||
GL_extensions.glActiveTexture = pglXGetProcAddressARB("glActiveTextureARB");
|
GL_extensions.glActiveTexture = pglXGetProcAddressARB("glActiveTextureARB");
|
||||||
GL_extensions.glMultiTexCoord2fv = pglXGetProcAddressARB("glMultiTexCoord2fv");
|
GL_extensions.glMultiTexCoord2fv = pglXGetProcAddressARB("glMultiTexCoord2fv");
|
||||||
|
GL_extensions.glClientActiveTexture = pglXGetProcAddressARB("glClientActiveTextureARB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ GL_API_FUNCTION(glColor3ub)
|
||||||
GL_API_FUNCTION(glColor4ub)
|
GL_API_FUNCTION(glColor4ub)
|
||||||
GL_API_FUNCTION(glColorMask)
|
GL_API_FUNCTION(glColorMask)
|
||||||
GL_API_FUNCTION(glColorMaterial)
|
GL_API_FUNCTION(glColorMaterial)
|
||||||
|
GL_API_FUNCTION(glColorPointer)
|
||||||
GL_API_FUNCTION(glCopyPixels)
|
GL_API_FUNCTION(glCopyPixels)
|
||||||
GL_API_FUNCTION(glCopyTexSubImage2D)
|
GL_API_FUNCTION(glCopyTexSubImage2D)
|
||||||
GL_API_FUNCTION(glCullFace)
|
GL_API_FUNCTION(glCullFace)
|
||||||
|
@ -48,9 +49,13 @@ GL_API_FUNCTION(glDepthFunc)
|
||||||
GL_API_FUNCTION(glDepthMask)
|
GL_API_FUNCTION(glDepthMask)
|
||||||
GL_API_FUNCTION(glDepthRange)
|
GL_API_FUNCTION(glDepthRange)
|
||||||
GL_API_FUNCTION(glDisable)
|
GL_API_FUNCTION(glDisable)
|
||||||
|
GL_API_FUNCTION(glDisableClientState)
|
||||||
|
GL_API_FUNCTION(glDrawArrays)
|
||||||
GL_API_FUNCTION(glDrawBuffer)
|
GL_API_FUNCTION(glDrawBuffer)
|
||||||
|
GL_API_FUNCTION(glDrawElements)
|
||||||
GL_API_FUNCTION(glDrawPixels)
|
GL_API_FUNCTION(glDrawPixels)
|
||||||
GL_API_FUNCTION(glEnable)
|
GL_API_FUNCTION(glEnable)
|
||||||
|
GL_API_FUNCTION(glEnableClientState)
|
||||||
GL_API_FUNCTION(glEnd)
|
GL_API_FUNCTION(glEnd)
|
||||||
GL_API_FUNCTION(glFlush)
|
GL_API_FUNCTION(glFlush)
|
||||||
GL_API_FUNCTION(glFogf)
|
GL_API_FUNCTION(glFogf)
|
||||||
|
@ -77,6 +82,7 @@ GL_API_FUNCTION(glMatrixMode)
|
||||||
GL_API_FUNCTION(glMultMatrixf)
|
GL_API_FUNCTION(glMultMatrixf)
|
||||||
GL_API_FUNCTION(glNormal3f)
|
GL_API_FUNCTION(glNormal3f)
|
||||||
GL_API_FUNCTION(glNormal3fv)
|
GL_API_FUNCTION(glNormal3fv)
|
||||||
|
GL_API_FUNCTION(glNormalPointer)
|
||||||
GL_API_FUNCTION(glOrtho)
|
GL_API_FUNCTION(glOrtho)
|
||||||
GL_API_FUNCTION(glPixelStorei)
|
GL_API_FUNCTION(glPixelStorei)
|
||||||
GL_API_FUNCTION(glPolygonMode)
|
GL_API_FUNCTION(glPolygonMode)
|
||||||
|
@ -94,6 +100,7 @@ GL_API_FUNCTION(glStencilMask)
|
||||||
GL_API_FUNCTION(glStencilOp)
|
GL_API_FUNCTION(glStencilOp)
|
||||||
GL_API_FUNCTION(glTexCoord2f)
|
GL_API_FUNCTION(glTexCoord2f)
|
||||||
GL_API_FUNCTION(glTexCoord2fv)
|
GL_API_FUNCTION(glTexCoord2fv)
|
||||||
|
GL_API_FUNCTION(glTexCoordPointer)
|
||||||
GL_API_FUNCTION(glTexEnvf)
|
GL_API_FUNCTION(glTexEnvf)
|
||||||
GL_API_FUNCTION(glTexEnvfv)
|
GL_API_FUNCTION(glTexEnvfv)
|
||||||
GL_API_FUNCTION(glTexEnvi)
|
GL_API_FUNCTION(glTexEnvi)
|
||||||
|
@ -106,6 +113,7 @@ GL_API_FUNCTION(glVertex3d)
|
||||||
GL_API_FUNCTION(glVertex3f)
|
GL_API_FUNCTION(glVertex3f)
|
||||||
GL_API_FUNCTION(glVertex3fv)
|
GL_API_FUNCTION(glVertex3fv)
|
||||||
GL_API_FUNCTION(glVertex4f)
|
GL_API_FUNCTION(glVertex4f)
|
||||||
|
GL_API_FUNCTION(glVertexPointer)
|
||||||
GL_API_FUNCTION(glViewport)
|
GL_API_FUNCTION(glViewport)
|
||||||
GL_API_FUNCTION(glXCreateContext)
|
GL_API_FUNCTION(glXCreateContext)
|
||||||
GL_API_FUNCTION(glXDestroyContext)
|
GL_API_FUNCTION(glXDestroyContext)
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
#define glColor3ub pglColor3ub
|
#define glColor3ub pglColor3ub
|
||||||
#define glColor4ub pglColor4ub
|
#define glColor4ub pglColor4ub
|
||||||
#define glColorMask pglColorMask
|
#define glColorMask pglColorMask
|
||||||
|
#define glColorPointer pglColorPointer
|
||||||
#define glCopyPixels pglCopyPixels
|
#define glCopyPixels pglCopyPixels
|
||||||
#define glCopyTexSubImage2D pglCopyTexSubImage2D
|
#define glCopyTexSubImage2D pglCopyTexSubImage2D
|
||||||
#define glColorMaterial pglColorMaterial
|
#define glColorMaterial pglColorMaterial
|
||||||
|
@ -91,9 +92,13 @@
|
||||||
#define glDepthMask pglDepthMask
|
#define glDepthMask pglDepthMask
|
||||||
#define glDepthRange pglDepthRange
|
#define glDepthRange pglDepthRange
|
||||||
#define glDisable pglDisable
|
#define glDisable pglDisable
|
||||||
|
#define glDisableClientState pglDisableClientState
|
||||||
|
#define glDrawArrays pglDrawArrays
|
||||||
#define glDrawBuffer pglDrawBuffer
|
#define glDrawBuffer pglDrawBuffer
|
||||||
|
#define glDrawElements pglDrawElements
|
||||||
#define glDrawPixels pglDrawPixels
|
#define glDrawPixels pglDrawPixels
|
||||||
#define glEnable pglEnable
|
#define glEnable pglEnable
|
||||||
|
#define glEnableClientState pglEnableClientState
|
||||||
#define glEnd pglEnd
|
#define glEnd pglEnd
|
||||||
#define glFlush pglFlush
|
#define glFlush pglFlush
|
||||||
#define glFogf pglFogf
|
#define glFogf pglFogf
|
||||||
|
@ -120,6 +125,7 @@
|
||||||
#define glMultMatrixf pglMultMatrixf
|
#define glMultMatrixf pglMultMatrixf
|
||||||
#define glNormal3f pglNormal3f
|
#define glNormal3f pglNormal3f
|
||||||
#define glNormal3fv pglNormal3fv
|
#define glNormal3fv pglNormal3fv
|
||||||
|
#define glNormalPointer pglNormalPointer
|
||||||
#define glOrtho pglOrtho
|
#define glOrtho pglOrtho
|
||||||
#define glPixelStorei pglPixelStorei
|
#define glPixelStorei pglPixelStorei
|
||||||
#define glPolygonMode pglPolygonMode
|
#define glPolygonMode pglPolygonMode
|
||||||
|
@ -137,6 +143,7 @@
|
||||||
#define glStencilOp pglStencilOp
|
#define glStencilOp pglStencilOp
|
||||||
#define glTexCoord2f pglTexCoord2f
|
#define glTexCoord2f pglTexCoord2f
|
||||||
#define glTexCoord2fv pglTexCoord2fv
|
#define glTexCoord2fv pglTexCoord2fv
|
||||||
|
#define glTexCoordPointer pglTexCoordPointer
|
||||||
#define glTexEnvf pglTexEnvf
|
#define glTexEnvf pglTexEnvf
|
||||||
#define glTexEnvfv pglTexEnvfv
|
#define glTexEnvfv pglTexEnvfv
|
||||||
#define glTexEnvi pglTexEnvi
|
#define glTexEnvi pglTexEnvi
|
||||||
|
@ -149,6 +156,7 @@
|
||||||
#define glVertex3f pglVertex3f
|
#define glVertex3f pglVertex3f
|
||||||
#define glVertex3fv pglVertex3fv
|
#define glVertex3fv pglVertex3fv
|
||||||
#define glVertex4f pglVertex4f
|
#define glVertex4f pglVertex4f
|
||||||
|
#define glVertexPointer pglVertexPointer
|
||||||
#define glViewport pglViewport
|
#define glViewport pglViewport
|
||||||
#define glXCreateContext pglXCreateContext
|
#define glXCreateContext pglXCreateContext
|
||||||
#define glXDestroyContext pglXDestroyContext
|
#define glXDestroyContext pglXDestroyContext
|
||||||
|
|
|
@ -174,6 +174,7 @@ typedef struct {
|
||||||
GLint max_texture_units;
|
GLint max_texture_units;
|
||||||
void (*glActiveTexture)(GLenum texture);
|
void (*glActiveTexture)(GLenum texture);
|
||||||
void (*glMultiTexCoord2fv)(GLenum target, const GLfloat *v);
|
void (*glMultiTexCoord2fv)(GLenum target, const GLfloat *v);
|
||||||
|
void (*glClientActiveTexture)(GLenum texture);
|
||||||
} GL_EXTENSIONS_LIST;
|
} GL_EXTENSIONS_LIST;
|
||||||
extern GL_EXTENSIONS_LIST GL_extensions;
|
extern GL_EXTENSIONS_LIST GL_extensions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue