drawprim.c revision b955672b950093ff7416d1269dd4d3b69983bd8f
1244N/A * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
251N/A#include "wined3d_private.h"
251N/A switch (PrimitiveType) {
251N/A case WINED3DPT_POINTLIST:
case WINED3DPT_LINELIST:
case WINED3DPT_LINESTRIP:
case WINED3DPT_TRIANGLELIST:
case WINED3DPT_TRIANGLESTRIP:
case WINED3DPT_TRIANGLEFAN:
return NumVertexes;
unsigned int* regnum) {
*regnum = 0;
else if ((usage == WINED3DDECLUSAGE_POSITION || usage == WINED3DDECLUSAGE_POSITIONT) && usage_idx == 1)
return FALSE;
return TRUE;
IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
unsigned int idx;
streamVBO = 0;
TRACE("Stream isn't up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0, &streamVBO);
streamVBO = 0;
data = ((IWineD3DVertexBufferImpl *) This->stateBlock->streamSource[element->Stream])->resource.allocatedMemory;
if(fixup) {
if(!warned) {
TRACE("Offset %d Stream %d UsageIndex %d\n", element->Offset, element->Stream, element->UsageIndex);
if (stride_used) {
for(i=0; i < numPreloadStreams; i++) {
if(vb) {
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT NumVertexes,
GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
unsigned int textureNo = 0;
if (idxSize != 0) {
} else if (idxData) {
if (sd->u.s.position.lpData) position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
else glNormal3f(0, 0, 0);
if (sd->u.s.diffuse.lpData) diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
if (This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR)
if (!warned)
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
else if (coordIdx < 0)
/* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
int coord_idx;
const void *ptr;
if (diffuse) {
if (specular) {
if (specular_fog)
if (position) {
++SkipnStrides;
glEnd();
static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) {
switch(type) {
case WINED3DDECLTYPE_FLOAT1:
case WINED3DDECLTYPE_FLOAT2:
case WINED3DDECLTYPE_FLOAT3:
case WINED3DDECLTYPE_FLOAT4:
case WINED3DDECLTYPE_UBYTE4:
case WINED3DDECLTYPE_UBYTE4N:
case WINED3DDECLTYPE_D3DCOLOR:
case WINED3DDECLTYPE_SHORT2:
case WINED3DDECLTYPE_SHORT4:
case WINED3DDECLTYPE_SHORT2N:
case WINED3DDECLTYPE_USHORT2N:
case WINED3DDECLTYPE_SHORT4N:
case WINED3DDECLTYPE_USHORT4N:
case WINED3DDECLTYPE_UDEC3:
case WINED3DDECLTYPE_DEC3N:
/* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
case WINED3DDECLTYPE_UNUSED:
static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
if (idxSize != 0) {
} else if (idxData) {
SkipnStrides++;
glEnd();
static inline void drawStridedInstanced(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd,
int numInstancedAttribs = 0, j;
if (idxSize == 0) {
/* This is a nasty thing. MSDN says no hardware supports that and apps have to use software vertex processing.
* Shouldn't be too hard to support with opengl, in theory just call glDrawArrays instead of drawElements.
for(i = 0; i < MAX_STREAMS; i++) {
if(((stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INSTANCEDATA) || (stateblock->streamFlags[i] & WINED3DSTREAMSOURCE_INDEXEDDATA)) && stateblock->streamSource[i]) {
/* D3D9 could set streamFreq 0 with (INSTANCEDATA or INDEXEDDATA) and then it is handled as 1. See d3d9/tests/visual.c-> stream_test() */
numInstances = stateblock->streamFreq[i]; /* use the specified number of instances from the first matched stream. See d3d9/tests/visual.c-> stream_test() */
for(i = 0; i < numInstances; i++) {
for(j = 0; j < numInstancedAttribs; j++) {
IWineD3DVertexBufferImpl *vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[sd->u.input[instancedData[j]].streamNo];
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
s->u.s.position.lpData = (BYTE *) ((unsigned long) s->u.s.position.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.blendWeights.lpData = (BYTE *) ((unsigned long) s->u.s.blendWeights.lpData + (unsigned long) vb->resource.allocatedMemory);
vb = (IWineD3DVertexBufferImpl *) This->stateBlock->streamSource[s->u.s.blendMatrixIndices.streamNo];
s->u.s.blendMatrixIndices.lpData = (BYTE *) ((unsigned long) s->u.s.blendMatrixIndices.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.normal.lpData = (BYTE *) ((unsigned long) s->u.s.normal.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.pSize.lpData = (BYTE *) ((unsigned long) s->u.s.pSize.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.diffuse.lpData = (BYTE *) ((unsigned long) s->u.s.diffuse.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.specular.lpData = (BYTE *) ((unsigned long) s->u.s.specular.lpData + (unsigned long) vb->resource.allocatedMemory);
for(i = 0; i < WINED3DDP_MAXTEXCOORD; i++) {
s->u.s.texCoords[i].lpData = (BYTE *) ((unsigned long) s->u.s.texCoords[i].lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.position2.lpData = (BYTE *) ((unsigned long) s->u.s.position2.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.normal2.lpData = (BYTE *) ((unsigned long) s->u.s.normal2.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.tangent.lpData = (BYTE *) ((unsigned long) s->u.s.tangent.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.binormal.lpData = (BYTE *) ((unsigned long) s->u.s.binormal.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.tessFactor.lpData = (BYTE *) ((unsigned long) s->u.s.tessFactor.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.fog.lpData = (BYTE *) ((unsigned long) s->u.s.fog.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.depth.lpData = (BYTE *) ((unsigned long) s->u.s.depth.lpData + (unsigned long) vb->resource.allocatedMemory);
s->u.s.sample.lpData = (BYTE *) ((unsigned long) s->u.s.sample.lpData + (unsigned long) vb->resource.allocatedMemory);
int PrimitiveType,
long NumPrimitives,
long StartVertexIndex,
long StartIdx,
short idxSize,
const void *idxData,
int minIndex) {
if (NumPrimitives == 0) return;
if (target) {
ENTER_GL();
if (numberOfVertices == 0 )
if(!This->strided_streams.u.s.position_transformed && This->activeContext->num_untracked_materials &&
if (!warned) {
if (!warned) {
if(emulation) {
if (!warned) {
LEAVE_GL();
#ifdef SHOW_FRAME_MAKEUP
static long int primCounter = 0;
if (primCounter >= 0) {
#ifdef SHOW_TEXTURE_MAKEUP
int textureNo;
sprintf(buffer, "/tmp/texture_%p_%ld_%d.tga", This->stateBlock->textures[textureNo], primCounter, textureNo);
IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture *)This->stateBlock->textures[textureNo], 0, &pSur);
FIXME("base Texture isn't of type texture %d\n", IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]));
++primCounter;
static void normalize_normal(float *n) {
n[0] = n[0] / length;
ENTER_GL();
LEAVE_GL();
return WINED3DERR_DRIVERINTERNALERROR;
} else if(i != buffer_size) {
LEAVE_GL();
return WINED3DERR_DRIVERINTERNALERROR;
patch->mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num_quads * 6 * d3d_out_vertex_size * sizeof(float) * 8);
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 2 + 4] - 0.5) * 4 * max_z; /* z, triangle 3 */
i += d3d_out_vertex_size;
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 1 + 4] - 0.5) * 4 * max_z; /* z, triangle 2 */
i += d3d_out_vertex_size;
patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 0 + 4] - 0.5) * 4 * max_z; /* z, triangle 1 */
i += d3d_out_vertex_size;
i += d3d_out_vertex_size;
i += d3d_out_vertex_size;
i += d3d_out_vertex_size;
LEAVE_GL();
return WINED3D_OK;