Added boxmapped texturing to input mesh, helps visualize it better. Added polymesh generation for layered heighfields.

This commit is contained in:
Mikko Mononen
2011-03-06 15:40:33 +00:00
parent 6cb0413cc7
commit e84d563bfe
16 changed files with 1612 additions and 193 deletions

View File

@@ -139,11 +139,64 @@ const char* BuildContext::getLogText(const int i) const
////////////////////////////////////////////////////////////////////////////////////////////////////
class GLCheckerTexture
{
unsigned int m_texId;
public:
GLCheckerTexture() : m_texId(0)
{
}
~GLCheckerTexture()
{
if (m_texId != 0)
glDeleteTextures(1, &m_texId);
}
void bind()
{
if (m_texId == 0)
{
// Create checker pattern.
const unsigned int col0 = duRGBA(215,215,215,255);
const unsigned int col1 = duRGBA(255,255,255,255);
static const int TSIZE = 32;
unsigned int data[TSIZE*TSIZE];
for (int y = 0; y < TSIZE; ++y)
for (int x = 0; x < TSIZE; ++x)
data[x+y*TSIZE] = (x==0 || y==0) ? col0 : col1;
glGenTextures(1, &m_texId);
glBindTexture(GL_TEXTURE_2D, m_texId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TSIZE,TSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
glBindTexture(GL_TEXTURE_2D, m_texId);
}
}
};
GLCheckerTexture g_tex;
void DebugDrawGL::depthMask(bool state)
{
glDepthMask(state ? GL_TRUE : GL_FALSE);
}
void DebugDrawGL::texture(bool state)
{
if (state)
{
glEnable(GL_TEXTURE_2D);
g_tex.bind();
}
else
{
glDisable(GL_TEXTURE_2D);
}
}
void DebugDrawGL::begin(duDebugDrawPrimitives prim, float size)
{
switch (prim)
@@ -177,6 +230,20 @@ void DebugDrawGL::vertex(const float x, const float y, const float z, unsigned i
glVertex3f(x,y,z);
}
void DebugDrawGL::vertex(const float* pos, unsigned int color, const float* uv)
{
glColor4ubv((GLubyte*)&color);
glTexCoord2fv(uv);
glVertex3fv(pos);
}
void DebugDrawGL::vertex(const float x, const float y, const float z, unsigned int color, const float u, const float v)
{
glColor4ubv((GLubyte*)&color);
glTexCoord2f(u,v);
glVertex3f(x,y,z);
}
void DebugDrawGL::end()
{
glEnd();