void Screen3D:: DrawAllAlpha() { AlphaRendering = false; SetRenderState(D3DRS_ZWRITEENABLE, FALSE); //SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); //SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); std::list<RenderBlock>::iterator i; while(DrawList.size()) { i = DrawList.begin(); RenderBlock r = (*i); D3DDevice->SetTransform( D3DTS_WORLDMATRIX(0), &r.m); DrawPrimitiveVB((*i).VB, (*i).IB); DrawList.erase(i); } SetRenderState(D3DRS_ZWRITEENABLE, TRUE); }
static HRESULT STDMETHODCALLTYPE MyDrawPrimitiveVB(IDirect3DDeviceN* pThis, D3DPRIMITIVETYPE a, LPDIRECT3DVERTEXBUFFERN b, DWORD c, DWORD d, DWORD e) { d3ddebugprintf(__FUNCTION__ "(0x%X) called.\n", pThis); if(ShouldSkipDrawing(false, true)) return D3D_OK; HRESULT rv = DrawPrimitiveVB(pThis, a, b, c, d, e); return rv; }
static GLboolean _gld_mesa_render_stage_run( GLcontext *ctx, struct tnl_pipeline_stage *stage) { GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; tnl_render_func *tab; GLint pass = 0; GLD_pb_dx7 *gldPB; DWORD dwFlags; /* Allow the drivers to lock before projected verts are built so * that window coordinates are guarenteed not to change before * rendering. */ ASSERT(tnl->Driver.Render.Start); tnl->Driver.Render.Start( ctx ); gldPB = &gld->PB2d; tnl->Driver.Render.Points = _gldSetupPoints[gld->iSetupFunc]; tnl->Driver.Render.Line = _gldSetupLine[gld->iSetupFunc]; tnl->Driver.Render.Triangle = _gldSetupTriangle[gld->iSetupFunc]; tnl->Driver.Render.Quad = _gldSetupQuad[gld->iSetupFunc]; dwFlags = DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY; _GLD_DX7_VB(Lock(gldPB->pVB, dwFlags, &gldPB->pPoints, NULL)); gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0; // Allocate primitive pointers - gldPB->pPoints is always first gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine); gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle); ASSERT(tnl->Driver.Render.BuildVertices); ASSERT(tnl->Driver.Render.PrimitiveNotify); ASSERT(tnl->Driver.Render.Points); ASSERT(tnl->Driver.Render.Line); ASSERT(tnl->Driver.Render.Triangle); ASSERT(tnl->Driver.Render.Quad); ASSERT(tnl->Driver.Render.ResetLineStipple); ASSERT(tnl->Driver.Render.Interp); ASSERT(tnl->Driver.Render.CopyPV); ASSERT(tnl->Driver.Render.ClippedLine); ASSERT(tnl->Driver.Render.ClippedPolygon); ASSERT(tnl->Driver.Render.Finish); tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 ); if (VB->ClipOrMask) { tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts; clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles; } else { tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts); } do { GLuint i, length, flags = 0; for (i = 0 ; !(flags & PRIM_END) ; i += length) { flags = VB->Primitive[i].mode; length= VB->Primitive[i].count; ASSERT(length || (flags & PRIM_END)); ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1); if (length) tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); } } while (tnl->Driver.Render.Multipass && tnl->Driver.Render.Multipass( ctx, ++pass )); // tnl->Driver.Render.Finish( ctx ); _GLD_DX7_VB(Unlock(gldPB->pVB)); if (gldPB->nPoints) { _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_POINTLIST, gldPB->pVB, 0, gldPB->nPoints, 0)); gldPB->nPoints = 0; } if (gldPB->nLines) { _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_LINELIST, gldPB->pVB, gldPB->iFirstLine, gldPB->nLines*2, 0)); gldPB->nLines = 0; } if (gldPB->nTriangles) { _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_TRIANGLELIST, gldPB->pVB, gldPB->iFirstTriangle, gldPB->nTriangles*3, 0)); gldPB->nTriangles = 0; } return GL_FALSE; /* finished the pipe */ }
static GLboolean gld_d3d_render_stage_run( GLcontext *ctx, struct tnl_pipeline_stage *stage) { GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); TNLcontext *tnl; struct vertex_buffer *VB; tnl_render_func *tab; GLint pass; GLD_pb_dx7 *gldPB = &gld->PB3d; DWORD dwFlags; /* static int count = 0; count++; if (count != 2) return GL_FALSE; */ // The "check" function should disable this stage, // but we'll test gld->bUseMesaTnL anyway. if (gld->bUseMesaTnL) { // Do nothing in this stage, but continue pipeline return GL_TRUE; } tnl = TNL_CONTEXT(ctx); VB = &tnl->vb; pass = 0; tnl->Driver.Render.Start( ctx ); #if 0 // For debugging: Useful to see if an app passes colour data in // an unusual format. switch (VB->AttribPtr[_TNL_ATTRIB_COLOR0]->Type) { case GL_FLOAT: ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n"); break; case GL_UNSIGNED_BYTE: ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_UNSIGNED_BYTE\n"); break; default: ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: *?*\n"); break; } #endif tnl->Driver.Render.Points = gld_Points3D_DX7; if (ctx->_TriangleCaps & DD_FLATSHADE) { tnl->Driver.Render.Line = gld_Line3DFlat_DX7; tnl->Driver.Render.Triangle = gld_Triangle3DFlat_DX7; tnl->Driver.Render.Quad = gld_Quad3DFlat_DX7; } else { tnl->Driver.Render.Line = gld_Line3DSmooth_DX7; tnl->Driver.Render.Triangle = gld_Triangle3DSmooth_DX7; tnl->Driver.Render.Quad = gld_Quad3DSmooth_DX7; } // _GLD_DX7_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD)); dwFlags = DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY; _GLD_DX7_VB(Lock(gldPB->pVB, dwFlags, &gldPB->pPoints, NULL)); gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0; // Allocate primitive pointers // gldPB->pPoints is always first gldPB->pLines = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine); gldPB->pTriangles = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle); ASSERT(tnl->Driver.Render.BuildVertices); ASSERT(tnl->Driver.Render.PrimitiveNotify); ASSERT(tnl->Driver.Render.Points); ASSERT(tnl->Driver.Render.Line); ASSERT(tnl->Driver.Render.Triangle); ASSERT(tnl->Driver.Render.Quad); ASSERT(tnl->Driver.Render.ResetLineStipple); ASSERT(tnl->Driver.Render.Interp); ASSERT(tnl->Driver.Render.CopyPV); ASSERT(tnl->Driver.Render.ClippedLine); ASSERT(tnl->Driver.Render.ClippedPolygon); ASSERT(tnl->Driver.Render.Finish); tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts); do { GLuint i, length, flags = 0; for (i = 0 ; !(flags & PRIM_END) ; i += length) { flags = VB->Primitive[i].mode; length= VB->Primitive[i].count; ASSERT(length || (flags & PRIM_END)); ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1); if (length) tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); } } while (tnl->Driver.Render.Multipass && tnl->Driver.Render.Multipass( ctx, ++pass )); _GLD_DX7_VB(Unlock(gldPB->pVB)); // _GLD_DX7_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, gldPB->dwStride)); _GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_PROJECTION, &gld->matProjection)); _GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_WORLD, &gld->matModelView)); if (gldPB->nPoints) { // _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints)); _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_POINTLIST, gldPB->pVB, 0, gldPB->nPoints, 0)); gldPB->nPoints = 0; } if (gldPB->nLines) { // _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines)); _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_LINELIST, gldPB->pVB, gldPB->iFirstLine, gldPB->nLines, 0)); gldPB->nLines = 0; } if (gldPB->nTriangles) { // _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles)); _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_TRIANGLELIST, gldPB->pVB, gldPB->iFirstTriangle, gldPB->nTriangles, 0)); gldPB->nTriangles = 0; } return GL_FALSE; /* finished the pipe */ }