J'ai rajouté le glDepthMask a true, mais toujours le même problème, tout ce que j'affiche après avoir activé le depthtest s'affiche puis disparait.
Voici mes fonction :
////////////////////////////////////////////////////////////
void RenderTarget::resetGLStates()
{
if (activate(true))
{
// Make sure that GLEW is initialized
priv::ensureGlewInit();
// Define the default OpenGL states
glCheck(glDisable(GL_CULL_FACE));
glCheck(glDisable(GL_LIGHTING));
glCheck(glDisable(GL_DEPTH_TEST));
glCheck(glDisable(GL_ALPHA_TEST));
glCheck(glEnable(GL_TEXTURE_2D));
glCheck(glEnable(GL_BLEND));
glCheck(glMatrixMode(GL_MODELVIEW));
glCheck(glEnableClientState(GL_VERTEX_ARRAY));
glCheck(glEnableClientState(GL_COLOR_ARRAY));
glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
glCheck(glEnable(GL_ALPHA_TEST));
glCheck(glAlphaFunc(GL_GREATER, 0));
glCheck(glClearDepth(1));
glCheck(glDepthMask(GL_TRUE));
m_cache.glStatesSet = true;
// Apply the default SFML states
applyBlendMode(BlendAlpha);
applyTransform(Transform::Identity);
applyTexture(NULL);
if (Shader::isAvailable())
applyShader(NULL);
m_cache.useVertexCache = false;
// Set the default view
setView(getView());
}
}
////////////////////////////////////////////////////////////
void RenderTarget::draw(const Vertex* vertices, unsigned int vertexCount,
PrimitiveType type, const RenderStates& states)
{
// Nothing to draw?
if (!vertices || (vertexCount == 0))
return;
if (activate(true))
{
// First set the persistent OpenGL states if it's the very first call
if (!m_cache.glStatesSet)
resetGLStates();
// Check if the vertex count is low enough so that we can pre-transform them
bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
if (useVertexCache)
{
// Pre-transform the vertices and store them into the vertex cache
for (unsigned int i = 0; i < vertexCount; ++i)
{
Vertex& vertex = m_cache.vertexCache[i];
Vector2f v2Pos = states.transform * Vector2f(vertices[i].position.x, vertices[i].position.y);
(vertices[i].position.z < 0) ? glCheck(glDisable(GL_DEPTH_TEST)) : glCheck(glEnable(GL_DEPTH_TEST));
(vertices[i].position.z > 1) ? vertex.position = Vector3f(v2Pos.x, v2Pos.y, 1) : vertex.position = Vector3f(v2Pos.x, v2Pos.y, vertices[i].position.z);
vertex.color = vertices[i].color;
vertex.texCoords = vertices[i].texCoords;
}
// Since vertices are transformed, we must use an identity transform to render them
if (!m_cache.useVertexCache)
applyTransform(Transform::Identity);
}
else
{
applyTransform(states.transform);
}
// Apply the view
if (m_cache.viewChanged)
applyCurrentView();
// Apply the blend mode
if (states.blendMode != m_cache.lastBlendMode)
applyBlendMode(states.blendMode);
// Apply the texture
Uint64 textureId = states.texture ? states.texture->m_cacheId : 0;
if (textureId != m_cache.lastTextureId)
applyTexture(states.texture);
// Apply the shader
if (states.shader)
applyShader(states.shader);
// If we pre-transform the vertices, we must use our internal vertex cache
if (useVertexCache)
{
// ... and if we already used it previously, we don't need to set the pointers again
if (!m_cache.useVertexCache)
vertices = m_cache.vertexCache;
else
vertices = NULL;
}
// Setup the pointers to the vertices' components
if (vertices)
{
const char* data = reinterpret_cast<const char*>(vertices);
glCheck(glVertexPointer(3, GL_FLOAT, sizeof(Vertex), data + 0));
glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 12));
glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 16));
}
// Find the OpenGL primitive type
static const GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES,
GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS};
GLenum mode = modes[type];
// Draw the primitives
glCheck(glDrawArrays(mode, 0, vertexCount));
// Unbind the shader, if any
if (states.shader)
applyShader(NULL);
// Update the cache
m_cache.useVertexCache = useVertexCache;
}
}
////////////////////////////////////////////////////////////
void RenderTarget::clear(const Color& color)
{
if (activate(true))
{
glCheck(glClearColor(color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f));
glCheck(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
}
}
Ai je encore oublié quelque chose ? X_X