2004-12-09 12:42:34 +01:00
|
|
|
/*
|
|
|
|
* WINED3D draw functions
|
|
|
|
*
|
|
|
|
* Copyright 2002-2004 Jason Edmeades
|
|
|
|
* Copyright 2002-2004 Raphael Junqueira
|
2005-07-13 16:15:54 +02:00
|
|
|
* Copyright 2004 Christian Costa
|
2005-07-11 16:25:54 +02:00
|
|
|
* Copyright 2005 Oliver Stieber
|
2004-12-09 12:42:34 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-12-09 12:42:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
|
2004-12-09 12:42:34 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
|
|
|
|
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
|
|
|
|
|
2005-09-27 12:49:59 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
#if 0 /* TODO */
|
2005-08-19 12:05:00 +02:00
|
|
|
extern IWineD3DVertexShaderImpl* VertexShaders[64];
|
|
|
|
extern IWineD3DVertexDeclarationImpl* VertexShaderDeclarations[64];
|
|
|
|
extern IWineD3DPixelShaderImpl* PixelShaders[64];
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
#undef GL_VERSION_1_4 /* To be fixed, caused by mesa headers */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Issues the glBegin call for gl given the primitive type and count */
|
2005-07-14 14:19:53 +02:00
|
|
|
static DWORD primitiveToGl(D3DPRIMITIVETYPE PrimitiveType,
|
2004-12-09 12:42:34 +01:00
|
|
|
DWORD NumPrimitives,
|
|
|
|
GLenum *primType)
|
|
|
|
{
|
|
|
|
DWORD NumVertexes = NumPrimitives;
|
|
|
|
|
|
|
|
switch (PrimitiveType) {
|
|
|
|
case D3DPT_POINTLIST:
|
|
|
|
TRACE("POINTS\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_POINTS;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPT_LINELIST:
|
|
|
|
TRACE("LINES\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_LINES;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives * 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPT_LINESTRIP:
|
|
|
|
TRACE("LINE_STRIP\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_LINE_STRIP;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPT_TRIANGLELIST:
|
|
|
|
TRACE("TRIANGLES\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_TRIANGLES;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives * 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPT_TRIANGLESTRIP:
|
|
|
|
TRACE("TRIANGLE_STRIP\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_TRIANGLE_STRIP;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives + 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DPT_TRIANGLEFAN:
|
|
|
|
TRACE("TRIANGLE_FAN\n");
|
2005-07-30 21:06:14 +02:00
|
|
|
*primType = GL_TRIANGLE_FAN;
|
2004-12-09 12:42:34 +01:00
|
|
|
NumVertexes = NumPrimitives + 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled primitive\n");
|
|
|
|
*primType = GL_POINTS;
|
|
|
|
break;
|
2005-07-13 16:15:54 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
return NumVertexes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure the appropriate material states are set up - only change
|
|
|
|
state if really required */
|
2005-07-14 14:19:53 +02:00
|
|
|
static void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
BOOL requires_material_reset = FALSE;
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
|
|
|
if (This->tracking_color == NEEDS_TRACKING && isDiffuseSupplied) {
|
|
|
|
/* If we have not set up the material color tracking, do it now as required */
|
|
|
|
glDisable(GL_COLOR_MATERIAL); /* Note: Man pages state must enable AFTER calling glColorMaterial! Required?*/
|
|
|
|
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
|
|
|
TRACE("glColorMaterial Parm=%x\n", This->tracking_parm);
|
|
|
|
glColorMaterial(GL_FRONT_AND_BACK, This->tracking_parm);
|
|
|
|
checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
|
2005-07-13 16:15:54 +02:00
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glEnable GL_COLOR_MATERIAL");
|
|
|
|
This->tracking_color = IS_TRACKING;
|
|
|
|
requires_material_reset = TRUE; /* Restore material settings as will be used */
|
|
|
|
|
2006-09-26 20:31:58 +02:00
|
|
|
} else if ((This->tracking_color == IS_TRACKING && !isDiffuseSupplied) ||
|
|
|
|
(This->tracking_color == NEEDS_TRACKING && !isDiffuseSupplied)) {
|
2004-12-09 12:42:34 +01:00
|
|
|
/* If we are tracking the current color but one isn't supplied, don't! */
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
|
|
|
This->tracking_color = NEEDS_TRACKING;
|
|
|
|
requires_material_reset = TRUE; /* Restore material settings as will be used */
|
|
|
|
|
|
|
|
} else if (This->tracking_color == IS_TRACKING && isDiffuseSupplied) {
|
|
|
|
/* No need to reset material colors since no change to gl_color_material */
|
|
|
|
requires_material_reset = FALSE;
|
|
|
|
|
|
|
|
} else if (This->tracking_color == NEEDS_DISABLE) {
|
|
|
|
glDisable(GL_COLOR_MATERIAL);
|
|
|
|
checkGLcall("glDisable GL_COLOR_MATERIAL");
|
|
|
|
This->tracking_color = DISABLED_TRACKING;
|
|
|
|
requires_material_reset = TRUE; /* Restore material settings as will be used */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the material colors which may have been tracking the color*/
|
|
|
|
if (requires_material_reset) {
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*) &This->stateBlock->material.Ambient);
|
|
|
|
checkGLcall("glMaterialfv");
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*) &This->stateBlock->material.Diffuse);
|
|
|
|
checkGLcall("glMaterialfv");
|
2005-07-30 21:06:14 +02:00
|
|
|
if (This->stateBlock->renderState[WINED3DRS_SPECULARENABLE]) {
|
2004-12-09 12:42:34 +01:00
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->stateBlock->material.Specular);
|
|
|
|
checkGLcall("glMaterialfv");
|
|
|
|
} else {
|
|
|
|
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
|
|
|
|
checkGLcall("glMaterialfv");
|
|
|
|
}
|
|
|
|
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*) &This->stateBlock->material.Emissive);
|
|
|
|
checkGLcall("glMaterialfv");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-30 21:06:14 +02:00
|
|
|
static GLfloat invymat[16] = {
|
2004-12-09 12:42:34 +01:00
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, -1.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 1.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f};
|
|
|
|
|
2006-05-25 11:40:36 +02:00
|
|
|
void d3ddevice_set_ortho(IWineD3DDeviceImpl *This) {
|
|
|
|
/* If the last draw was transformed as well, no need to reapply all the matrixes */
|
|
|
|
if ( (!This->last_was_rhw) || (This->viewport_changed) ) {
|
|
|
|
|
|
|
|
double X, Y, height, width, minZ, maxZ;
|
|
|
|
This->last_was_rhw = TRUE;
|
|
|
|
This->viewport_changed = FALSE;
|
|
|
|
|
|
|
|
/* Transformed already into viewport coordinates, so we do not need transform
|
|
|
|
matrices. Reset all matrices to identity and leave the default matrix in world
|
|
|
|
mode. */
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
checkGLcall("glMatrixMode(GL_MODELVIEW)");
|
|
|
|
glLoadIdentity();
|
|
|
|
checkGLcall("glLoadIdentity");
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
checkGLcall("glMatrixMode(GL_PROJECTION)");
|
|
|
|
glLoadIdentity();
|
|
|
|
checkGLcall("glLoadIdentity");
|
|
|
|
|
|
|
|
/* Set up the viewport to be full viewport */
|
|
|
|
X = This->stateBlock->viewport.X;
|
|
|
|
Y = This->stateBlock->viewport.Y;
|
|
|
|
height = This->stateBlock->viewport.Height;
|
|
|
|
width = This->stateBlock->viewport.Width;
|
|
|
|
minZ = This->stateBlock->viewport.MinZ;
|
|
|
|
maxZ = This->stateBlock->viewport.MaxZ;
|
2006-08-21 18:28:05 +02:00
|
|
|
if(!This->untransformed) {
|
|
|
|
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
|
|
|
|
glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
|
|
|
|
} else {
|
|
|
|
TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
|
|
|
|
glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
|
|
|
|
}
|
2006-05-25 11:40:36 +02:00
|
|
|
checkGLcall("glOrtho");
|
|
|
|
|
|
|
|
/* Window Coord 0 is the middle of the first pixel, so translate by half
|
|
|
|
a pixel (See comment above glTranslate below) */
|
|
|
|
glTranslatef(0.375, 0.375, 0);
|
|
|
|
checkGLcall("glTranslatef(0.375, 0.375, 0)");
|
|
|
|
if (This->renderUpsideDown) {
|
|
|
|
glMultMatrixf(invymat);
|
|
|
|
checkGLcall("glMultMatrixf(invymat)");
|
|
|
|
}
|
|
|
|
|
2006-06-12 13:25:10 +02:00
|
|
|
/* Vertex fog on transformed vertices? Use the calculated fog factor stored in the specular color */
|
|
|
|
if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] && This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] != D3DFOG_NONE) {
|
|
|
|
if(GL_SUPPORT(EXT_FOG_COORD)) {
|
2006-06-16 00:24:46 +02:00
|
|
|
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
|
|
|
|
checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
|
2006-06-12 13:25:10 +02:00
|
|
|
glFogi(GL_FOG_MODE, GL_LINEAR);
|
|
|
|
checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
|
|
|
|
/* The dx fog range in this case is fixed to 0 - 255,
|
|
|
|
* but in GL it still depends on the fog start and end (according to the ext)
|
|
|
|
* Use this to turn around the fog as it's needed. That prevents some
|
|
|
|
* calculations during drawing :-)
|
|
|
|
*/
|
|
|
|
glFogf(GL_FOG_START, (float) 0xff);
|
|
|
|
checkGLcall("glFogfv GL_FOG_END");
|
|
|
|
glFogf(GL_FOG_END, 0.0);
|
|
|
|
checkGLcall("glFogfv GL_FOG_START");
|
|
|
|
} else {
|
|
|
|
/* Disable GL fog, handle this in software in drawStridedSlow */
|
|
|
|
glDisable(GL_FOG);
|
|
|
|
checkGLcall("glDisable(GL_FOG)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-25 11:40:36 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Setup views - Transformed & lit if RHW, else untransformed.
|
2005-07-13 16:15:54 +02:00
|
|
|
Only unlit if Normals are supplied
|
2004-12-09 12:42:34 +01:00
|
|
|
Returns: Whether to restore lighting afterwards */
|
2006-07-07 15:15:20 +02:00
|
|
|
static void primitiveInitState(
|
|
|
|
IWineD3DDevice *iface,
|
|
|
|
WineDirect3DVertexStridedData* strided,
|
|
|
|
BOOL useVS,
|
|
|
|
BOOL* lighting_changed,
|
|
|
|
BOOL* lighting_original) {
|
|
|
|
|
|
|
|
BOOL fixed_vtx_transformed =
|
|
|
|
(strided->u.s.position.lpData != NULL || strided->u.s.position.VBO != 0 ||
|
|
|
|
strided->u.s.position2.lpData != NULL || strided->u.s.position2.VBO != 0) &&
|
|
|
|
strided->u.s.position_transformed;
|
|
|
|
|
|
|
|
BOOL fixed_vtx_lit =
|
|
|
|
strided->u.s.normal.lpData == NULL && strided->u.s.normal.VBO == 0 &&
|
|
|
|
strided->u.s.normal2.lpData == NULL && strided->u.s.normal2.VBO == 0;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
2006-07-07 15:15:20 +02:00
|
|
|
*lighting_changed = FALSE;
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* If no normals, DISABLE lighting otherwise, don't touch lighing as it is
|
|
|
|
set by the appropriate render state. Note Vertex Shader output is already lit */
|
2006-07-07 15:15:20 +02:00
|
|
|
if (fixed_vtx_lit || useVS) {
|
|
|
|
*lighting_changed = TRUE;
|
|
|
|
*lighting_original = glIsEnabled(GL_LIGHTING);
|
2004-12-09 12:42:34 +01:00
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
checkGLcall("glDisable(GL_LIGHTING);");
|
2006-07-07 15:15:20 +02:00
|
|
|
TRACE("Disabled lighting, old state = %d\n", *lighting_original);
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
2006-07-07 15:15:20 +02:00
|
|
|
if (!useVS && fixed_vtx_transformed) {
|
2006-05-25 11:40:36 +02:00
|
|
|
d3ddevice_set_ortho(This);
|
2006-06-12 13:25:10 +02:00
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Untransformed, so relies on the view and projection matrices */
|
2006-08-21 18:28:05 +02:00
|
|
|
This->untransformed = TRUE;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
if (!useVS && (This->last_was_rhw || !This->modelview_valid)) {
|
|
|
|
/* Only reapply when have to */
|
|
|
|
This->modelview_valid = TRUE;
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
checkGLcall("glMatrixMode");
|
|
|
|
|
|
|
|
/* In the general case, the view matrix is the identity matrix */
|
|
|
|
if (This->view_ident) {
|
2006-07-24 04:54:30 +02:00
|
|
|
glLoadMatrixf((float *) &This->stateBlock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glLoadMatrixf");
|
|
|
|
} else {
|
2006-07-24 04:54:30 +02:00
|
|
|
glLoadMatrixf((float *) &This->stateBlock->transforms[WINED3DTS_VIEW].u.m[0][0]);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glLoadMatrixf");
|
2006-07-24 04:54:30 +02:00
|
|
|
glMultMatrixf((float *) &This->stateBlock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glMultMatrixf");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!useVS && (This->last_was_rhw || !This->proj_valid)) {
|
|
|
|
/* Only reapply when have to */
|
|
|
|
This->proj_valid = TRUE;
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
checkGLcall("glMatrixMode");
|
|
|
|
|
|
|
|
/* The rule is that the window coordinate 0 does not correspond to the
|
|
|
|
beginning of the first pixel, but the center of the first pixel.
|
|
|
|
As a consequence if you want to correctly draw one line exactly from
|
|
|
|
the left to the right end of the viewport (with all matrices set to
|
|
|
|
be identity), the x coords of both ends of the line would be not
|
|
|
|
-1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
|
|
|
|
instead. */
|
|
|
|
glLoadIdentity();
|
2005-07-30 21:06:14 +02:00
|
|
|
|
2005-08-03 21:14:19 +02:00
|
|
|
glTranslatef(0.9 / This->stateBlock->viewport.Width, -0.9 / This->stateBlock->viewport.Height, 0);
|
|
|
|
checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)");
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
if (This->renderUpsideDown) {
|
|
|
|
glMultMatrixf(invymat);
|
|
|
|
checkGLcall("glMultMatrixf(invymat)");
|
|
|
|
}
|
2006-07-24 04:54:30 +02:00
|
|
|
glMultMatrixf((float *) &This->stateBlock->transforms[WINED3DTS_PROJECTION].u.m[0][0]);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glLoadMatrixf");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vertex Shader output is already transformed, so set up identity matrices */
|
|
|
|
if (useVS) {
|
2006-09-23 19:09:06 +02:00
|
|
|
This->posFixup[1] = This->renderUpsideDown ? -1.0 : 1.0;
|
|
|
|
This->posFixup[2] = 0.9 / This->stateBlock->viewport.Width;
|
|
|
|
This->posFixup[3] = -0.9 / This->stateBlock->viewport.Height;
|
2005-07-13 16:15:54 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
This->last_was_rhw = FALSE;
|
2006-06-12 13:25:10 +02:00
|
|
|
|
2006-07-17 07:41:53 +02:00
|
|
|
/* Setup fogging */
|
|
|
|
if (useVS && ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->usesFog) {
|
|
|
|
/* In D3D vertex shader return the 'final' fog value, while in OpenGL it is the 'input' fog value.
|
|
|
|
* The code below 'disables' the OpenGL postprocessing by setting the formula to '1'. */
|
|
|
|
glFogi(GL_FOG_MODE, GL_LINEAR);
|
|
|
|
glFogf(GL_FOG_START, 1.0f);
|
|
|
|
glFogf(GL_FOG_END, 0.0f);
|
|
|
|
|
|
|
|
} else if(This->stateBlock->renderState[WINED3DRS_FOGENABLE]
|
|
|
|
&& This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] != D3DFOG_NONE) {
|
|
|
|
|
2006-06-12 13:25:10 +02:00
|
|
|
if(GL_SUPPORT(EXT_FOG_COORD)) {
|
2006-06-16 00:24:46 +02:00
|
|
|
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
|
|
|
|
checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)\n");
|
2006-06-12 13:25:10 +02:00
|
|
|
/* Reapply the fog range */
|
|
|
|
IWineD3DDevice_SetRenderState(iface, WINED3DRS_FOGSTART, This->stateBlock->renderState[WINED3DRS_FOGSTART]);
|
|
|
|
IWineD3DDevice_SetRenderState(iface, WINED3DRS_FOGEND, This->stateBlock->renderState[WINED3DRS_FOGEND]);
|
|
|
|
/* Restore the fog mode */
|
|
|
|
IWineD3DDevice_SetRenderState(iface, WINED3DRS_FOGTABLEMODE, This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE]);
|
|
|
|
} else {
|
|
|
|
/* Enable GL_FOG again because we disabled it above */
|
|
|
|
glEnable(GL_FOG);
|
|
|
|
checkGLcall("glEnable(GL_FOG)");
|
|
|
|
}
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-07 08:24:24 +02:00
|
|
|
static BOOL fixed_get_input(
|
|
|
|
BYTE usage, BYTE usage_idx,
|
|
|
|
unsigned int* regnum) {
|
|
|
|
|
|
|
|
*regnum = -1;
|
|
|
|
|
|
|
|
/* Those positions must have the order in the
|
|
|
|
* named part of the strided data */
|
|
|
|
|
|
|
|
if ((usage == D3DDECLUSAGE_POSITION || usage == D3DDECLUSAGE_POSITIONT) && usage_idx == 0)
|
|
|
|
*regnum = 0;
|
|
|
|
else if (usage == D3DDECLUSAGE_BLENDWEIGHT && usage_idx == 0)
|
|
|
|
*regnum = 1;
|
|
|
|
else if (usage == D3DDECLUSAGE_BLENDINDICES && usage_idx == 0)
|
|
|
|
*regnum = 2;
|
|
|
|
else if (usage == D3DDECLUSAGE_NORMAL && usage_idx == 0)
|
|
|
|
*regnum = 3;
|
|
|
|
else if (usage == D3DDECLUSAGE_PSIZE && usage_idx == 0)
|
|
|
|
*regnum = 4;
|
|
|
|
else if (usage == D3DDECLUSAGE_COLOR && usage_idx == 0)
|
|
|
|
*regnum = 5;
|
|
|
|
else if (usage == D3DDECLUSAGE_COLOR && usage_idx == 1)
|
|
|
|
*regnum = 6;
|
|
|
|
else if (usage == D3DDECLUSAGE_TEXCOORD && usage_idx < D3DDP_MAXTEXCOORD)
|
|
|
|
*regnum = 7 + usage_idx;
|
|
|
|
else if ((usage == D3DDECLUSAGE_POSITION || usage == D3DDECLUSAGE_POSITIONT) && usage_idx == 1)
|
|
|
|
*regnum = 7 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_NORMAL && usage_idx == 1)
|
|
|
|
*regnum = 8 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_TANGENT && usage_idx == 0)
|
|
|
|
*regnum = 9 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_BINORMAL && usage_idx == 0)
|
|
|
|
*regnum = 10 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_TESSFACTOR && usage_idx == 0)
|
|
|
|
*regnum = 11 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_FOG && usage_idx == 0)
|
|
|
|
*regnum = 12 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_DEPTH && usage_idx == 0)
|
|
|
|
*regnum = 13 + D3DDP_MAXTEXCOORD;
|
|
|
|
else if (usage == D3DDECLUSAGE_SAMPLE && usage_idx == 0)
|
|
|
|
*regnum = 14 + D3DDP_MAXTEXCOORD;
|
|
|
|
|
|
|
|
if (*regnum < 0) {
|
|
|
|
FIXME("Unsupported input stream [usage=%s, usage_idx=%u]\n",
|
|
|
|
debug_d3ddeclusage(usage), usage_idx);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-06-12 08:51:58 +02:00
|
|
|
void primitiveDeclarationConvertToStridedData(
|
|
|
|
IWineD3DDevice *iface,
|
|
|
|
BOOL useVertexShaderFunction,
|
|
|
|
WineDirect3DVertexStridedData *strided,
|
|
|
|
LONG BaseVertexIndex,
|
2006-06-21 15:01:38 +02:00
|
|
|
BOOL *fixup) {
|
2006-06-12 08:51:58 +02:00
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
/* We need to deal with frequency data!*/
|
|
|
|
|
|
|
|
BYTE *data = NULL;
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2005-12-09 11:23:52 +01:00
|
|
|
IWineD3DVertexDeclarationImpl* vertexDeclaration = NULL;
|
2005-07-07 22:45:39 +02:00
|
|
|
int i;
|
2005-12-09 11:23:52 +01:00
|
|
|
WINED3DVERTEXELEMENT *element;
|
2005-07-07 22:45:39 +02:00
|
|
|
DWORD stride;
|
2006-03-22 20:47:54 +01:00
|
|
|
int reg;
|
2005-07-07 22:45:39 +02:00
|
|
|
|
2005-12-09 11:23:52 +01:00
|
|
|
/* Locate the vertex declaration */
|
2006-07-25 00:50:43 +02:00
|
|
|
if (This->stateBlock->vertexShader && ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration) {
|
2005-12-09 11:23:52 +01:00
|
|
|
TRACE("Using vertex declaration from shader\n");
|
|
|
|
vertexDeclaration = (IWineD3DVertexDeclarationImpl *)((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration;
|
|
|
|
} else {
|
|
|
|
TRACE("Using vertex declaration\n");
|
|
|
|
vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translate the declaration into strided data */
|
|
|
|
for (i = 0 ; i < vertexDeclaration->declarationWNumElements - 1; ++i) {
|
2006-06-21 15:01:38 +02:00
|
|
|
GLint streamVBO = 0;
|
2006-07-07 08:24:24 +02:00
|
|
|
BOOL stride_used;
|
|
|
|
unsigned int idx;
|
2005-12-09 11:23:52 +01:00
|
|
|
|
|
|
|
element = vertexDeclaration->pDeclarationWine + i;
|
2006-09-17 22:26:18 +02:00
|
|
|
TRACE("%p Element %p (%d of %d)\n", vertexDeclaration->pDeclarationWine,
|
|
|
|
element, i + 1, vertexDeclaration->declarationWNumElements - 1);
|
|
|
|
|
|
|
|
if (This->stateBlock->streamSource[element->Stream] == NULL)
|
|
|
|
continue;
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
if (This->stateBlock->streamIsUP) {
|
|
|
|
TRACE("Stream is up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
|
2006-06-21 15:01:38 +02:00
|
|
|
streamVBO = 0;
|
2005-07-07 22:45:39 +02:00
|
|
|
data = (BYTE *)This->stateBlock->streamSource[element->Stream];
|
2006-06-21 15:01:38 +02:00
|
|
|
if(fixup && *fixup) FIXME("Missing fixed and unfixed vertices, expect graphics glitches\n");
|
2005-07-07 22:45:39 +02:00
|
|
|
} else {
|
2005-07-24 19:11:33 +02:00
|
|
|
TRACE("Stream isn't up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
|
2006-06-21 15:01:38 +02:00
|
|
|
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[element->Stream]);
|
|
|
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0, &streamVBO);
|
|
|
|
if(fixup) {
|
|
|
|
if( streamVBO != 0) *fixup = TRUE;
|
|
|
|
else if(*fixup) FIXME("Missing fixed and unfixed vertices, expect graphics glitches\n");
|
|
|
|
}
|
2005-07-07 22:45:39 +02:00
|
|
|
}
|
2005-07-11 16:25:54 +02:00
|
|
|
stride = This->stateBlock->streamStride[element->Stream];
|
2005-07-07 22:45:39 +02:00
|
|
|
data += (BaseVertexIndex * stride);
|
|
|
|
data += element->Offset;
|
2006-03-22 20:47:54 +01:00
|
|
|
reg = element->Reg;
|
2005-12-09 11:23:52 +01:00
|
|
|
|
|
|
|
TRACE("Offset %d Stream %d UsageIndex %d\n", element->Offset, element->Stream, element->UsageIndex);
|
2006-03-22 20:47:54 +01:00
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
if (useVertexShaderFunction)
|
|
|
|
stride_used = vshader_get_input(This->stateBlock->vertexShader,
|
|
|
|
element->Usage, element->UsageIndex, &idx);
|
|
|
|
else
|
|
|
|
stride_used = fixed_get_input(element->Usage, element->UsageIndex, &idx);
|
|
|
|
|
2006-07-07 08:24:24 +02:00
|
|
|
if (stride_used) {
|
|
|
|
TRACE("Loaded %s array %u [usage=%s, usage_idx=%u, "
|
2006-10-01 05:20:10 +02:00
|
|
|
"stream=%u, offset=%u, stride=%u, VBO=%u]\n",
|
2006-07-07 08:24:24 +02:00
|
|
|
useVertexShaderFunction? "shader": "fixed function", idx,
|
|
|
|
debug_d3ddeclusage(element->Usage), element->UsageIndex,
|
|
|
|
element->Stream, element->Offset, stride, streamVBO);
|
|
|
|
|
|
|
|
strided->u.input[idx].lpData = data;
|
|
|
|
strided->u.input[idx].dwType = element->Type;
|
|
|
|
strided->u.input[idx].dwStride = stride;
|
|
|
|
strided->u.input[idx].VBO = streamVBO;
|
2006-07-07 08:27:38 +02:00
|
|
|
if (!useVertexShaderFunction) {
|
|
|
|
if (element->Usage == D3DDECLUSAGE_POSITION)
|
|
|
|
strided->u.s.position_transformed = FALSE;
|
|
|
|
else if (element->Usage == D3DDECLUSAGE_POSITIONT)
|
|
|
|
strided->u.s.position_transformed = TRUE;
|
|
|
|
}
|
2005-07-07 22:45:39 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDirect3DVertexStridedData *strided, GLint streamVBO) {
|
2004-12-09 12:42:34 +01:00
|
|
|
int numBlends;
|
|
|
|
int numTextures;
|
|
|
|
int textureNo;
|
|
|
|
int coordIdxInfo = 0x00; /* Information on number of coords supplied */
|
|
|
|
int numCoords[8]; /* Holding place for D3DFVF_TEXTUREFORMATx */
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
/* Either 3 or 4 floats depending on the FVF */
|
|
|
|
/* FIXME: Can blending data be in a different stream to the position data?
|
|
|
|
and if so using the fixed pipeline how do we handle it */
|
|
|
|
if (thisFVF & D3DFVF_POSITION_MASK) {
|
|
|
|
strided->u.s.position.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.position.dwStride = stride;
|
|
|
|
strided->u.s.position.VBO = streamVBO;
|
|
|
|
data += 3 * sizeof(float);
|
|
|
|
if (thisFVF & D3DFVF_XYZRHW) {
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT4;
|
2006-07-07 15:15:20 +02:00
|
|
|
strided->u.s.position_transformed = TRUE;
|
2006-06-21 15:01:38 +02:00
|
|
|
data += sizeof(float);
|
2006-07-07 15:15:20 +02:00
|
|
|
} else
|
|
|
|
strided->u.s.position_transformed = FALSE;
|
2006-06-21 15:01:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
|
|
|
|
/** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
|
|
|
|
numBlends = 1 + (((thisFVF & D3DFVF_XYZB5) - D3DFVF_XYZB1) >> 1);
|
|
|
|
if(thisFVF & D3DFVF_LASTBETA_UBYTE4) numBlends--;
|
|
|
|
|
|
|
|
if ((thisFVF & D3DFVF_XYZB5 ) > D3DFVF_XYZRHW) {
|
|
|
|
TRACE("Setting blend Weights to %p\n", data);
|
|
|
|
strided->u.s.blendWeights.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.blendWeights.dwType = WINED3DDECLTYPE_FLOAT1 + numBlends - 1;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.blendWeights.dwStride = stride;
|
|
|
|
strided->u.s.blendWeights.VBO = streamVBO;
|
|
|
|
data += numBlends * sizeof(FLOAT);
|
|
|
|
|
|
|
|
if (thisFVF & D3DFVF_LASTBETA_UBYTE4) {
|
|
|
|
strided->u.s.blendMatrixIndices.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.blendMatrixIndices.dwType = WINED3DDECLTYPE_UBYTE4;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.blendMatrixIndices.dwStride= stride;
|
|
|
|
strided->u.s.blendMatrixIndices.VBO = streamVBO;
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Normal is always 3 floats */
|
|
|
|
if (thisFVF & D3DFVF_NORMAL) {
|
|
|
|
strided->u.s.normal.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.normal.dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.normal.dwStride = stride;
|
|
|
|
strided->u.s.normal.VBO = streamVBO;
|
|
|
|
data += 3 * sizeof(FLOAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pointsize is a single float */
|
|
|
|
if (thisFVF & D3DFVF_PSIZE) {
|
|
|
|
strided->u.s.pSize.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.pSize.dwType = WINED3DDECLTYPE_FLOAT1;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.pSize.dwStride = stride;
|
|
|
|
strided->u.s.pSize.VBO = streamVBO;
|
|
|
|
data += sizeof(FLOAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Diffuse is 4 unsigned bytes */
|
|
|
|
if (thisFVF & D3DFVF_DIFFUSE) {
|
|
|
|
strided->u.s.diffuse.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.diffuse.dwType = WINED3DDECLTYPE_SHORT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.diffuse.dwStride = stride;
|
|
|
|
strided->u.s.diffuse.VBO = streamVBO;
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Specular is 4 unsigned bytes */
|
|
|
|
if (thisFVF & D3DFVF_SPECULAR) {
|
|
|
|
strided->u.s.specular.lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.specular.dwType = WINED3DDECLTYPE_SHORT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.specular.dwStride = stride;
|
|
|
|
strided->u.s.specular.VBO = streamVBO;
|
|
|
|
data += sizeof(DWORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Texture coords */
|
|
|
|
numTextures = (thisFVF & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
|
|
|
coordIdxInfo = (thisFVF & 0x00FF0000) >> 16; /* 16 is from definition of D3DFVF_TEXCOORDSIZE1, and is 8 (0-7 stages) * 2bits long */
|
|
|
|
|
|
|
|
/* numTextures indicates the number of texture coordinates supplied */
|
|
|
|
/* However, the first set may not be for stage 0 texture - it all */
|
2006-10-11 03:52:50 +02:00
|
|
|
/* depends on WINED3DTSS_TEXCOORDINDEX. */
|
2006-06-21 15:01:38 +02:00
|
|
|
/* The number of bytes for each coordinate set is based off */
|
|
|
|
/* D3DFVF_TEXCOORDSIZEn, which are the bottom 2 bits */
|
|
|
|
|
|
|
|
/* So, for each supplied texture extract the coords */
|
|
|
|
for (textureNo = 0; textureNo < numTextures; ++textureNo) {
|
|
|
|
|
|
|
|
strided->u.s.texCoords[textureNo].lpData = data;
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT1;
|
2006-06-21 15:01:38 +02:00
|
|
|
strided->u.s.texCoords[textureNo].dwStride = stride;
|
|
|
|
strided->u.s.texCoords[textureNo].VBO = streamVBO;
|
|
|
|
numCoords[textureNo] = coordIdxInfo & 0x03;
|
|
|
|
|
|
|
|
/* Always one set */
|
|
|
|
data += sizeof(float);
|
|
|
|
if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT1) {
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT2;
|
2006-06-21 15:01:38 +02:00
|
|
|
data += sizeof(float);
|
|
|
|
if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT2) {
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT3;
|
2006-06-21 15:01:38 +02:00
|
|
|
data += sizeof(float);
|
|
|
|
if (numCoords[textureNo] != D3DFVF_TEXTUREFORMAT3) {
|
2006-10-11 03:54:22 +02:00
|
|
|
strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT4;
|
2006-06-21 15:01:38 +02:00
|
|
|
data += sizeof(float);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
coordIdxInfo = coordIdxInfo >> 2; /* Drop bottom two bits */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, LONG BaseVertexIndex, BOOL *fixup) {
|
|
|
|
|
|
|
|
short LoopThroughTo = 0;
|
|
|
|
short nStream;
|
|
|
|
GLint streamVBO = 0;
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
2005-07-13 16:15:54 +02:00
|
|
|
/* OK, Now to setup the data locations
|
|
|
|
For the non-created vertex shaders, the VertexShader var holds the real
|
2004-12-09 12:42:34 +01:00
|
|
|
FVF and only stream 0 matters
|
|
|
|
For the created vertex shaders, there is an FVF per stream */
|
2005-07-06 21:02:38 +02:00
|
|
|
if (!This->stateBlock->streamIsUP && !(This->stateBlock->vertexShader == NULL)) {
|
2004-12-09 12:42:34 +01:00
|
|
|
LoopThroughTo = MAX_STREAMS;
|
|
|
|
} else {
|
|
|
|
LoopThroughTo = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Work through stream by stream */
|
2005-07-30 21:06:14 +02:00
|
|
|
for (nStream=0; nStream<LoopThroughTo; ++nStream) {
|
2005-07-05 16:05:18 +02:00
|
|
|
DWORD stride = This->stateBlock->streamStride[nStream];
|
2004-12-09 12:42:34 +01:00
|
|
|
BYTE *data = NULL;
|
|
|
|
DWORD thisFVF = 0;
|
|
|
|
|
|
|
|
/* Skip empty streams */
|
2005-07-05 16:05:18 +02:00
|
|
|
if (This->stateBlock->streamSource[nStream] == NULL) continue;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Retrieve appropriate FVF */
|
|
|
|
if (LoopThroughTo == 1) { /* Use FVF, not vertex shader */
|
2005-07-06 21:02:38 +02:00
|
|
|
thisFVF = This->stateBlock->fvf;
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Handle memory passed directly as well as vertex buffers */
|
|
|
|
if (This->stateBlock->streamIsUP) {
|
2006-06-21 15:01:38 +02:00
|
|
|
streamVBO = 0;
|
2005-07-05 16:05:18 +02:00
|
|
|
data = (BYTE *)This->stateBlock->streamSource[nStream];
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
2006-06-21 15:01:38 +02:00
|
|
|
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[nStream]);
|
|
|
|
/* GetMemory binds the VBO */
|
|
|
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[nStream], 0, &streamVBO);
|
|
|
|
if(fixup) {
|
|
|
|
if(streamVBO != 0 ) *fixup = TRUE;
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
#if 0 /* TODO: Vertex shader support */
|
|
|
|
thisFVF = This->stateBlock->vertexShaderDecl->fvf[nStream];
|
2005-07-24 19:11:33 +02:00
|
|
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[nStream], 0);
|
2004-12-09 12:42:34 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
VTRACE(("FVF for stream %d is %lx\n", nStream, thisFVF));
|
|
|
|
if (thisFVF == 0) continue;
|
|
|
|
|
|
|
|
/* Now convert the stream into pointers */
|
|
|
|
|
|
|
|
/* Shuffle to the beginning of the vertexes to render and index from there */
|
|
|
|
data = data + (BaseVertexIndex * stride);
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
primitiveConvertFVFtoOffset(thisFVF, stride, data, strided, streamVBO);
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-30 21:06:14 +02:00
|
|
|
#if 0 /* TODO: Software Shaders */
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Draw a single vertex using this information */
|
2005-07-14 14:19:53 +02:00
|
|
|
static void draw_vertex(IWineD3DDevice *iface, /* interface */
|
2004-12-09 12:42:34 +01:00
|
|
|
BOOL isXYZ, float x, float y, float z, float rhw, /* xyzn position*/
|
|
|
|
BOOL isNormal, float nx, float ny, float nz, /* normal */
|
|
|
|
BOOL isDiffuse, float *dRGBA, /* 1st colors */
|
|
|
|
BOOL isSpecular, float *sRGB, /* 2ndry colors */
|
|
|
|
BOOL isPtSize, float ptSize, /* pointSize */
|
2005-03-03 14:57:15 +01:00
|
|
|
WINED3DVECTOR_4 *texcoords, int *numcoords) /* texture info */
|
2004-12-09 12:42:34 +01:00
|
|
|
{
|
|
|
|
unsigned int textureNo;
|
|
|
|
float s, t, r, q;
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
|
|
|
/* Diffuse -------------------------------- */
|
|
|
|
if (isDiffuse) {
|
|
|
|
glColor4fv(dRGBA);
|
|
|
|
VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n", dRGBA[0], dRGBA[1], dRGBA[2], dRGBA[3]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Specular Colour ------------------------------------------*/
|
|
|
|
if (isSpecular) {
|
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
GL_EXTCALL(glSecondaryColor3fvEXT(sRGB));
|
|
|
|
VTRACE(("glSecondaryColor4f: r,g,b=%f,%f,%f\n", sRGB[0], sRGB[1], sRGB[2]));
|
|
|
|
} else {
|
|
|
|
VTRACE(("Specular color extensions not supplied\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Normal -------------------------------- */
|
|
|
|
if (isNormal) {
|
|
|
|
VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", nx,ny,nz));
|
|
|
|
glNormal3f(nx, ny, nz);
|
2005-07-13 16:15:54 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Point Size ----------------------------------------------*/
|
|
|
|
if (isPtSize) {
|
|
|
|
|
|
|
|
/* no such functionality in the fixed function GL pipeline */
|
|
|
|
FIXME("Cannot change ptSize here in openGl\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Texture coords --------------------------- */
|
|
|
|
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
|
|
|
|
|
|
|
|
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
|
|
|
|
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
continue ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query tex coords */
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
|
|
|
|
2006-10-11 03:52:50 +02:00
|
|
|
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
|
2005-07-30 21:06:14 +02:00
|
|
|
if (coordIdx >= MAX_TEXTURES) {
|
2004-12-09 12:42:34 +01:00
|
|
|
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
|
|
|
|
continue;
|
|
|
|
} else if (numcoords[coordIdx] == 0) {
|
|
|
|
TRACE("tex: %d - Skipping tex coords, as no data supplied or no coords supplied\n", textureNo);
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Initialize vars */
|
|
|
|
s = 0.0f;
|
|
|
|
t = 0.0f;
|
|
|
|
r = 0.0f;
|
|
|
|
q = 0.0f;
|
|
|
|
|
|
|
|
switch (numcoords[coordIdx]) {
|
|
|
|
case 4: q = texcoords[coordIdx].w; /* drop through */
|
|
|
|
case 3: r = texcoords[coordIdx].z; /* drop through */
|
|
|
|
case 2: t = texcoords[coordIdx].y; /* drop through */
|
2005-07-13 16:15:54 +02:00
|
|
|
case 1: s = texcoords[coordIdx].x;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (numcoords[coordIdx]) { /* Supply the provided texture coords */
|
|
|
|
case D3DTTFF_COUNT1:
|
|
|
|
VTRACE(("tex:%d, s=%f\n", textureNo, s));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2004-12-14 12:54:27 +01:00
|
|
|
GLMULTITEXCOORD1F(textureNo, s);
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord1f(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT2:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f\n", textureNo, s, t));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2004-12-14 12:54:27 +01:00
|
|
|
GLMULTITEXCOORD2F(textureNo, s, t);
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord2f(s, t);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT3:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2004-12-14 12:54:27 +01:00
|
|
|
GLMULTITEXCOORD3F(textureNo, s, t, r);
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord3f(s, t, r);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT4:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2004-12-14 12:54:27 +01:00
|
|
|
GLMULTITEXCOORD4F(textureNo, s, t, r, q);
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord4f(s, t, r, q);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Should not get here as numCoords should be 0->4 (%x)!\n", numcoords[coordIdx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* End of textures */
|
|
|
|
|
|
|
|
/* Position -------------------------------- */
|
|
|
|
if (isXYZ) {
|
|
|
|
if (1.0f == rhw || rhw < 0.00001f) {
|
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
|
|
|
|
glVertex3f(x, y, z);
|
|
|
|
} else {
|
|
|
|
/* Cannot optimize by dividing through by rhw as rhw is required
|
|
|
|
later for perspective in the GL pipeline for vertex shaders */
|
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw));
|
|
|
|
glVertex4f(x,y,z,rhw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-07-30 21:06:14 +02:00
|
|
|
#endif /* TODO: Software shaders */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-08-03 21:53:16 +02:00
|
|
|
/* This should match any arrays loaded in loadNumberedArrays. */
|
|
|
|
/* TODO: Only load / unload arrays if we have to. */
|
|
|
|
static void unloadNumberedArrays(IWineD3DDevice *iface) {
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
|
|
|
/* disable any attribs (this is the same for both GLSL and ARB modes) */
|
|
|
|
GLint maxAttribs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Leave all the attribs disabled */
|
|
|
|
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs);
|
|
|
|
/* MESA does not support it right not */
|
|
|
|
if (glGetError() != GL_NO_ERROR)
|
|
|
|
maxAttribs = 16;
|
|
|
|
for (i = 0; i < maxAttribs; ++i) {
|
|
|
|
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
|
|
|
|
checkGLcall("glDisableVertexAttribArrayARB(reg);");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Only load / unload arrays if we have to. */
|
2006-07-07 08:27:38 +02:00
|
|
|
static void loadNumberedArrays(
|
|
|
|
IWineD3DDevice *iface,
|
|
|
|
IWineD3DVertexShader *shader,
|
|
|
|
WineDirect3DVertexStridedData *strided) {
|
2006-06-12 08:53:32 +02:00
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2006-09-20 18:36:49 +02:00
|
|
|
GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
|
2006-07-07 08:27:38 +02:00
|
|
|
int i;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
for (i = 0; i < MAX_ATTRIBS; i++) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
if (!strided->u.input[i].lpData && !strided->u.input[i].VBO)
|
|
|
|
continue;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
TRACE_(d3d_shader)("Loading array %u [VBO=%u]\n", i, strided->u.input[i].VBO);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
if(curVBO != strided->u.input[i].VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, strided->u.input[i].VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = strided->u.input[i].VBO;
|
|
|
|
}
|
|
|
|
GL_EXTCALL(glVertexAttribPointerARB(i,
|
|
|
|
WINED3D_ATR_SIZE(strided->u.input[i].dwType),
|
|
|
|
WINED3D_ATR_GLTYPE(strided->u.input[i].dwType),
|
|
|
|
WINED3D_ATR_NORMALIZED(strided->u.input[i].dwType),
|
|
|
|
strided->u.input[i].dwStride,
|
|
|
|
strided->u.input[i].lpData));
|
|
|
|
GL_EXTCALL(glEnableVertexAttribArrayARB(i));
|
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-08-03 21:53:16 +02:00
|
|
|
/* This should match any arrays loaded in loadVertexData. */
|
|
|
|
/* TODO: Only load / unload arrays if we have to. */
|
|
|
|
static void unloadVertexData(IWineD3DDevice *iface) {
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
int texture_idx;
|
|
|
|
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
|
|
|
}
|
|
|
|
for (texture_idx = 0; texture_idx < GL_LIMITS(textures); ++texture_idx) {
|
2006-08-11 01:04:24 +02:00
|
|
|
GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
|
2006-08-03 21:53:16 +02:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Only load / unload arrays if we have to. */
|
2006-05-06 16:58:57 +02:00
|
|
|
static void loadVertexData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd) {
|
2005-08-19 12:05:00 +02:00
|
|
|
unsigned int textureNo = 0;
|
2006-06-27 23:44:26 +02:00
|
|
|
unsigned int texture_idx = 0;
|
2005-08-19 12:05:00 +02:00
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2006-06-21 15:01:38 +02:00
|
|
|
GLint curVBO = -1;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE("Using fast vertex array code\n");
|
|
|
|
/* Blend Data ---------------------------------------------- */
|
2006-06-21 15:01:38 +02:00
|
|
|
if( (sd->u.s.blendWeights.lpData) || (sd->u.s.blendWeights.VBO) ||
|
|
|
|
(sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO) ) {
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
|
2005-07-13 16:15:54 +02:00
|
|
|
if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
#if 1
|
|
|
|
glEnableClientState(GL_WEIGHT_ARRAY_ARB);
|
|
|
|
checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
|
|
|
|
#endif
|
|
|
|
|
2006-10-01 05:20:10 +02:00
|
|
|
TRACE("Blend %d %p %d\n", WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
|
2006-07-07 08:25:14 +02:00
|
|
|
sd->u.s.blendWeights.lpData, sd->u.s.blendWeights.dwStride);
|
2005-08-19 12:05:00 +02:00
|
|
|
/* FIXME("TODO\n");*/
|
2005-07-13 16:15:54 +02:00
|
|
|
/* Note dwType == float3 or float4 == 2 or 3 */
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* with this on, the normals appear to be being modified,
|
|
|
|
but the vertices aren't being translated as they should be
|
|
|
|
Maybe the world matrix aren't being setup properly? */
|
2006-07-07 08:25:14 +02:00
|
|
|
glVertexBlendARB(WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) + 1);
|
2005-08-19 12:05:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
|
2006-07-07 08:25:14 +02:00
|
|
|
WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) ,
|
2005-08-19 12:05:00 +02:00
|
|
|
sd->u.s.blendWeights.dwStride,
|
|
|
|
sd->u.s.blendWeights.lpData));
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.blendWeights.VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.blendWeights.VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.blendWeights.VBO;
|
|
|
|
}
|
|
|
|
|
2006-07-07 08:25:14 +02:00
|
|
|
GL_EXTCALL(glWeightPointerARB)(
|
|
|
|
WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
|
|
|
|
sd->u.s.blendWeights.dwStride,
|
|
|
|
sd->u.s.blendWeights.lpData);
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
checkGLcall("glWeightPointerARB");
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
if((sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO)){
|
2005-08-19 12:05:00 +02:00
|
|
|
static BOOL showfixme = TRUE;
|
|
|
|
if(showfixme){
|
|
|
|
FIXME("blendMatrixIndices support\n");
|
|
|
|
showfixme = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
} else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* FIXME("TODO\n");*/
|
|
|
|
#if 0
|
|
|
|
|
2006-07-07 08:25:14 +02:00
|
|
|
GL_EXTCALL(glVertexWeightPointerEXT)(
|
|
|
|
WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
|
|
|
|
sd->u.s.blendWeights.dwStride,
|
|
|
|
sd->u.s.blendWeights.lpData);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
|
|
|
|
glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
|
|
|
|
checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
|
2005-08-19 12:05:00 +02:00
|
|
|
#endif
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* TODO: support blends in fixupVertices */
|
2004-12-09 12:42:34 +01:00
|
|
|
FIXME("unsupported blending in openGl\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
|
2005-08-19 12:05:00 +02:00
|
|
|
#if 0 /* TODO: Vertex blending */
|
|
|
|
glDisable(GL_VERTEX_BLEND_ARB);
|
|
|
|
#endif
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("ARB_VERTEX_BLEND\n");
|
2004-12-09 12:42:34 +01:00
|
|
|
} else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE(" EXT_VERTEX_WEIGHTING\n");
|
2004-12-09 12:42:34 +01:00
|
|
|
glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
|
|
|
|
checkGLcall("glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* FOG ----------------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.fog.lpData || sd->u.s.fog.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* TODO: fog*/
|
|
|
|
if (GL_SUPPORT(EXT_FOG_COORD) {
|
2006-06-16 00:24:46 +02:00
|
|
|
glEnableClientState(GL_FOG_COORDINATE_EXT);
|
2006-07-07 08:25:14 +02:00
|
|
|
(GL_EXTCALL)(FogCoordPointerEXT)(
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.fog.dwType),
|
|
|
|
sd->u.s.fog.dwStride,
|
|
|
|
sd->u.s.fog.lpData);
|
2005-08-19 12:05:00 +02:00
|
|
|
} else {
|
|
|
|
/* don't bother falling back to 'slow' as we don't support software FOG yet. */
|
|
|
|
/* FIXME: fixme once */
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("Hardware support for FOG is not avaiable, FOG disabled.\n");
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
} else {
|
|
|
|
if (GL_SUPPRT(EXT_FOR_COORD) {
|
|
|
|
/* make sure fog is disabled */
|
2006-06-16 00:24:46 +02:00
|
|
|
glDisableClientState(GL_FOG_COORDINATE_EXT);
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
#endif
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
#if 0 /* tangents ----------------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO ||
|
|
|
|
sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* TODO: tangents*/
|
|
|
|
if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
glEnable(GL_TANGENT_ARRAY_EXT);
|
2006-07-07 08:25:14 +02:00
|
|
|
(GL_EXTCALL)(TangentPointerEXT)(
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.tangent.dwType),
|
|
|
|
sd->u.s.tangent.dwStride,
|
|
|
|
sd->u.s.tangent.lpData);
|
2005-08-19 12:05:00 +02:00
|
|
|
} else {
|
|
|
|
glDisable(GL_TANGENT_ARRAY_EXT);
|
|
|
|
}
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
glEnable(GL_BINORMAL_ARRAY_EXT);
|
2006-07-07 08:25:14 +02:00
|
|
|
(GL_EXTCALL)(BinormalPointerEXT)(
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.binormal.dwType),
|
|
|
|
sd->u.s.binormal.dwStride,
|
|
|
|
sd->u.s.binormal.lpData);
|
2005-08-19 12:05:00 +02:00
|
|
|
} else{
|
|
|
|
glDisable(GL_BINORMAL_ARRAY_EXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* don't bother falling back to 'slow' as we don't support software tangents and binormals yet . */
|
|
|
|
/* FIXME: fixme once */
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("Hardware support for tangents and binormals is not avaiable, tangents and binormals disabled.\n");
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
|
|
|
|
/* make sure fog is disabled */
|
|
|
|
glDisable(GL_TANGENT_ARRAY_EXT);
|
|
|
|
glDisable(GL_BINORMAL_ARRAY_EXT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Point Size ----------------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.pSize.lpData || sd->u.s.pSize.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
/* no such functionality in the fixed function GL pipeline */
|
|
|
|
TRACE("Cannot change ptSize here in openGl\n");
|
|
|
|
/* TODO: Implement this function in using shaders if they are available */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vertex Pointers -----------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.position.lpData != NULL || sd->u.s.position.VBO != 0) {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* Note dwType == float3 or float4 == 2 or 3 */
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n",
|
2005-08-19 12:05:00 +02:00
|
|
|
sd->u.s.position.dwStride,
|
|
|
|
sd->u.s.position.dwType + 1,
|
|
|
|
sd->u.s.position.lpData));
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.position.VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.position.VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.position.VBO;
|
|
|
|
}
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
/* min(WINED3D_ATR_SIZE(position),3) to Disable RHW mode as 'w' coord
|
|
|
|
handling for rhw mode should not impact screen position whereas in GL it does.
|
|
|
|
This may result in very slightly distored textures in rhw mode, but
|
|
|
|
a very minimal different. There's always the other option of
|
2006-06-21 15:01:38 +02:00
|
|
|
fixing the view matrix to prevent w from having any effect
|
|
|
|
|
|
|
|
This only applies to user pointer sources, in VBOs the vertices are fixed up
|
|
|
|
*/
|
|
|
|
if(sd->u.s.position.VBO == 0) {
|
2006-07-07 08:25:14 +02:00
|
|
|
glVertexPointer(3 /* min(WINED3D_ATR_SIZE(sd->u.s.position.dwType),3) */,
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
|
|
|
|
sd->u.s.position.dwStride, sd->u.s.position.lpData);
|
2006-06-21 15:01:38 +02:00
|
|
|
} else {
|
2006-07-07 08:25:14 +02:00
|
|
|
glVertexPointer(
|
|
|
|
WINED3D_ATR_SIZE(sd->u.s.position.dwType),
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
|
|
|
|
sd->u.s.position.dwStride, sd->u.s.position.lpData);
|
2006-06-21 15:01:38 +02:00
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
checkGLcall("glVertexPointer(...)");
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
checkGLcall("glDisableClientState(GL_VERTEX_ARRAY)");
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Normals -------------------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.normal.lpData || sd->u.s.normal.VBO) {
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Note dwType == float3 or float4 == 2 or 3 */
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n",
|
2005-07-13 16:15:54 +02:00
|
|
|
sd->u.s.normal.dwStride,
|
2004-12-09 12:42:34 +01:00
|
|
|
sd->u.s.normal.lpData));
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.normal.VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.normal.VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.normal.VBO;
|
|
|
|
}
|
2006-07-07 08:25:14 +02:00
|
|
|
glNormalPointer(
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.normal.dwType),
|
|
|
|
sd->u.s.normal.dwStride,
|
|
|
|
sd->u.s.normal.lpData);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glNormalPointer(...)");
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)");
|
|
|
|
glNormal3f(0, 0, 1);
|
|
|
|
checkGLcall("glNormal3f(0, 0, 1)");
|
|
|
|
}
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
/* Diffuse Colour --------------------------------------------*/
|
|
|
|
/* WARNING: Data here MUST be in RGBA format, so cannot */
|
|
|
|
/* go directly into fast mode from app pgm, because */
|
|
|
|
/* directx requires data in BGRA format. */
|
|
|
|
/* currently fixupVertices swizels the format, but this isn't */
|
|
|
|
/* very practical when using VBOS */
|
|
|
|
/* NOTE: Unless we write a vertex shader to swizel the colour */
|
|
|
|
/* , or the user doesn't care and wants the speed advantage */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.diffuse.lpData || sd->u.s.diffuse.VBO) {
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Note dwType == float3 or float4 == 2 or 3 */
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
|
2005-07-13 16:15:54 +02:00
|
|
|
sd->u.s.diffuse.dwStride,
|
2004-12-09 12:42:34 +01:00
|
|
|
sd->u.s.diffuse.lpData));
|
2005-08-19 12:05:00 +02:00
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.diffuse.VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.diffuse.VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.diffuse.VBO;
|
|
|
|
}
|
2005-07-13 16:15:54 +02:00
|
|
|
glColorPointer(4, GL_UNSIGNED_BYTE,
|
|
|
|
sd->u.s.diffuse.dwStride,
|
2004-12-09 12:42:34 +01:00
|
|
|
sd->u.s.diffuse.lpData);
|
|
|
|
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
checkGLcall("glDisableClientState(GL_COLOR_ARRAY)");
|
|
|
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
checkGLcall("glColor4f(1, 1, 1, 1)");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Specular Colour ------------------------------------------*/
|
2006-06-21 15:01:38 +02:00
|
|
|
if (sd->u.s.specular.lpData || sd->u.s.specular.VBO) {
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE("setting specular colour\n");
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Note dwType == float3 or float4 == 2 or 3 */
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
|
2005-07-13 16:15:54 +02:00
|
|
|
sd->u.s.specular.dwStride,
|
2004-12-09 12:42:34 +01:00
|
|
|
sd->u.s.specular.lpData));
|
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.specular.VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.specular.VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.specular.VBO;
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE,
|
2005-07-13 16:15:54 +02:00
|
|
|
sd->u.s.specular.dwStride,
|
2004-12-09 12:42:34 +01:00
|
|
|
sd->u.s.specular.lpData);
|
|
|
|
vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
|
|
|
|
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
|
|
|
vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
|
|
|
|
} else {
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
/* Missing specular color is not critical, no warnings */
|
|
|
|
VTRACE(("Specular colour is not supported in this GL implementation\n"));
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
} else {
|
2005-08-19 12:05:00 +02:00
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
|
|
|
|
checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
|
|
|
|
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
|
|
|
|
checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Missing specular color is not critical, no warnings */
|
|
|
|
VTRACE(("Specular colour is not supported in this GL implementation\n"));
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Texture coords -------------------------------------------*/
|
2005-08-19 12:05:00 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
for (textureNo = 0, texture_idx = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
|
2006-05-25 13:54:03 +02:00
|
|
|
/* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
|
|
|
|
/* Abort if we don't support the extension. */
|
|
|
|
if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
|
|
|
|
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
continue;
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
if (!GL_SUPPORT(NV_REGISTER_COMBINERS) || This->stateBlock->textures[textureNo]) {
|
|
|
|
/* Select the correct texture stage */
|
|
|
|
GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
|
|
|
|
}
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
2006-10-11 03:52:50 +02:00
|
|
|
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
if (coordIdx >= MAX_TEXTURES) {
|
2004-12-09 12:42:34 +01:00
|
|
|
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
|
2005-01-17 14:44:57 +01:00
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
} else if (sd->u.s.texCoords[coordIdx].lpData == NULL && sd->u.s.texCoords[coordIdx].VBO == 0) {
|
2004-12-09 12:42:34 +01:00
|
|
|
VTRACE(("Bound texture but no texture coordinates supplied, so skipping\n"));
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
|
2005-01-17 14:44:57 +01:00
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
2006-07-26 08:25:07 +02:00
|
|
|
TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
|
|
|
|
textureNo, texture_idx, coordIdx, sd->u.s.texCoords[coordIdx].lpData);
|
2006-06-21 15:01:38 +02:00
|
|
|
if(curVBO != sd->u.s.texCoords[coordIdx].VBO) {
|
|
|
|
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.texCoords[coordIdx].VBO));
|
|
|
|
checkGLcall("glBindBufferARB");
|
|
|
|
curVBO = sd->u.s.texCoords[coordIdx].VBO;
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
/* The coords to supply depend completely on the fvf / vertex shader */
|
2006-07-07 08:25:14 +02:00
|
|
|
glTexCoordPointer(
|
|
|
|
WINED3D_ATR_SIZE(sd->u.s.texCoords[coordIdx].dwType),
|
|
|
|
WINED3D_ATR_GLTYPE(sd->u.s.texCoords[coordIdx].dwType),
|
|
|
|
sd->u.s.texCoords[coordIdx].dwStride,
|
|
|
|
sd->u.s.texCoords[coordIdx].lpData);
|
2005-07-13 16:15:54 +02:00
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
}
|
2006-06-27 23:44:26 +02:00
|
|
|
} else if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
|
|
|
|
}
|
|
|
|
if (!GL_SUPPORT(NV_REGISTER_COMBINERS) || This->stateBlock->textures[textureNo]) ++texture_idx;
|
|
|
|
}
|
|
|
|
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
for (textureNo = texture_idx; textureNo < GL_LIMITS(textures); ++textureNo) {
|
|
|
|
GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo));
|
2005-07-13 16:15:54 +02:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2006-05-26 15:22:14 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
|
2005-07-13 16:15:54 +02:00
|
|
|
}
|
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
2005-07-13 16:15:54 +02:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum glPrimitiveType,
|
|
|
|
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
if (idxData != NULL /* This crashes sometimes!*/) {
|
2006-10-01 05:20:10 +02:00
|
|
|
TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex);
|
2005-08-19 12:05:00 +02:00
|
|
|
idxData = idxData == (void *)-1 ? NULL : idxData;
|
|
|
|
#if 1
|
|
|
|
#if 0
|
|
|
|
glIndexPointer(idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idxSize, startIdx);
|
|
|
|
glEnableClientState(GL_INDEX_ARRAY);
|
|
|
|
#endif
|
|
|
|
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
|
|
|
|
(const char *)idxData+(idxSize * startIdx));
|
|
|
|
#else /* using drawRangeElements may be faster */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
glDrawRangeElements(glPrimitiveType, minIndex, minIndex + numberOfVertices - 1, numberOfVertices,
|
|
|
|
idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
|
|
|
|
(const char *)idxData+(idxSize * startIdx));
|
2004-12-09 12:42:34 +01:00
|
|
|
#endif
|
|
|
|
checkGLcall("glDrawRangeElements");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Note first is now zero as we shuffled along earlier */
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE("(%p) : glDrawArrays(%x, 0, %d)\n", This, glPrimitiveType, numberOfVertices);
|
|
|
|
glDrawArrays(glPrimitiveType, 0, numberOfVertices);
|
2004-12-09 12:42:34 +01:00
|
|
|
checkGLcall("glDrawArrays");
|
|
|
|
|
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
return;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
2005-07-13 16:15:54 +02:00
|
|
|
/*
|
2004-12-09 12:42:34 +01:00
|
|
|
* Actually draw using the supplied information.
|
|
|
|
* Slower GL version which extracts info about each vertex in turn
|
|
|
|
*/
|
2005-08-19 12:05:00 +02:00
|
|
|
|
2006-05-06 16:58:57 +02:00
|
|
|
static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
|
2005-08-19 12:05:00 +02:00
|
|
|
UINT NumVertexes, GLenum glPrimType,
|
2004-12-09 12:42:34 +01:00
|
|
|
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
|
|
|
|
|
|
|
|
unsigned int textureNo = 0;
|
2006-06-27 23:44:26 +02:00
|
|
|
unsigned int texture_idx = 0;
|
2004-12-09 12:42:34 +01:00
|
|
|
const short *pIdxBufS = NULL;
|
|
|
|
const long *pIdxBufL = NULL;
|
|
|
|
LONG SkipnStrides = 0;
|
|
|
|
LONG vx_index;
|
|
|
|
float x = 0.0f, y = 0.0f, z = 0.0f; /* x,y,z coordinates */
|
|
|
|
float nx = 0.0f, ny = 0.0, nz = 0.0f; /* normal x,y,z coordinates */
|
|
|
|
float rhw = 0.0f; /* rhw */
|
|
|
|
float ptSize = 0.0f; /* Point size */
|
|
|
|
DWORD diffuseColor = 0xFFFFFFFF; /* Diffuse Color */
|
|
|
|
DWORD specularColor = 0; /* Specular Color */
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("Using slow vertex array code\n");
|
|
|
|
|
|
|
|
/* Variable Initialization */
|
|
|
|
if (idxData != NULL) {
|
|
|
|
if (idxSize == 2) pIdxBufS = (const short *) idxData;
|
|
|
|
else pIdxBufL = (const long *) idxData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start drawing in GL */
|
|
|
|
VTRACE(("glBegin(%x)\n", glPrimType));
|
|
|
|
glBegin(glPrimType);
|
|
|
|
|
2006-06-21 15:01:38 +02:00
|
|
|
/* We shouldn't start this function if any VBO is involved. Should I put a safety check here?
|
|
|
|
* Guess it's not necessary(we crash then anyway) and would only eat CPU time
|
|
|
|
*/
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* For each primitive */
|
2005-07-30 21:06:14 +02:00
|
|
|
for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Initialize diffuse color */
|
|
|
|
diffuseColor = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
/* For indexed data, we need to go a few more strides in */
|
|
|
|
if (idxData != NULL) {
|
|
|
|
|
|
|
|
/* Indexed so work out the number of strides to skip */
|
|
|
|
if (idxSize == 2) {
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
|
2005-08-19 12:05:00 +02:00
|
|
|
SkipnStrides = pIdxBufS[startIdx + vx_index];
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
|
2005-08-19 12:05:00 +02:00
|
|
|
SkipnStrides = pIdxBufL[startIdx + vx_index];
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Position Information ------------------ */
|
|
|
|
if (sd->u.s.position.lpData != NULL) {
|
|
|
|
|
|
|
|
float *ptrToCoords = (float *)(sd->u.s.position.lpData + (SkipnStrides * sd->u.s.position.dwStride));
|
|
|
|
x = ptrToCoords[0];
|
|
|
|
y = ptrToCoords[1];
|
|
|
|
z = ptrToCoords[2];
|
|
|
|
rhw = 1.0;
|
|
|
|
VTRACE(("x,y,z=%f,%f,%f\n", x,y,z));
|
|
|
|
|
|
|
|
/* RHW follows, only if transformed, ie 4 floats were provided */
|
2006-07-07 15:15:20 +02:00
|
|
|
if (sd->u.s.position_transformed) {
|
2004-12-09 12:42:34 +01:00
|
|
|
rhw = ptrToCoords[3];
|
|
|
|
VTRACE(("rhw=%f\n", rhw));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Blending data -------------------------- */
|
|
|
|
if (sd->u.s.blendWeights.lpData != NULL) {
|
2005-08-19 12:05:00 +02:00
|
|
|
/* float *ptrToCoords = (float *)(sd->u.s.blendWeights.lpData + (SkipnStrides * sd->u.s.blendWeights.dwStride)); */
|
2004-12-09 12:42:34 +01:00
|
|
|
FIXME("Blending not supported yet\n");
|
|
|
|
|
|
|
|
if (sd->u.s.blendMatrixIndices.lpData != NULL) {
|
|
|
|
/*DWORD *ptrToCoords = (DWORD *)(sd->u.s.blendMatrixIndices.lpData + (SkipnStrides * sd->u.s.blendMatrixIndices.dwStride));*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vertex Normal Data (untransformed only)- */
|
|
|
|
if (sd->u.s.normal.lpData != NULL) {
|
|
|
|
|
|
|
|
float *ptrToCoords = (float *)(sd->u.s.normal.lpData + (SkipnStrides * sd->u.s.normal.dwStride));
|
|
|
|
nx = ptrToCoords[0];
|
|
|
|
ny = ptrToCoords[1];
|
|
|
|
nz = ptrToCoords[2];
|
|
|
|
VTRACE(("nx,ny,nz=%f,%f,%f\n", nx, ny, nz));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Point Size ----------------------------- */
|
|
|
|
if (sd->u.s.pSize.lpData != NULL) {
|
|
|
|
|
|
|
|
float *ptrToCoords = (float *)(sd->u.s.pSize.lpData + (SkipnStrides * sd->u.s.pSize.dwStride));
|
|
|
|
ptSize = ptrToCoords[0];
|
|
|
|
VTRACE(("ptSize=%f\n", ptSize));
|
|
|
|
FIXME("No support for ptSize yet\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Diffuse -------------------------------- */
|
|
|
|
if (sd->u.s.diffuse.lpData != NULL) {
|
|
|
|
|
|
|
|
DWORD *ptrToCoords = (DWORD *)(sd->u.s.diffuse.lpData + (SkipnStrides * sd->u.s.diffuse.dwStride));
|
|
|
|
diffuseColor = ptrToCoords[0];
|
|
|
|
VTRACE(("diffuseColor=%lx\n", diffuseColor));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Specular -------------------------------- */
|
|
|
|
if (sd->u.s.specular.lpData != NULL) {
|
|
|
|
|
|
|
|
DWORD *ptrToCoords = (DWORD *)(sd->u.s.specular.lpData + (SkipnStrides * sd->u.s.specular.dwStride));
|
|
|
|
specularColor = ptrToCoords[0];
|
|
|
|
VTRACE(("specularColor=%lx\n", specularColor));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Texture coords --------------------------- */
|
2006-06-27 23:44:26 +02:00
|
|
|
for (textureNo = 0, texture_idx = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
|
|
|
|
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
continue ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query tex coords */
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
|
|
|
|
2006-10-11 03:52:50 +02:00
|
|
|
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
|
2005-11-07 12:13:26 +01:00
|
|
|
float *ptrToCoords = NULL;
|
2004-12-09 12:42:34 +01:00
|
|
|
float s = 0.0, t = 0.0, r = 0.0, q = 0.0;
|
|
|
|
|
|
|
|
if (coordIdx > 7) {
|
|
|
|
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
|
2006-07-16 22:03:15 +02:00
|
|
|
++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
continue;
|
2005-11-07 12:13:26 +01:00
|
|
|
} else if (coordIdx < 0) {
|
|
|
|
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
|
2006-07-16 22:03:15 +02:00
|
|
|
++texture_idx;
|
2005-11-07 12:13:26 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptrToCoords = (float *)(sd->u.s.texCoords[coordIdx].lpData + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride));
|
|
|
|
if (sd->u.s.texCoords[coordIdx].lpData == NULL) {
|
2004-12-09 12:42:34 +01:00
|
|
|
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
|
2006-07-16 22:03:15 +02:00
|
|
|
++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
|
2006-10-11 03:54:22 +02:00
|
|
|
int coordsToUse = sd->u.s.texCoords[coordIdx].dwType + 1; /* 0 == WINED3DDECLTYPE_FLOAT1 etc */
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* The coords to supply depend completely on the fvf / vertex shader */
|
|
|
|
switch (coordsToUse) {
|
|
|
|
case 4: q = ptrToCoords[3]; /* drop through */
|
|
|
|
case 3: r = ptrToCoords[2]; /* drop through */
|
|
|
|
case 2: t = ptrToCoords[1]; /* drop through */
|
2005-07-13 16:15:54 +02:00
|
|
|
case 1: s = ptrToCoords[0];
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Projected is more 'fun' - Move the last coord to the 'q'
|
2006-10-11 03:52:50 +02:00
|
|
|
parameter (see comments under WINED3DTSS_TEXTURETRANSFORMFLAGS */
|
|
|
|
if ((This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] != D3DTTFF_DISABLE) &&
|
|
|
|
(This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED)) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-10-11 03:52:50 +02:00
|
|
|
if (This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED) {
|
2004-12-09 12:42:34 +01:00
|
|
|
switch (coordsToUse) {
|
|
|
|
case 0: /* Drop Through */
|
|
|
|
case 1:
|
|
|
|
FIXME("D3DTTFF_PROJECTED but only zero or one coordinate?\n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
q = t;
|
|
|
|
t = 0.0;
|
|
|
|
coordsToUse = 4;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
q = r;
|
|
|
|
r = 0.0;
|
|
|
|
coordsToUse = 4;
|
|
|
|
break;
|
|
|
|
case 4: /* Nop here */
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-11 03:52:50 +02:00
|
|
|
FIXME("Unexpected WINED3DTSS_TEXTURETRANSFORMFLAGS value of %d\n",
|
|
|
|
This->stateBlock->textureState[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED);
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (coordsToUse) { /* Supply the provided texture coords */
|
|
|
|
case D3DTTFF_COUNT1:
|
|
|
|
VTRACE(("tex:%d, s=%f\n", textureNo, s));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord1fARB(texture_idx, s));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord1f(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT2:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f\n", textureNo, s, t));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord2fARB(texture_idx, s, t));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord2f(s, t);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT3:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f\n", textureNo, s, t, r));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord3fARB(texture_idx, s, t, r));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord3f(s, t, r);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case D3DTTFF_COUNT4:
|
|
|
|
VTRACE(("tex:%d, s=%f, t=%f, r=%f, q=%f\n", textureNo, s, t, r, q));
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
2006-06-27 23:44:26 +02:00
|
|
|
GL_EXTCALL(glMultiTexCoord4fARB(texture_idx, s, t, r, q));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
glTexCoord4f(s, t, r, q);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Should not get here as coordsToUse is two bits only (%x)!\n", coordsToUse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-27 23:44:26 +02:00
|
|
|
if (!GL_SUPPORT(NV_REGISTER_COMBINERS) || This->stateBlock->textures[textureNo]) ++texture_idx;
|
2004-12-09 12:42:34 +01:00
|
|
|
} /* End of textures */
|
|
|
|
|
|
|
|
/* Diffuse -------------------------------- */
|
|
|
|
if (sd->u.s.diffuse.lpData != NULL) {
|
2005-11-15 13:03:13 +01:00
|
|
|
glColor4ub(D3DCOLOR_B_R(diffuseColor),
|
|
|
|
D3DCOLOR_B_G(diffuseColor),
|
|
|
|
D3DCOLOR_B_B(diffuseColor),
|
|
|
|
D3DCOLOR_B_A(diffuseColor));
|
2006-04-21 10:01:34 +02:00
|
|
|
VTRACE(("glColor4ub: r,g,b,a=%lu,%lu,%lu,%lu\n",
|
2005-11-15 13:03:13 +01:00
|
|
|
D3DCOLOR_B_R(diffuseColor),
|
|
|
|
D3DCOLOR_B_G(diffuseColor),
|
|
|
|
D3DCOLOR_B_B(diffuseColor),
|
|
|
|
D3DCOLOR_B_A(diffuseColor)));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Specular ------------------------------- */
|
2005-11-15 13:03:13 +01:00
|
|
|
if (sd->u.s.specular.lpData != NULL) {
|
2006-06-12 13:25:10 +02:00
|
|
|
/* special case where the fog density is stored in the diffuse alpha channel */
|
|
|
|
if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
|
2006-10-11 03:54:22 +02:00
|
|
|
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == D3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&&
|
2006-06-12 13:25:10 +02:00
|
|
|
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == D3DFOG_NONE) {
|
|
|
|
if(GL_SUPPORT(EXT_FOG_COORD)) {
|
|
|
|
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
|
|
|
|
} else {
|
|
|
|
static BOOL warned = FALSE;
|
|
|
|
if(!warned) {
|
|
|
|
/* TODO: Use the fog table code from old ddraw */
|
|
|
|
FIXME("Implement fog for transformed vertices in software\n");
|
|
|
|
warned = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-21 10:01:34 +02:00
|
|
|
VTRACE(("glSecondaryColor4ub: r,g,b=%lu,%lu,%lu\n",
|
2005-11-15 13:03:13 +01:00
|
|
|
D3DCOLOR_B_R(specularColor),
|
|
|
|
D3DCOLOR_B_G(specularColor),
|
|
|
|
D3DCOLOR_B_B(specularColor)));
|
2004-12-09 12:42:34 +01:00
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
GL_EXTCALL(glSecondaryColor3ubEXT)(
|
2005-11-15 13:03:13 +01:00
|
|
|
D3DCOLOR_B_R(specularColor),
|
|
|
|
D3DCOLOR_B_G(specularColor),
|
|
|
|
D3DCOLOR_B_B(specularColor));
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
2005-07-13 16:15:54 +02:00
|
|
|
/* Do not worry if specular colour missing and disable request */
|
|
|
|
VTRACE(("Specular color extensions not supplied\n"));
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
if (vx_index == 0) {
|
2005-07-13 16:15:54 +02:00
|
|
|
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
|
|
|
|
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
|
|
|
|
} else {
|
|
|
|
/* Do not worry if specular colour missing and disable request */
|
|
|
|
VTRACE(("Specular color extensions not supplied\n"));
|
|
|
|
}
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Normal -------------------------------- */
|
|
|
|
if (sd->u.s.normal.lpData != NULL) {
|
|
|
|
VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", nx,ny,nz));
|
|
|
|
glNormal3f(nx, ny, nz);
|
|
|
|
} else {
|
|
|
|
if (vx_index == 0) glNormal3f(0, 0, 1);
|
|
|
|
}
|
2005-07-13 16:15:54 +02:00
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Position -------------------------------- */
|
|
|
|
if (sd->u.s.position.lpData != NULL) {
|
2006-05-09 18:16:13 +02:00
|
|
|
if (1.0f == rhw || ((rhw < eps) && (rhw > -eps))) {
|
2004-12-09 12:42:34 +01:00
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f\n", x,y,z));
|
|
|
|
glVertex3f(x, y, z);
|
|
|
|
} else {
|
|
|
|
GLfloat w = 1.0 / rhw;
|
|
|
|
VTRACE(("Vertex: glVertex:x,y,z=%f,%f,%f / rhw=%f\n", x,y,z,rhw));
|
|
|
|
glVertex4f(x*w, y*w, z*w, w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For non indexed mode, step onto next parts */
|
|
|
|
if (idxData == NULL) {
|
2005-07-30 21:06:14 +02:00
|
|
|
++SkipnStrides;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
checkGLcall("glEnd and previous calls");
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* TODO: Software/Hardware vertex blending support */
|
2005-07-13 16:15:54 +02:00
|
|
|
/*
|
2004-12-09 12:42:34 +01:00
|
|
|
* Draw with emulated vertex shaders
|
|
|
|
* Note: strided data is uninitialized, as we need to pass the vertex
|
2005-07-13 16:15:54 +02:00
|
|
|
* shader directly as ordering irs yet
|
2004-12-09 12:42:34 +01:00
|
|
|
*/
|
2006-05-06 16:58:57 +02:00
|
|
|
void drawStridedSoftwareVS(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
|
2004-12-09 12:42:34 +01:00
|
|
|
int PrimitiveType, ULONG NumPrimitives,
|
|
|
|
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
|
|
|
|
|
|
|
|
unsigned int textureNo = 0;
|
|
|
|
GLenum glPrimType = GL_POINTS;
|
|
|
|
int NumVertexes = NumPrimitives;
|
|
|
|
const short *pIdxBufS = NULL;
|
|
|
|
const long *pIdxBufL = NULL;
|
|
|
|
LONG SkipnStrides = 0;
|
|
|
|
LONG vx_index;
|
|
|
|
float x = 0.0f, y = 0.0f, z = 0.0f; /* x,y,z coordinates */
|
|
|
|
float rhw = 0.0f; /* rhw */
|
|
|
|
float ptSize = 0.0f; /* Point size */
|
|
|
|
D3DVECTOR_4 texcoords[8]; /* Texture Coords */
|
|
|
|
int numcoords[8]; /* Number of coords */
|
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
IDirect3DVertexShaderImpl* vertexShader = NULL;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
TRACE("Using slow software vertex shader code\n");
|
|
|
|
|
|
|
|
/* Variable Initialization */
|
|
|
|
if (idxData != NULL) {
|
|
|
|
if (idxSize == 2) pIdxBufS = (const short *) idxData;
|
|
|
|
else pIdxBufL = (const long *) idxData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ok, Work out which primitive is requested and how many vertexes that will be */
|
|
|
|
NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
|
|
|
|
|
|
|
|
/* Retrieve the VS information */
|
2005-08-19 12:05:00 +02:00
|
|
|
vertexShader = (IWineD3DVertexShaderImp *)This->stateBlock->VertexShader;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Start drawing in GL */
|
|
|
|
VTRACE(("glBegin(%x)\n", glPrimType));
|
|
|
|
glBegin(glPrimType);
|
|
|
|
|
|
|
|
/* For each primitive */
|
2005-07-30 21:06:14 +02:00
|
|
|
for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* For indexed data, we need to go a few more strides in */
|
|
|
|
if (idxData != NULL) {
|
|
|
|
|
|
|
|
/* Indexed so work out the number of strides to skip */
|
|
|
|
if (idxSize == 2) {
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
|
2004-12-09 12:42:34 +01:00
|
|
|
SkipnStrides = pIdxBufS[startIdx+vx_index];
|
|
|
|
} else {
|
2006-10-01 05:20:10 +02:00
|
|
|
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
|
2004-12-09 12:42:34 +01:00
|
|
|
SkipnStrides = pIdxBufL[startIdx+vx_index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill the vertex shader input */
|
2005-08-19 12:05:00 +02:00
|
|
|
IDirect3DDeviceImpl_FillVertexShaderInputSW(This, vertexShader, SkipnStrides);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Initialize the output fields to the same defaults as it would normally have */
|
2005-08-19 12:05:00 +02:00
|
|
|
memset(&vertexShader->output, 0, sizeof(VSHADEROUTPUTDATA8));
|
|
|
|
vertexShader->output.oD[0].x = 1.0;
|
|
|
|
vertexShader->output.oD[0].y = 1.0;
|
|
|
|
vertexShader->output.oD[0].z = 1.0;
|
|
|
|
vertexShader->output.oD[0].w = 1.0;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Now execute the vertex shader */
|
2005-08-19 12:05:00 +02:00
|
|
|
IDirect3DVertexShaderImpl_ExecuteSW(vertexShader, &vertexShader->input, &vertexShader->output);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/*
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE_VECTOR(vertexShader->output.oPos);
|
|
|
|
TRACE_VECTOR(vertexShader->output.oD[0]);
|
|
|
|
TRACE_VECTOR(vertexShader->output.oD[1]);
|
|
|
|
TRACE_VECTOR(vertexShader->output.oT[0]);
|
|
|
|
TRACE_VECTOR(vertexShader->output.oT[1]);
|
|
|
|
TRACE_VECTOR(vertexShader->input.V[0]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[0]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[1]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[2]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[3]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[4]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[5]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[6]);
|
|
|
|
TRACE_VECTOR(vertexShader->data->C[7]);
|
2004-12-09 12:42:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Extract out the output */
|
2005-08-19 12:05:00 +02:00
|
|
|
/* FIXME: Fog coords? */
|
|
|
|
x = vertexShader->output.oPos.x;
|
|
|
|
y = vertexShader->output.oPos.y;
|
|
|
|
z = vertexShader->output.oPos.z;
|
|
|
|
rhw = vertexShader->output.oPos.w;
|
|
|
|
ptSize = vertexShader->output.oPts.x; /* Fixme - Is this right? */
|
|
|
|
|
|
|
|
/** Update textures coords using vertexShader->output.oT[0->7] */
|
2004-12-09 12:42:34 +01:00
|
|
|
memset(texcoords, 0x00, sizeof(texcoords));
|
|
|
|
memset(numcoords, 0x00, sizeof(numcoords));
|
|
|
|
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
2005-08-19 12:05:00 +02:00
|
|
|
texcoords[textureNo].x = vertexShader->output.oT[textureNo].x;
|
|
|
|
texcoords[textureNo].y = vertexShader->output.oT[textureNo].y;
|
|
|
|
texcoords[textureNo].z = vertexShader->output.oT[textureNo].z;
|
|
|
|
texcoords[textureNo].w = vertexShader->output.oT[textureNo].w;
|
2006-10-11 03:52:50 +02:00
|
|
|
if (This->stateBlock->texture_state[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] != D3DTTFF_DISABLE) {
|
|
|
|
numcoords[textureNo] = This->stateBlock->texture_state[textureNo][WINED3DTSS_TEXTURETRANSFORMFLAGS] & ~D3DTTFF_PROJECTED;
|
2004-12-09 12:42:34 +01:00
|
|
|
} else {
|
|
|
|
switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->stateBlock->textures[textureNo])) {
|
2006-03-09 23:21:16 +01:00
|
|
|
case WINED3DRTYPE_TEXTURE: numcoords[textureNo] = 2; break;
|
|
|
|
case WINED3DRTYPE_VOLUMETEXTURE: numcoords[textureNo] = 3; break;
|
|
|
|
default: numcoords[textureNo] = 4;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2005-07-13 16:15:54 +02:00
|
|
|
numcoords[textureNo] = 0;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw using this information */
|
|
|
|
draw_vertex(iface,
|
2005-07-13 16:15:54 +02:00
|
|
|
TRUE, x, y, z, rhw,
|
|
|
|
TRUE, 0.0f, 0.0f, 1.0f,
|
2005-08-19 12:05:00 +02:00
|
|
|
TRUE, (float*) &vertexShader->output.oD[0],
|
|
|
|
TRUE, (float*) &vertexShader->output.oD[1],
|
2004-12-09 12:42:34 +01:00
|
|
|
FALSE, ptSize, /* FIXME: Change back when supported */
|
|
|
|
texcoords, numcoords);
|
|
|
|
|
|
|
|
/* For non indexed mode, step onto next parts */
|
|
|
|
if (idxData == NULL) {
|
2005-07-30 21:06:14 +02:00
|
|
|
++SkipnStrides;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* for each vertex */
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
checkGLcall("glEnd and previous calls");
|
|
|
|
}
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
#endif
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 00:26:16 +02:00
|
|
|
inline static void drawPrimitiveDrawStrided(
|
2006-07-04 11:08:39 +02:00
|
|
|
IWineD3DDevice *iface,
|
|
|
|
BOOL useVertexShaderFunction,
|
|
|
|
BOOL usePixelShaderFunction,
|
|
|
|
WineDirect3DVertexStridedData *dataLocations,
|
|
|
|
UINT numberOfvertices,
|
|
|
|
UINT numberOfIndicies,
|
|
|
|
GLenum glPrimType,
|
|
|
|
const void *idxData,
|
|
|
|
short idxSize,
|
|
|
|
int minIndex,
|
|
|
|
long StartIdx,
|
|
|
|
BOOL fixup) {
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2006-06-21 15:01:38 +02:00
|
|
|
BOOL useDrawStridedSlow;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
int startStride = idxData == NULL ? 0 :
|
|
|
|
idxData == (void *) -1 ? 0 :
|
|
|
|
(idxSize == 2 ? *(((const short *) idxData) + StartIdx) : *((const int *) idxData) + StartIdx);
|
|
|
|
int endStride = startStride;
|
|
|
|
TRACE("begin Start stride %d, end stride %d, number of indices%d, number of vertices%d\n",
|
|
|
|
startStride, endStride, numberOfIndicies, numberOfvertices);
|
2005-08-19 12:05:00 +02:00
|
|
|
|
|
|
|
/* Generate some fixme's if unsupported functionality is being used */
|
|
|
|
#define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
|
|
|
|
/* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
|
|
|
|
if (!useVertexShaderFunction && (BUFFER_OR_DATA(blendMatrixIndices) || BUFFER_OR_DATA(blendWeights))) {
|
|
|
|
FIXME("Blending data is only valid with vertex shaders %p %p\n",dataLocations->u.s.blendWeights.lpData,dataLocations->u.s.blendWeights.lpData);
|
|
|
|
}
|
|
|
|
if (!useVertexShaderFunction && (BUFFER_OR_DATA(position2) || BUFFER_OR_DATA(normal2))) {
|
|
|
|
FIXME("Tweening is only valid with vertex shaders\n");
|
|
|
|
}
|
|
|
|
if (!useVertexShaderFunction && (BUFFER_OR_DATA(tangent) || BUFFER_OR_DATA(binormal))) {
|
|
|
|
FIXME("Tangent and binormal bump mapping is only valid with vertex shaders\n");
|
|
|
|
}
|
|
|
|
if (!useVertexShaderFunction && (BUFFER_OR_DATA(tessFactor) || BUFFER_OR_DATA(fog) || BUFFER_OR_DATA(depth) || BUFFER_OR_DATA(sample))) {
|
|
|
|
FIXME("Extended attributes are only valid with vertex shaders\n");
|
|
|
|
}
|
|
|
|
#undef BUFFER_OR_DATA
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Fixed pipeline, no fixups required - load arrays */
|
|
|
|
if (!useVertexShaderFunction &&
|
|
|
|
((dataLocations->u.s.pSize.lpData == NULL &&
|
|
|
|
dataLocations->u.s.diffuse.lpData == NULL &&
|
|
|
|
dataLocations->u.s.specular.lpData == NULL) ||
|
|
|
|
fixup) ) {
|
|
|
|
|
|
|
|
/* Load the vertex data using named arrays */
|
|
|
|
TRACE("(%p) Loading vertex data\n", This);
|
|
|
|
loadVertexData(iface, dataLocations);
|
|
|
|
useDrawStridedSlow = FALSE;
|
|
|
|
|
|
|
|
/* Shader pipeline - load attribute arrays */
|
|
|
|
} else if(useVertexShaderFunction) {
|
|
|
|
|
2006-07-07 08:27:38 +02:00
|
|
|
loadNumberedArrays(iface, This->stateBlock->vertexShader, dataLocations);
|
2006-07-04 11:08:39 +02:00
|
|
|
useDrawStridedSlow = FALSE;
|
|
|
|
|
2006-08-05 18:15:35 +02:00
|
|
|
/* We compile the shader here because we need the vertex declaration
|
|
|
|
* in order to determine if we need to do any swizzling for D3DCOLOR
|
|
|
|
* registers. If the shader is already compiled this call will do nothing. */
|
|
|
|
IWineD3DVertexShader_CompileShader(This->stateBlock->vertexShader);
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Draw vertex by vertex */
|
|
|
|
} else {
|
|
|
|
TRACE("Not loading vertex data\n");
|
|
|
|
useDrawStridedSlow = TRUE;
|
|
|
|
}
|
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
|
|
|
|
2006-08-24 23:55:23 +02:00
|
|
|
if(usePixelShaderFunction) {
|
|
|
|
/* We compile the shader here because it depends on the texture stage state
|
|
|
|
* setup of the bound textures. If the shader is already compiled and the texture stage
|
|
|
|
* state setup matches the program this function will do nothing
|
|
|
|
*/
|
|
|
|
IWineD3DPixelShader_CompileShader(This->stateBlock->pixelShader);
|
|
|
|
}
|
2006-07-07 08:17:58 +02:00
|
|
|
/* If GLSL is used for either pixel or vertex shaders, make a GLSL program
|
2006-08-19 17:23:20 +02:00
|
|
|
* Otherwise set NULL, to restore fixed function */
|
2006-10-08 05:25:01 +02:00
|
|
|
if ((This->vs_selected_mode == SHADER_GLSL && useVertexShaderFunction) ||
|
|
|
|
(This->ps_selected_mode == SHADER_GLSL && usePixelShaderFunction))
|
2006-07-07 08:17:58 +02:00
|
|
|
set_glsl_shader_program(iface);
|
|
|
|
else
|
2006-08-19 17:23:20 +02:00
|
|
|
This->stateBlock->glsl_program = NULL;
|
2006-07-07 08:17:58 +02:00
|
|
|
|
|
|
|
/* If GLSL is used now, or might have been used before, (re)set the program */
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->vs_selected_mode == SHADER_GLSL || This->ps_selected_mode == SHADER_GLSL) {
|
2006-07-04 11:08:39 +02:00
|
|
|
|
2006-08-19 17:23:20 +02:00
|
|
|
GLhandleARB progId = This->stateBlock->glsl_program ? This->stateBlock->glsl_program->programId : 0;
|
|
|
|
if (progId)
|
|
|
|
TRACE_(d3d_shader)("Using GLSL program %u\n", progId);
|
|
|
|
GL_EXTCALL(glUseProgramObjectARB(progId));
|
2006-07-04 11:08:39 +02:00
|
|
|
checkGLcall("glUseProgramObjectARB");
|
|
|
|
}
|
2006-06-08 10:00:23 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
if (useVertexShaderFunction) {
|
2006-05-21 23:15:09 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
TRACE("Using vertex shader\n");
|
2006-05-21 23:15:09 +02:00
|
|
|
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->vs_selected_mode == SHADER_ARB) {
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Bind the vertex program */
|
|
|
|
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB,
|
|
|
|
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId));
|
|
|
|
checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);");
|
2006-06-08 10:00:23 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Enable OpenGL vertex programs */
|
|
|
|
glEnable(GL_VERTEX_PROGRAM_ARB);
|
|
|
|
checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);");
|
|
|
|
TRACE_(d3d_shader)("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n",
|
|
|
|
This, ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId);
|
2006-05-21 23:15:09 +02:00
|
|
|
}
|
2006-07-04 11:08:39 +02:00
|
|
|
}
|
2005-08-19 12:05:00 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
if (usePixelShaderFunction) {
|
2006-05-21 23:15:09 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
TRACE("Using pixel shader\n");
|
2006-05-21 23:15:09 +02:00
|
|
|
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->ps_selected_mode == SHADER_ARB) {
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Bind the fragment program */
|
|
|
|
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
|
|
|
|
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId));
|
|
|
|
checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);");
|
2006-06-08 10:00:23 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Enable OpenGL fragment programs */
|
|
|
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
|
|
|
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
|
|
|
|
TRACE_(d3d_shader)("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n",
|
|
|
|
This, ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId);
|
|
|
|
}
|
2006-10-08 05:25:01 +02:00
|
|
|
}
|
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Load any global constants/uniforms that may have been set by the application */
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->vs_selected_mode == SHADER_GLSL || This->ps_selected_mode == SHADER_GLSL)
|
2006-09-27 13:15:58 +02:00
|
|
|
shader_glsl_load_constants(iface, usePixelShaderFunction, useVertexShaderFunction);
|
2006-10-08 05:25:01 +02:00
|
|
|
else if (This->vs_selected_mode == SHADER_ARB || This->ps_selected_mode == SHADER_ARB)
|
2006-09-27 13:15:58 +02:00
|
|
|
shader_arb_load_constants(iface, usePixelShaderFunction, useVertexShaderFunction);
|
2006-06-16 22:07:00 +02:00
|
|
|
|
2006-07-04 11:08:39 +02:00
|
|
|
/* Draw vertex-by-vertex */
|
|
|
|
if (useDrawStridedSlow)
|
|
|
|
drawStridedSlow(iface, dataLocations, numberOfIndicies, glPrimType, idxData, idxSize, minIndex, StartIdx);
|
|
|
|
else
|
|
|
|
drawStridedFast(iface, numberOfIndicies, glPrimType, idxData, idxSize, minIndex, StartIdx);
|
|
|
|
|
|
|
|
/* Cleanup vertex program */
|
|
|
|
if (useVertexShaderFunction) {
|
2006-08-03 21:53:16 +02:00
|
|
|
unloadNumberedArrays(iface);
|
2006-07-04 11:08:39 +02:00
|
|
|
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->vs_selected_mode == SHADER_ARB)
|
2006-07-04 11:08:39 +02:00
|
|
|
glDisable(GL_VERTEX_PROGRAM_ARB);
|
2006-08-03 21:53:16 +02:00
|
|
|
} else {
|
|
|
|
unloadVertexData(iface);
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
2006-07-04 11:08:39 +02:00
|
|
|
|
|
|
|
/* Cleanup fragment program */
|
2006-10-08 05:25:01 +02:00
|
|
|
if (usePixelShaderFunction && This->ps_selected_mode == SHADER_ARB)
|
2006-07-04 11:08:39 +02:00
|
|
|
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
2005-08-19 12:05:00 +02:00
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 15:15:20 +02:00
|
|
|
inline void drawPrimitiveTraceDataLocations(
|
|
|
|
WineDirect3DVertexStridedData *dataLocations) {
|
2005-07-07 22:45:39 +02:00
|
|
|
|
|
|
|
/* Dump out what parts we have supplied */
|
2006-07-07 15:15:20 +02:00
|
|
|
TRACE("Strided Data:\n");
|
2005-07-07 22:45:39 +02:00
|
|
|
TRACE_STRIDED((dataLocations), position);
|
|
|
|
TRACE_STRIDED((dataLocations), blendWeights);
|
|
|
|
TRACE_STRIDED((dataLocations), blendMatrixIndices);
|
|
|
|
TRACE_STRIDED((dataLocations), normal);
|
|
|
|
TRACE_STRIDED((dataLocations), pSize);
|
|
|
|
TRACE_STRIDED((dataLocations), diffuse);
|
|
|
|
TRACE_STRIDED((dataLocations), specular);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[0]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[1]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[2]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[3]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[4]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[5]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[6]);
|
|
|
|
TRACE_STRIDED((dataLocations), texCoords[7]);
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE_STRIDED((dataLocations), position2);
|
|
|
|
TRACE_STRIDED((dataLocations), normal2);
|
|
|
|
TRACE_STRIDED((dataLocations), tangent);
|
|
|
|
TRACE_STRIDED((dataLocations), binormal);
|
|
|
|
TRACE_STRIDED((dataLocations), tessFactor);
|
|
|
|
TRACE_STRIDED((dataLocations), fog);
|
|
|
|
TRACE_STRIDED((dataLocations), depth);
|
|
|
|
TRACE_STRIDED((dataLocations), sample);
|
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-06-27 23:41:27 +02:00
|
|
|
static void drawPrimitiveUploadTexturesPS(IWineD3DDeviceImpl* This) {
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for (i = 0; i < GL_LIMITS(samplers); ++i) {
|
|
|
|
/* Pixel shader support should imply multitexture support. */
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
|
|
|
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
|
|
|
|
checkGLcall("glActiveTextureARB");
|
|
|
|
} else if (i) {
|
|
|
|
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!This->stateBlock->textures[i]) continue;
|
|
|
|
|
|
|
|
/* Enable the correct target. Is this required for GLSL? For ARB_fragment_program it isn't, afaik. */
|
|
|
|
glDisable(GL_TEXTURE_1D);
|
|
|
|
This->stateBlock->textureDimensions[i] = IWineD3DBaseTexture_GetTextureDimensions(This->stateBlock->textures[i]);
|
|
|
|
switch(This->stateBlock->textureDimensions[i]) {
|
|
|
|
case GL_TEXTURE_2D:
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
break;
|
|
|
|
case GL_TEXTURE_3D:
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
break;
|
|
|
|
case GLTEXTURECUBEMAP:
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
glEnable(This->stateBlock->textureDimensions[i]);
|
|
|
|
|
|
|
|
/* Upload texture, apply states */
|
|
|
|
IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) This->stateBlock->textures[i]);
|
2006-06-27 23:44:26 +02:00
|
|
|
IWineD3DDevice_SetupTextureStates((IWineD3DDevice *)This, i, i, REAPPLY_ALPHAOP);
|
2006-06-27 23:41:27 +02:00
|
|
|
IWineD3DBaseTexture_ApplyStateChanges(This->stateBlock->textures[i], This->stateBlock->textureState[i], This->stateBlock->samplerState[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-03 21:49:05 +02:00
|
|
|
/* uploads textures and setup texture states ready for rendering */
|
2006-06-27 23:44:26 +02:00
|
|
|
static void drawPrimitiveUploadTextures(IWineD3DDeviceImpl* This) {
|
|
|
|
INT current_sampler = 0;
|
|
|
|
float constant_color[4];
|
2005-08-01 12:58:31 +02:00
|
|
|
unsigned int i;
|
2005-08-01 11:20:55 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
/* ARB_texture_env_combine is limited to GL_MAX_TEXTURE_UNITS stages. On
|
|
|
|
* nVidia cards GL_MAX_TEXTURE_UNITS is generally not larger than 4.
|
|
|
|
* Register combiners however provide up to 8 combiner stages. In order to
|
|
|
|
* take advantage of this, we need to be separate D3D texture stages from
|
|
|
|
* GL texture units. When using register combiners GL_MAX_TEXTURE_UNITS
|
|
|
|
* corresponds to MaxSimultaneousTextures and GL_MAX_GENERAL_COMBINERS_NV
|
|
|
|
* corresponds to MaxTextureBlendStages in the caps. */
|
|
|
|
|
|
|
|
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
glEnable(GL_REGISTER_COMBINERS_NV);
|
|
|
|
D3DCOLORTOGLFLOAT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], constant_color);
|
|
|
|
GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &constant_color[0]));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < GL_LIMITS(texture_stages); ++i) {
|
|
|
|
INT texture_idx = -1;
|
|
|
|
|
|
|
|
/* D3DTOP_DISABLE disables the current & any higher texture stages */
|
|
|
|
if (This->stateBlock->textureState[i][WINED3DTSS_COLOROP] == D3DTOP_DISABLE) break;
|
|
|
|
|
|
|
|
if (!GL_SUPPORT(NV_REGISTER_COMBINERS) || This->stateBlock->textures[i]) {
|
|
|
|
texture_idx = current_sampler++;
|
|
|
|
|
|
|
|
/* Active the texture unit corresponding to the current texture stage */
|
|
|
|
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
|
|
|
|
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
|
|
|
|
checkGLcall("glActiveTextureARB");
|
|
|
|
} else if (i) {
|
|
|
|
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
|
|
|
|
}
|
|
|
|
}
|
2005-08-01 11:20:55 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
if (This->stateBlock->textures[i]) {
|
|
|
|
/* Enable the correct target. */
|
|
|
|
glDisable(GL_TEXTURE_1D);
|
|
|
|
This->stateBlock->textureDimensions[i] = IWineD3DBaseTexture_GetTextureDimensions(This->stateBlock->textures[i]);
|
|
|
|
switch(This->stateBlock->textureDimensions[i]) {
|
2005-08-01 11:20:55 +02:00
|
|
|
case GL_TEXTURE_2D:
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
2006-06-27 23:44:26 +02:00
|
|
|
break;
|
2005-08-01 11:20:55 +02:00
|
|
|
case GL_TEXTURE_3D:
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
2006-06-27 23:44:26 +02:00
|
|
|
break;
|
2005-08-01 11:20:55 +02:00
|
|
|
case GLTEXTURECUBEMAP:
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
2006-06-27 23:44:26 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-08-03 21:49:05 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
/* imply GL_SUPPORT(NV_TEXTURE_SHADER) when setting texture_shader_active */
|
|
|
|
if (This->texture_shader_active && This->stateBlock->textureDimensions[i] == GL_TEXTURE_2D) {
|
|
|
|
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
|
|
|
|
} else {
|
|
|
|
glEnable(This->stateBlock->textureDimensions[i]);
|
2005-08-01 12:58:31 +02:00
|
|
|
}
|
2005-08-01 11:20:55 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
/* Upload texture, apply states */
|
|
|
|
IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) This->stateBlock->textures[i]);
|
|
|
|
IWineD3DDevice_SetupTextureStates((IWineD3DDevice *)This, i, texture_idx, REAPPLY_ALPHAOP);
|
|
|
|
IWineD3DBaseTexture_ApplyStateChanges(This->stateBlock->textures[i], This->stateBlock->textureState[i], This->stateBlock->samplerState[i]);
|
|
|
|
} else if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
/* ARB_texture_env_combine needs a valid texture bound to the
|
|
|
|
* texture unit, even if it isn't used. Bind a dummy texture. */
|
2005-08-01 11:20:55 +02:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
2006-06-27 23:44:26 +02:00
|
|
|
glEnable(GL_TEXTURE_1D);
|
|
|
|
This->stateBlock->textureDimensions[i] = GL_TEXTURE_1D;
|
|
|
|
glBindTexture(GL_TEXTURE_1D, This->dummyTextureName[i]);
|
|
|
|
}
|
2005-08-01 11:20:55 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
/** these ops apply to the texture unit, so they are preserved between texture changes, but for now brute force and reapply all
|
|
|
|
dx9_1pass_emboss_bump_mapping and dx9_2pass_emboss_bump_mapping are good texts to make sure the states are being applied when needed **/
|
|
|
|
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
set_tex_op_nvrc((IWineD3DDevice *)This, FALSE, i, This->stateBlock->textureState[i][WINED3DTSS_COLOROP],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG1],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG2],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG0],
|
|
|
|
texture_idx);
|
|
|
|
/* alphaop */
|
|
|
|
set_tex_op_nvrc((IWineD3DDevice *)This, TRUE, i, This->stateBlock->textureState[i][WINED3DTSS_ALPHAOP],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG1],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG2],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG0],
|
|
|
|
texture_idx);
|
|
|
|
} else {
|
|
|
|
set_tex_op((IWineD3DDevice *)This, FALSE, i, This->stateBlock->textureState[i][WINED3DTSS_COLOROP],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG1],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG2],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_COLORARG0]);
|
|
|
|
/* alphaop */
|
|
|
|
set_tex_op((IWineD3DDevice *)This, TRUE, i, This->stateBlock->textureState[i][WINED3DTSS_ALPHAOP],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG1],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG2],
|
|
|
|
This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we're using register combiners, set the amount of *used* combiners.
|
|
|
|
* Ie, the number of stages below the first stage to have a color op of
|
|
|
|
* D3DTOP_DISABLE. */
|
|
|
|
if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
|
|
|
|
/* NUM_GENERAL_COMBINERS_NV should be > 0 */
|
|
|
|
if (!i) glDisable(GL_REGISTER_COMBINERS_NV);
|
|
|
|
else GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, i));
|
|
|
|
}
|
2005-08-01 11:20:55 +02:00
|
|
|
|
2006-06-27 23:44:26 +02:00
|
|
|
/* Disable the remaining texture units. */
|
|
|
|
for (i = current_sampler; i < GL_LIMITS(textures); ++i) {
|
|
|
|
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
|
|
|
|
glDisable(GL_TEXTURE_1D);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_TEXTURE_3D);
|
|
|
|
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
}
|
2005-07-21 12:32:48 +02:00
|
|
|
}
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Routine common to the draw primitive and draw indexed primitive routines */
|
|
|
|
void drawPrimitive(IWineD3DDevice *iface,
|
2006-05-06 16:58:57 +02:00
|
|
|
int PrimitiveType,
|
|
|
|
long NumPrimitives,
|
|
|
|
/* for Indexed: */
|
|
|
|
long StartVertexIndex,
|
|
|
|
UINT numberOfVertices,
|
|
|
|
long StartIdx,
|
|
|
|
short idxSize,
|
|
|
|
const void *idxData,
|
|
|
|
int minIndex,
|
|
|
|
WineDirect3DVertexStridedData *DrawPrimStrideData) {
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-01-17 14:44:57 +01:00
|
|
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
2004-12-09 12:42:34 +01:00
|
|
|
BOOL useVertexShaderFunction = FALSE;
|
2006-03-09 00:52:45 +01:00
|
|
|
BOOL usePixelShaderFunction = FALSE;
|
2006-05-06 16:58:57 +02:00
|
|
|
WineDirect3DVertexStridedData *dataLocations;
|
2006-06-04 16:42:57 +02:00
|
|
|
IWineD3DSwapChainImpl *swapchain;
|
2006-07-04 11:08:39 +02:00
|
|
|
int i;
|
2006-06-21 15:01:38 +02:00
|
|
|
BOOL fixup = FALSE;
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-07-07 15:15:20 +02:00
|
|
|
BOOL lighting_changed, lighting_original = FALSE;
|
|
|
|
|
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
|
|
|
/* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
|
|
|
|
* here simply check whether a shader was set, or the user disabled shaders */
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->vs_selected_mode != SHADER_NONE && This->stateBlock->vertexShader &&
|
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
|
|
|
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.function != NULL)
|
2005-10-11 22:27:54 +02:00
|
|
|
useVertexShaderFunction = TRUE;
|
2005-08-19 12:05:00 +02:00
|
|
|
|
2006-10-08 05:25:01 +02:00
|
|
|
if (This->ps_selected_mode != SHADER_NONE && This->stateBlock->pixelShader &&
|
wined3d: Rework shader mode selection.
- currently half the shader selection code (GLSL vs ARB) is in
fillGLcaps. The parts that check for software shaders are in
GetDeviceCaps. That placement, will work, but is definitely not optimal.
FillGLcaps should detect support - it should not make decision as to
what's used, because that's not what the purpose of the function is.
GetDeviceCaps should report support as it has already been selected.
Instead, select shader mode in its own function, called in the
appropriate places.
- unifying pixel and vertex shaders into a single selection is a
mistake. A software vertex shader can be coupled with a hardware arb or
glsl pixel shader, or no shader at all. Split them back into two and add
a SHADER_NONE variant.
- drawprim is doing support checks for ARB_PROGRAM, and making shader
decisions based on that - that's wrong, support has already been
checked, and decided upon, and shaders can be implemented via software,
ARB_PROGRAm or GLSL, so that support check isn't valid.
- Store the shader selected mode into the shader itself. Different types
of shaders can be combined, so this is an improvement. In fact, storing
the mode into the settings globally is a mistake as well - it should be
done per device, since different cards have different capabilities.
2006-07-04 09:21:53 +02:00
|
|
|
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.function)
|
2006-03-09 00:52:45 +01:00
|
|
|
usePixelShaderFunction = TRUE;
|
|
|
|
|
2006-06-04 16:42:57 +02:00
|
|
|
/* Invalidate the back buffer memory so LockRect will read it the next time */
|
|
|
|
for(i = 0; i < IWineD3DDevice_GetNumberOfSwapChains(iface); i++) {
|
|
|
|
IWineD3DDevice_GetSwapChain(iface, i, (IWineD3DSwapChain **) &swapchain);
|
|
|
|
if(swapchain) {
|
2006-06-15 12:54:19 +02:00
|
|
|
if(swapchain->backBuffer) ((IWineD3DSurfaceImpl *) swapchain->backBuffer[0])->Flags |= SFLAG_GLDIRTY;
|
2006-06-04 16:42:57 +02:00
|
|
|
IWineD3DSwapChain_Release( (IWineD3DSwapChain *) swapchain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Ok, we will be updating the screen from here onwards so grab the lock */
|
|
|
|
ENTER_GL();
|
|
|
|
|
2006-05-06 16:58:57 +02:00
|
|
|
if(DrawPrimStrideData) {
|
2006-07-07 08:27:38 +02:00
|
|
|
|
|
|
|
/* Note: this is a ddraw fixed-function code path */
|
|
|
|
|
2006-05-06 16:58:57 +02:00
|
|
|
TRACE("================ Strided Input ===================\n");
|
|
|
|
dataLocations = DrawPrimStrideData;
|
2006-07-07 08:27:38 +02:00
|
|
|
drawPrimitiveTraceDataLocations(dataLocations);
|
2006-06-21 15:01:38 +02:00
|
|
|
fixup = FALSE;
|
2006-05-06 16:58:57 +02:00
|
|
|
}
|
2006-07-07 08:27:38 +02:00
|
|
|
|
2006-07-25 00:50:43 +02:00
|
|
|
else if (This->stateBlock->vertexDecl || This->stateBlock->vertexShader) {
|
2006-07-07 08:27:38 +02:00
|
|
|
|
|
|
|
/* Note: This is a fixed function or shader codepath.
|
|
|
|
* This means it must handle both types of strided data.
|
|
|
|
* Shaders must go through here to zero the strided data, even if they
|
|
|
|
* don't set any declaration at all */
|
2005-12-09 11:23:52 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE("================ Vertex Declaration ===================\n");
|
2006-05-06 16:58:57 +02:00
|
|
|
dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
|
|
|
|
if(!dataLocations) {
|
|
|
|
ERR("Out of memory!\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-07-07 08:27:38 +02:00
|
|
|
|
|
|
|
if (This->stateBlock->vertexDecl != NULL ||
|
|
|
|
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration != NULL)
|
|
|
|
|
|
|
|
primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction,
|
|
|
|
dataLocations, StartVertexIndex, &fixup);
|
2006-06-12 08:51:58 +02:00
|
|
|
|
2005-07-07 22:45:39 +02:00
|
|
|
} else {
|
2006-07-07 08:27:38 +02:00
|
|
|
|
|
|
|
/* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
|
|
|
|
* It is reachable through d3d8, but only for fixed-function.
|
|
|
|
* It will not work properly for shaders. */
|
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
TRACE("================ FVF ===================\n");
|
2006-05-06 16:58:57 +02:00
|
|
|
dataLocations = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dataLocations));
|
|
|
|
if(!dataLocations) {
|
|
|
|
ERR("Out of memory!\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-06-21 15:01:38 +02:00
|
|
|
primitiveConvertToStridedData(iface, dataLocations, StartVertexIndex, &fixup);
|
2006-07-07 08:27:38 +02:00
|
|
|
drawPrimitiveTraceDataLocations(dataLocations);
|
2005-07-07 22:45:39 +02:00
|
|
|
}
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* Setup transform matrices and sort out */
|
2006-07-07 15:15:20 +02:00
|
|
|
primitiveInitState(iface, dataLocations, useVertexShaderFunction, &lighting_changed, &lighting_original);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
|
|
|
/* Now initialize the materials state */
|
2006-06-21 15:01:38 +02:00
|
|
|
init_materials(iface, (dataLocations->u.s.diffuse.lpData != NULL || dataLocations->u.s.diffuse.VBO != 0));
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2006-06-27 23:41:27 +02:00
|
|
|
if (usePixelShaderFunction) {
|
|
|
|
drawPrimitiveUploadTexturesPS(This);
|
|
|
|
} else {
|
|
|
|
drawPrimitiveUploadTextures(This);
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-08-19 12:05:00 +02:00
|
|
|
{
|
|
|
|
GLenum glPrimType;
|
|
|
|
/* Ok, Work out which primitive is requested and how many vertexes that
|
|
|
|
will be */
|
|
|
|
UINT calculatedNumberOfindices = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
|
|
|
|
if (numberOfVertices == 0 )
|
|
|
|
numberOfVertices = calculatedNumberOfindices;
|
2006-07-04 11:08:39 +02:00
|
|
|
|
|
|
|
drawPrimitiveDrawStrided(iface, useVertexShaderFunction, usePixelShaderFunction,
|
|
|
|
dataLocations, numberOfVertices, calculatedNumberOfindices, glPrimType,
|
|
|
|
idxData, idxSize, minIndex, StartIdx, fixup);
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
|
2006-05-06 16:58:57 +02:00
|
|
|
if(!DrawPrimStrideData) HeapFree(GetProcessHeap(), 0, dataLocations);
|
|
|
|
|
2004-12-09 12:42:34 +01:00
|
|
|
/* If vertex shaders or no normals, restore previous lighting state */
|
2006-07-07 15:15:20 +02:00
|
|
|
if (lighting_changed) {
|
|
|
|
if (lighting_original) glEnable(GL_LIGHTING);
|
2004-12-09 12:42:34 +01:00
|
|
|
else glDisable(GL_LIGHTING);
|
|
|
|
TRACE("Restored lighting to original state\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finshed updating the screen, restore lock */
|
|
|
|
LEAVE_GL();
|
|
|
|
TRACE("Done all gl drawing\n");
|
|
|
|
|
|
|
|
/* Diagnostics */
|
2005-09-27 12:49:59 +02:00
|
|
|
#ifdef SHOW_FRAME_MAKEUP
|
2004-12-09 12:42:34 +01:00
|
|
|
{
|
2005-09-27 12:49:59 +02:00
|
|
|
static long int primCounter = 0;
|
|
|
|
/* NOTE: set primCounter to the value reported by drawprim
|
|
|
|
before you want to to write frame makeup to /tmp */
|
|
|
|
if (primCounter >= 0) {
|
2006-04-06 19:36:02 +02:00
|
|
|
WINED3DLOCKED_RECT r;
|
2004-12-09 12:42:34 +01:00
|
|
|
char buffer[80];
|
2006-03-08 00:11:28 +01:00
|
|
|
IWineD3DSurface_LockRect(This->renderTarget, &r, NULL, WINED3DLOCK_READONLY);
|
2006-10-01 05:20:10 +02:00
|
|
|
sprintf(buffer, "/tmp/backbuffer_%d.tga", primCounter);
|
2004-12-09 12:42:34 +01:00
|
|
|
TRACE("Saving screenshot %s\n", buffer);
|
2005-07-30 21:06:14 +02:00
|
|
|
IWineD3DSurface_SaveSnapshot(This->renderTarget, buffer);
|
|
|
|
IWineD3DSurface_UnlockRect(This->renderTarget);
|
2004-12-09 12:42:34 +01:00
|
|
|
|
2005-09-27 12:49:59 +02:00
|
|
|
#ifdef SHOW_TEXTURE_MAKEUP
|
2004-12-09 12:42:34 +01:00
|
|
|
{
|
2005-07-30 21:06:14 +02:00
|
|
|
IWineD3DSurface *pSur;
|
2004-12-09 12:42:34 +01:00
|
|
|
int textureNo;
|
|
|
|
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
|
|
|
|
if (This->stateBlock->textures[textureNo] != NULL) {
|
2006-10-01 05:20:10 +02:00
|
|
|
sprintf(buffer, "/tmp/texture_%p_%d_%d.tga", This->stateBlock->textures[textureNo], primCounter, textureNo);
|
2005-07-30 21:06:14 +02:00
|
|
|
TRACE("Saving texture %s\n", buffer);
|
2006-03-09 23:21:16 +01:00
|
|
|
if (IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]) == WINED3DRTYPE_TEXTURE) {
|
2005-09-27 12:49:59 +02:00
|
|
|
IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture *)This->stateBlock->textures[textureNo], 0, &pSur);
|
|
|
|
IWineD3DSurface_SaveSnapshot(pSur, buffer);
|
|
|
|
IWineD3DSurface_Release(pSur);
|
|
|
|
} else {
|
|
|
|
FIXME("base Texture isn't of type texture %d\n", IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]));
|
|
|
|
}
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2006-10-01 05:20:10 +02:00
|
|
|
TRACE("drawprim #%d\n", primCounter);
|
2005-09-27 12:49:59 +02:00
|
|
|
++primCounter;
|
2004-12-09 12:42:34 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|