Commit 8b0a0f4d authored by hybrid's avatar hybrid

Add a general 2d render method. This method accepts vertex and index lists,...

Add a general 2d render method. This method accepts vertex and index lists, and needs textures being set via setMaterial before the call to this method. This method is not implemented in the sw drivers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2586 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 31e1ca74
...@@ -506,13 +506,39 @@ namespace video ...@@ -506,13 +506,39 @@ namespace video
\param primCount Amount of Primitives \param primCount Amount of Primitives
\param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex. \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
\param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan. \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
\param iType Index type, e.g. video::EIT_16BIT for a triangle fan. */ \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primCount, const void* indexList, u32 primCount,
E_VERTEX_TYPE vType=EVT_STANDARD, E_VERTEX_TYPE vType=EVT_STANDARD,
scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
E_INDEX_TYPE iType=EIT_16BIT) =0; E_INDEX_TYPE iType=EIT_16BIT) =0;
//! Draws a vertex primitive list in 2d
/** Compared to the general (3d) version of this method, this
one sets up a 2d render mode, and uses only x and y of vectors.
Note that, depending on the index type, some vertices might be
not accessible through the index list. The limit is at 65535
vertices for 16bit indices. Please note that currently not all
primitives are available for all drivers, and some might be
emulated via triangle renders. This function is not available
for the sw drivers.
\param vertices Pointer to array of vertices.
\param vertexCount Amount of vertices in the array.
\param indexList Pointer to array of indices. These define the
vertices used for each primitive. Depending on the pType,
indices are interpreted as single objects (for point like
primitives), pairs (for lines), triplets (for triangles), or
quads.
\param primCount Amount of Primitives
\param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
\param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
\param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primCount,
E_VERTEX_TYPE vType=EVT_STANDARD,
scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
E_INDEX_TYPE iType=EIT_16BIT) =0;
//! Draws an indexed triangle list. //! Draws an indexed triangle list.
/** Note that there may be at maximum 65536 vertices, because /** Note that there may be at maximum 65536 vertices, because
the index list is an array of 16 bit values each with a maximum the index list is an array of 16 bit values each with a maximum
......
...@@ -850,66 +850,115 @@ void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, ...@@ -850,66 +850,115 @@ void CD3D8Driver::drawVertexPrimitiveList(const void* vertices,
if (!vertexCount || !primitiveCount) if (!vertexCount || !primitiveCount)
return; return;
draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount,
vType, pType, iType, true);
}
//! draws a vertex primitive list in 2d
void CD3D8Driver::draw2DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType)
{
if (!checkPrimitiveCount(primitiveCount))
return;
CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType);
if (!vertexCount || !primitiveCount)
return;
draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount,
vType, pType, iType, false);
}
void CD3D8Driver::draw2D3DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType, bool is3D)
{
setVertexShader(vType); setVertexShader(vType);
const u32 stride = getVertexPitchFromType(vType); const u32 stride = getVertexPitchFromType(vType);
if (setRenderStates3DMode()) D3DFORMAT indexType=D3DFMT_UNKNOWN;
switch (iType)
{ {
switch (pType) case (EIT_16BIT):
{ {
case scene::EPT_POINT_SPRITES: indexType=D3DFMT_INDEX16;
case scene::EPT_POINTS:
{
f32 tmp=Material.Thickness/getScreenSize().Height;
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp));
tmp=1.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp));
tmp=0.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp));
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
}
break;
case scene::EPT_LINE_STRIP:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
break;
case scene::EPT_LINE_LOOP:
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
u16 tmpIndices[] = {0, primitiveCount};
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
1, tmpIndices, D3DFMT_INDEX16, vertices, stride);
}
break;
case scene::EPT_LINES:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
break;
case scene::EPT_TRIANGLE_STRIP:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
break;
case scene::EPT_TRIANGLE_FAN:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount,
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
break; break;
case scene::EPT_TRIANGLES: }
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount, case (EIT_32BIT):
primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride); {
indexType=D3DFMT_INDEX32;
break; break;
} }
} }
if (is3D)
{
if (!setRenderStates3DMode())
return;
}
else
setRenderStates2DMode(true, (Material.getTexture(0) != 0), true);
switch (pType)
{
case scene::EPT_POINT_SPRITES:
case scene::EPT_POINTS:
{
f32 tmp=Material.Thickness/getScreenSize().Height;
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp));
tmp=1.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp));
tmp=0.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp));
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
}
break;
case scene::EPT_LINE_STRIP:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
break;
case scene::EPT_LINE_LOOP:
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
u16 tmpIndices[] = {0, primitiveCount};
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
1, tmpIndices, indexType, vertices, stride);
}
break;
case scene::EPT_LINES:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
break;
case scene::EPT_TRIANGLE_STRIP:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
break;
case scene::EPT_TRIANGLE_FAN:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
break;
case scene::EPT_TRIANGLES:
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
break;
}
} }
......
...@@ -65,9 +65,16 @@ namespace video ...@@ -65,9 +65,16 @@ namespace video
virtual const core::rect<s32>& getViewPort() const; virtual const core::rect<s32>& getViewPort() const;
//! draws a vertex primitive list //! draws a vertex primitive list
void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType);
//! draws a vertex primitive list in 2d
virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
...@@ -258,6 +265,11 @@ namespace video ...@@ -258,6 +265,11 @@ namespace video
void createMaterialRenderers(); void createMaterialRenderers();
void draw2D3DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType, bool is3D);
inline D3DCOLORVALUE colorToD3D(const SColor& col) inline D3DCOLORVALUE colorToD3D(const SColor& col)
{ {
const f32 f = 1.0f / 255.0f; const f32 f = 1.0f / 255.0f;
......
...@@ -31,10 +31,11 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<u32>& screenSize, HWND window, ...@@ -31,10 +31,11 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<u32>& screenSize, HWND window,
StencilBuffer(stencilbuffer), AntiAliasing(0), StencilBuffer(stencilbuffer), AntiAliasing(0),
D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0), D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0),
WindowId(0), SceneSourceRect(0), WindowId(0), SceneSourceRect(0),
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0), LastVertexType((video::E_VERTEX_TYPE)-1), VendorID(0),
MaxLightDistance(0.f), LastSetLight(-1), ColorFormat(ECF_A8R8G8B8), DeviceLost(false), MaxTextureUnits(0), MaxUserClipPlanes(0),
Fullscreen(fullscreen), DriverWasReset(true), AlphaToCoverageSupport(false), MaxLightDistance(0.f), LastSetLight(-1), Cached2DModeSignature(0),
Cached2DModeSignature(0) ColorFormat(ECF_A8R8G8B8), DeviceLost(false),
Fullscreen(fullscreen), DriverWasReset(true), AlphaToCoverageSupport(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D9Driver"); setDebugName("CD3D9Driver");
...@@ -1118,6 +1119,35 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, ...@@ -1118,6 +1119,35 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices,
if (!vertexCount || !primitiveCount) if (!vertexCount || !primitiveCount)
return; return;
draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount,
vType, pType, iType, true);
}
//! draws a vertex primitive list
void CD3D9Driver::draw2DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType)
{
if (!checkPrimitiveCount(primitiveCount))
return;
CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType,iType);
if (!vertexCount || !primitiveCount)
return;
draw2D3DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount,
vType, pType, iType, false);
}
void CD3D9Driver::draw2D3DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType, bool is3D)
{
setVertexShader(vType); setVertexShader(vType);
const u32 stride = getVertexPitchFromType(vType); const u32 stride = getVertexPitchFromType(vType);
...@@ -1137,101 +1167,106 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, ...@@ -1137,101 +1167,106 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices,
} }
} }
if (setRenderStates3DMode()) if (is3D)
{ {
switch (pType) if (!setRenderStates3DMode())
return;
}
else
setRenderStates2DMode(true, (Material.getTexture(0) != 0), true);
switch (pType)
{
case scene::EPT_POINT_SPRITES:
case scene::EPT_POINTS:
{ {
case scene::EPT_POINT_SPRITES: f32 tmp=Material.Thickness/getScreenSize().Height;
case scene::EPT_POINTS: if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp));
tmp=1.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp));
tmp=0.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp));
if (!vertices)
{ {
f32 tmp=Material.Thickness/getScreenSize().Height; pID3DDevice->DrawIndexedPrimitive(D3DPT_POINTLIST, 0, 0, vertexCount, 0, primitiveCount);
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_POINTSIZE, *(DWORD*)(&tmp));
tmp=1.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_A, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_B, *(DWORD*)(&tmp));
pID3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *(DWORD*)(&tmp));
tmp=0.0f;
pID3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *(DWORD*)(&tmp));
if (!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_POINTLIST, 0, 0, vertexCount, 0, primitiveCount);
}
else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
}
pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
if (pType==scene::EPT_POINT_SPRITES)
pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
} }
break; else
case scene::EPT_LINE_STRIP: {
if(!vertices) pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, vertexCount, 0, primitiveCount); primitiveCount, indexList, indexType, vertices, stride);
else }
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride); pID3DDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
break; if (pType==scene::EPT_POINT_SPRITES)
case scene::EPT_LINE_LOOP: pID3DDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
if(!vertices) }
{ break;
// TODO: Implement proper hardware support for this primitive type. case scene::EPT_LINE_STRIP:
// (No looping occurs currently because this would require a way to if(!vertices)
// draw the hardware buffer with a custom set of indices. We may even pID3DDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, vertexCount, 0, primitiveCount);
// need to create a new mini index buffer specifically for this else
// primitive type.) pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount);
}
else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride); primitiveCount, indexList, indexType, vertices, stride);
break;
case scene::EPT_LINE_LOOP:
if(!vertices)
{
// TODO: Implement proper hardware support for this primitive type.
// (No looping occurs currently because this would require a way to
// draw the hardware buffer with a custom set of indices. We may even
// need to create a new mini index buffer specifically for this
// primitive type.)
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount);
}
else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
u16 tmpIndices[] = {0, primitiveCount}; u16 tmpIndices[] = {0, primitiveCount};
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
1, tmpIndices, indexType, vertices, stride); 1, tmpIndices, indexType, vertices, stride);
} }
break; break;
case scene::EPT_LINES: case scene::EPT_LINES:
if(!vertices) if(!vertices)
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount);
else else
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride); primitiveCount, indexList, indexType, vertices, stride);
break; break;
case scene::EPT_TRIANGLE_STRIP: case scene::EPT_TRIANGLE_STRIP:
if(!vertices) if(!vertices)
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, vertexCount, 0, primitiveCount);
else else
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, primitiveCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, primitiveCount,
indexList, indexType, vertices, stride); indexList, indexType, vertices, stride);
break; break;
case scene::EPT_TRIANGLE_FAN: case scene::EPT_TRIANGLE_FAN:
if(!vertices) if(!vertices)
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, vertexCount, 0, primitiveCount);
else else
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, primitiveCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, primitiveCount,
indexList, indexType, vertices, stride); indexList, indexType, vertices, stride);
break;
case scene::EPT_TRIANGLES:
if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, vertexCount, 0, primitiveCount);
}
else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
}
break; break;
} case scene::EPT_TRIANGLES:
if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, vertexCount, 0, primitiveCount);
}
else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride);
}
break;
} }
} }
...@@ -2546,7 +2581,7 @@ bool CD3D9Driver::reset() ...@@ -2546,7 +2581,7 @@ bool CD3D9Driver::reset()
// restore other depth buffers // restore other depth buffers
for (i=1; i<DepthBuffers.size(); ++i) for (i=1; i<DepthBuffers.size(); ++i)
{ {
HRESULT hr=pID3DDevice->CreateDepthStencilSurface(DepthBuffers[i]->Size.Width, pID3DDevice->CreateDepthStencilSurface(DepthBuffers[i]->Size.Width,
DepthBuffers[i]->Size.Height, DepthBuffers[i]->Size.Height,
desc.Format, desc.Format,
desc.MultiSampleType, desc.MultiSampleType,
......
...@@ -112,7 +112,14 @@ namespace video ...@@ -112,7 +112,14 @@ namespace video
//! draws a vertex primitive list //! draws a vertex primitive list
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType);
//! draws a vertex primitive list in 2d
virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType);
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
...@@ -338,6 +345,11 @@ namespace video ...@@ -338,6 +345,11 @@ namespace video
void createMaterialRenderers(); void createMaterialRenderers();
void draw2D3DVertexPrimitiveList(const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType, bool is3D);
inline D3DCOLORVALUE colorToD3D(const SColor& col) inline D3DCOLORVALUE colorToD3D(const SColor& col)
{ {
const f32 f = 1.0f / 255.0f; const f32 f = 1.0f / 255.0f;
......
...@@ -399,7 +399,7 @@ public: ...@@ -399,7 +399,7 @@ public:
}; };
//! material renderer for all kinds of linghtmaps //! material renderer for all kinds of lightmaps
class CD3D9MaterialRenderer_LIGHTMAP : public CD3D9MaterialRenderer class CD3D9MaterialRenderer_LIGHTMAP : public CD3D9MaterialRenderer
{ {
public: public:
......
...@@ -576,6 +576,15 @@ void CNullDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, ...@@ -576,6 +576,15 @@ void CNullDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
} }
//! draws a vertex primitive list in 2d
void CNullDriver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, const void* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType)
{
if ((iType==EIT_16BIT) && (vertexCount>65536))
os::Printer::log("Too many vertices for 16bit index type, render artifacts may occur.");
PrimitivesDrawn += primitiveCount;
}
//! draws an indexed triangle list //! draws an indexed triangle list
void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount) void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount)
{ {
......
...@@ -109,6 +109,11 @@ namespace video ...@@ -109,6 +109,11 @@ namespace video
const void* indexList, u32 primitiveCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! draws a vertex primitive list in 2d
virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! draws an indexed triangle list //! draws an indexed triangle list
virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount); virtual void drawIndexedTriangleList(const S3DVertex* vertices, u32 vertexCount, const u16* indexList, u32 triangleCount);
......
This diff is collapsed.
...@@ -99,6 +99,11 @@ namespace video ...@@ -99,6 +99,11 @@ namespace video
const void* indexList, u32 primitiveCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! draws a vertex primitive list in 2d
virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{ {
...@@ -351,6 +356,13 @@ namespace video ...@@ -351,6 +356,13 @@ namespace video
//! \param[in] lightIndex: the index of the requesting light //! \param[in] lightIndex: the index of the requesting light
void assignHardwareLight(u32 lightIndex); void assignHardwareLight(u32 lightIndex);
//! helper function for render setup.
void createColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType);
//! helper function doing the actual rendering.
void renderArray(const void* indexList, u32 primitiveCount,
scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
core::stringw Name; core::stringw Name;
core::matrix4 Matrices[ETS_COUNT]; core::matrix4 Matrices[ETS_COUNT];
core::array<u8> ColorBuffer; core::array<u8> ColorBuffer;
......
...@@ -527,21 +527,29 @@ public: ...@@ -527,21 +527,29 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{ {
// diffuse map // diffuse map is default modulated
// detail map on second layer
if (Driver->queryFeature(EVDF_MULTITEXTURE)) if (Driver->queryFeature(EVDF_MULTITEXTURE))
{ {
// detail map
Driver->extGlActiveTexture(GL_TEXTURE1_ARB); Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
} }
} }
} }
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
}
}; };
...@@ -607,7 +615,6 @@ public: ...@@ -607,7 +615,6 @@ public:
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
} }
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment