parent
f8ebc6ec21
commit
c9a8a242a0
|
@ -257,7 +257,6 @@ bool CGL14Device::Create()
|
||||||
if (glVersion >= 15)
|
if (glVersion >= 15)
|
||||||
{
|
{
|
||||||
GetLogger()->Info("Core VBO supported\n", glMajor, glMinor);
|
GetLogger()->Info("Core VBO supported\n", glMajor, glMinor);
|
||||||
m_vertexBufferType = VBT_VBO_CORE;
|
|
||||||
|
|
||||||
// Set function pointers
|
// Set function pointers
|
||||||
m_glGenBuffers = glGenBuffers;
|
m_glGenBuffers = glGenBuffers;
|
||||||
|
@ -269,7 +268,6 @@ bool CGL14Device::Create()
|
||||||
else if (vboARB) // VBO ARB extension available
|
else if (vboARB) // VBO ARB extension available
|
||||||
{
|
{
|
||||||
GetLogger()->Info("ARB VBO supported\n");
|
GetLogger()->Info("ARB VBO supported\n");
|
||||||
m_vertexBufferType = VBT_VBO_ARB;
|
|
||||||
|
|
||||||
// Set function pointers
|
// Set function pointers
|
||||||
m_glGenBuffers = glGenBuffersARB;
|
m_glGenBuffers = glGenBuffersARB;
|
||||||
|
@ -280,8 +278,11 @@ bool CGL14Device::Create()
|
||||||
}
|
}
|
||||||
else // no VBO support
|
else // no VBO support
|
||||||
{
|
{
|
||||||
GetLogger()->Info("VBO not supported\n");
|
m_errorMessage = "Your graphics card or drivers don't support OpenGL 1.5 or vertex buffer objects.\n"
|
||||||
m_vertexBufferType = VBT_DISPLAY_LIST;
|
"Ensure you have the latest graphics drivers for your graphics card.\n\n";
|
||||||
|
GetLogger()->Error(m_errorMessage.c_str());
|
||||||
|
m_errorMessage += GetHardwareInfo();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is mostly done in all modern hardware by default
|
// This is mostly done in all modern hardware by default
|
||||||
|
@ -1476,10 +1477,7 @@ void CGL14Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||||
template <typename Vertex>
|
template <typename Vertex>
|
||||||
unsigned int CGL14Device::CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
unsigned int CGL14Device::CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = ++m_lastVboId;
|
||||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
|
||||||
{
|
|
||||||
id = ++m_lastVboId;
|
|
||||||
|
|
||||||
VboObjectInfo info;
|
VboObjectInfo info;
|
||||||
info.primitiveType = primitiveType;
|
info.primitiveType = primitiveType;
|
||||||
|
@ -1493,25 +1491,12 @@ unsigned int CGL14Device::CreateStaticBufferImpl(PrimitiveType primitiveType, co
|
||||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
m_vboObjects[id] = info;
|
m_vboObjects[id] = info;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id = glGenLists(1);
|
|
||||||
|
|
||||||
glNewList(id, GL_COMPILE);
|
|
||||||
|
|
||||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
|
||||||
|
|
||||||
glEndList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Vertex>
|
template <typename Vertex>
|
||||||
void CGL14Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
void CGL14Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
|
||||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1526,19 +1511,8 @@ void CGL14Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType pr
|
||||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
|
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
|
||||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
glNewList(bufferId, GL_COMPILE);
|
|
||||||
|
|
||||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
|
||||||
|
|
||||||
glEndList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGL14Device::DrawStaticBuffer(unsigned int bufferId)
|
void CGL14Device::DrawStaticBuffer(unsigned int bufferId)
|
||||||
{
|
|
||||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1609,15 +1583,8 @@ void CGL14Device::DrawStaticBuffer(unsigned int bufferId)
|
||||||
|
|
||||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
glCallList(bufferId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGL14Device::DestroyStaticBuffer(unsigned int bufferId)
|
void CGL14Device::DestroyStaticBuffer(unsigned int bufferId)
|
||||||
{
|
|
||||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1627,11 +1594,6 @@ void CGL14Device::DestroyStaticBuffer(unsigned int bufferId)
|
||||||
|
|
||||||
m_vboObjects.erase(it);
|
m_vboObjects.erase(it);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
glDeleteLists(bufferId, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Based on libwine's implementation */
|
/* Based on libwine's implementation */
|
||||||
|
|
||||||
|
|
|
@ -43,17 +43,6 @@
|
||||||
namespace Gfx
|
namespace Gfx
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
\enum VertexBufferType
|
|
||||||
\brief Specifies type of vertex buffer to use
|
|
||||||
*/
|
|
||||||
enum VertexBufferType
|
|
||||||
{
|
|
||||||
VBT_DISPLAY_LIST, //! use display lists
|
|
||||||
VBT_VBO_CORE, //! use core OpenGL 1.5 VBOs
|
|
||||||
VBT_VBO_ARB //! use ARB extension VBOs
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ShadowMappingSupport
|
enum ShadowMappingSupport
|
||||||
{
|
{
|
||||||
SMS_NONE, //! No support for depth textures
|
SMS_NONE, //! No support for depth textures
|
||||||
|
@ -295,8 +284,6 @@ private:
|
||||||
bool m_multiDrawArrays = false;
|
bool m_multiDrawArrays = false;
|
||||||
//! Framebuffer support
|
//! Framebuffer support
|
||||||
FramebufferSupport m_framebufferSupport = FBS_NONE;
|
FramebufferSupport m_framebufferSupport = FBS_NONE;
|
||||||
//! Which vertex buffer type to use
|
|
||||||
VertexBufferType m_vertexBufferType = VBT_DISPLAY_LIST;
|
|
||||||
//! Map of saved VBO objects
|
//! Map of saved VBO objects
|
||||||
std::map<unsigned int, VboObjectInfo> m_vboObjects;
|
std::map<unsigned int, VboObjectInfo> m_vboObjects;
|
||||||
//! Last ID of VBO object
|
//! Last ID of VBO object
|
||||||
|
|
Loading…
Reference in New Issue