Merge revisions r5419:r5425 from trunk to ogl-es.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5426 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2017-04-15 17:18:44 +00:00
parent 37c8b9d64b
commit 8dfcbde957
10 changed files with 108 additions and 11 deletions

View File

@ -9,6 +9,7 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
--------------------------
Changes in 1.9 (not yet released)
- Add support for different geometric primitivs to meshbuffers. Thanks @gerdb for patch proposal (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=45999)
- change SEvent::SUserEvent.UserData1 and SEvent::SUserEvent.UserData1 from s32 to size_t to avoid cutting numbers on some 64-bit platforms (SDL and Windows)
- Improve speed of draw3DBox (OpenGL and D3D9). Thanks @zerochen for patch (https://sourceforge.net/p/irrlicht/patches/256)
- Support more keys on OSX "[]\". Thanks @neoascetic for patch (#313).

View File

@ -20,6 +20,7 @@ namespace scene
public:
//! constructor
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
: PrimitiveType(EPT_TRIANGLES)
{
VertexBuffer=new CVertexBuffer(vertexType);
IndexBuffer=new CIndexBuffer(indexType);
@ -101,8 +102,22 @@ namespace scene
}
}
//! Describe what kind of primitive geometry is used by the meshbuffer
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
{
PrimitiveType = type;
}
//! Get the kind of primitive geometry which is used by the meshbuffer
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
{
return PrimitiveType;
}
video::SMaterial Material;
core::aabbox3d<f32> BoundingBox;
//! Primitive type used for rendering (triangles, lines, ...)
E_PRIMITIVE_TYPE PrimitiveType;
private:
CDynamicMeshBuffer(const CDynamicMeshBuffer&); // = delete in c++11, prevent copying

View File

@ -18,7 +18,10 @@ namespace scene
{
public:
//! Default constructor for empty meshbuffer
CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER)
CMeshBuffer()
: ChangedID_Vertex(1), ChangedID_Index(1)
, MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER)
, PrimitiveType(EPT_TRIANGLES)
{
#ifdef _DEBUG
setDebugName("CMeshBuffer");
@ -252,6 +255,17 @@ namespace scene
MappingHint_Index=NewMappingHint;
}
//! Describe what kind of primitive geometry is used by the meshbuffer
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
{
PrimitiveType = type;
}
//! Get the kind of primitive geometry which is used by the meshbuffer
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
{
return PrimitiveType;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
@ -285,6 +299,8 @@ namespace scene
core::array<u16> Indices;
//! Bounding box of this meshbuffer.
core::aabbox3d<f32> BoundingBox;
//! Primitive type used for rendering (triangles, lines, ...)
E_PRIMITIVE_TYPE PrimitiveType;
};
//! Standard meshbuffer

View File

@ -144,11 +144,41 @@ namespace scene
//! Get the currently used ID for identification of changes.
/** This shouldn't be used for anything outside the VideoDriver. */
virtual u32 getChangedID_Index() const = 0;
//! Describe what kind of primitive geometry is used by the meshbuffer
/** Note: Default is EPT_TRIANGLES. Using other types is fine for rendering.
But meshbuffer manipulation functions might expect type EPT_TRIANGLES
to work correctly. Also mesh writers will generally fail (badly!) with other
types than EPT_TRIANGLES. */
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) = 0;
//! Get the kind of primitive geometry which is used by the meshbuffer
virtual E_PRIMITIVE_TYPE getPrimitiveType() const = 0;
//! Calculate how many geometric primitives are used by this meshbuffer
virtual u32 getPrimitiveCount() const
{
u32 indexCount = getIndexCount();
switch (getPrimitiveType())
{
case scene::EPT_POINTS: return indexCount;
case scene::EPT_LINE_STRIP: return indexCount-1;
case scene::EPT_LINE_LOOP: return indexCount-1;
case scene::EPT_LINES: return indexCount/2;
case scene::EPT_TRIANGLE_STRIP: return (indexCount-2)/3;
case scene::EPT_TRIANGLE_FAN: return (indexCount-2)/3;
case scene::EPT_TRIANGLES: return indexCount/3;
case scene::EPT_QUAD_STRIP: return (indexCount-2)/4;
case scene::EPT_QUADS: return indexCount/4;
case scene::EPT_POLYGON: return indexCount-1;
case scene::EPT_POINT_SPRITES: return indexCount;
}
return 0;
}
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -16,7 +16,11 @@ namespace scene
struct SSharedMeshBuffer : public IMeshBuffer
{
//! constructor
SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
SSharedMeshBuffer()
: IMeshBuffer()
, Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1)
, MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
, PrimitiveType(EPT_TRIANGLES)
{
#ifdef _DEBUG
setDebugName("SSharedMeshBuffer");
@ -194,6 +198,18 @@ namespace scene
MappingHintIndex=NewMappingHint;
}
//! Describe what kind of primitive geometry is used by the meshbuffer
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
{
PrimitiveType = type;
}
//! Get the kind of primitive geometry which is used by the meshbuffer
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
{
return PrimitiveType;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{
@ -232,6 +248,9 @@ namespace scene
//! hardware mapping hint
E_HARDWARE_MAPPING MappingHintVertex;
E_HARDWARE_MAPPING MappingHintIndex;
//! Primitive type used for rendering (triangles, lines, ...)
E_PRIMITIVE_TYPE PrimitiveType;
};

View File

@ -22,7 +22,8 @@ struct SSkinMeshBuffer : public IMeshBuffer
SSkinMeshBuffer(video::E_VERTEX_TYPE vt=video::EVT_STANDARD) :
ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt),
MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER),
BoundingBoxNeedsRecalculated(true)
BoundingBoxNeedsRecalculated(true),
PrimitiveType(EPT_TRIANGLES)
{
#ifdef _DEBUG
setDebugName("SSkinMeshBuffer");
@ -357,6 +358,18 @@ struct SSkinMeshBuffer : public IMeshBuffer
}
}
//! Describe what kind of primitive geometry is used by the meshbuffer
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)
{
PrimitiveType = type;
}
//! Get the kind of primitive geometry which is used by the meshbuffer
virtual E_PRIMITIVE_TYPE getPrimitiveType() const
{
return PrimitiveType;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
{
@ -389,6 +402,9 @@ struct SSkinMeshBuffer : public IMeshBuffer
core::aabbox3d<f32> BoundingBox;
//! Primitive type used for rendering (triangles, lines, ...)
E_PRIMITIVE_TYPE PrimitiveType;
// hardware mapping hint
E_HARDWARE_MAPPING MappingHint_Vertex:3;
E_HARDWARE_MAPPING MappingHint_Index:3;

View File

@ -1166,7 +1166,7 @@ void CD3D9Driver::drawHardwareBuffer(SHWBufferLink *_HWBuffer)
iPtr=0;
}
drawVertexPrimitiveList(vPtr, mb->getVertexCount(), iPtr, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType());
drawVertexPrimitiveList(vPtr, mb->getVertexCount(), iPtr, mb->getPrimitiveCount(), mb->getVertexType(), mb->getPrimitiveType(), mb->getIndexType());
if (HWBuffer->vertexBuffer)
pID3DDevice->SetStreamSource(0, 0, 0, 0);

View File

@ -48,13 +48,13 @@ namespace irr
virtual bool isWindowActive() const _IRR_OVERRIDE_;
//! returns if window has focus.
bool isWindowFocused() const;
bool isWindowFocused() const _IRR_OVERRIDE_;
//! returns if window is minimized.
bool isWindowMinimized() const;
bool isWindowMinimized() const _IRR_OVERRIDE_;
//! returns color format of the window.
video::ECOLOR_FORMAT getColorFormat() const;
video::ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;
//! presents a surface in the client area
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0) _IRR_OVERRIDE_;

View File

@ -1749,7 +1749,7 @@ void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer* mb)
if (HWBuffer)
drawHardwareBuffer(HWBuffer);
else
drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType());
drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getPrimitiveCount(), mb->getVertexType(), mb->getPrimitiveType(), mb->getIndexType());
}

View File

@ -670,7 +670,7 @@ void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer)
indexList=0;
}
drawVertexPrimitiveList(vertices, mb->getVertexCount(), indexList, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType());
drawVertexPrimitiveList(vertices, mb->getVertexCount(), indexList, mb->getPrimitiveCount(), mb->getVertexType(), mb->getPrimitiveType(), mb->getIndexType());
if (HWBuffer->Mapped_Vertex!=scene::EHM_NEVER)
extGlBindBuffer(GL_ARRAY_BUFFER, 0);