Push de couleur qui marche pas 💢

This commit is contained in:
Claudel-D-Roy 2023-11-20 15:02:02 -05:00
parent 85b8f4b94b
commit 02fafea45c
4 changed files with 20 additions and 3 deletions

View File

@ -1181,8 +1181,10 @@ void Engine::Render(float elapsedTime) {
//m_remotePlayer.ApplyTransformation(remotePlayer, false);
m_world.Update(m_bullets, m_player.GetPosition(), m_blockinfo);
m_renderer.UpdateMesh(&m_world, m_player.GetPosition(), m_blockinfo);
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_remotePlayer.Render(m_animeAtlas, m_shader01, all, elapsedTime);
if (m_isSkybox) m_renderer.RenderWorld(&m_world, m_renderCount, m_player.GetPosition(), m_player.GetDirection(), all, m_shader01, m_textureAtlas);

View File

@ -7,7 +7,7 @@ void main()
texel = texture2D(tex,gl_TexCoord[0].st);
texel *= light;
texel.a = 255.;
gl_FragColor = texel;
}

View File

@ -105,6 +105,10 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
atlas.TextureIndexToCoord(0, u, v, w, h);
//glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glLoadMatrixf(tran.GetMatrix().GetInternalValues());
glBegin(GL_QUADS);
glTexCoord2f(u, v); glVertex3f(x - width/2., y - height, z); //glVertex3f(v4.x, v4.y, v4.z);//glVertex3f(0, 50, 0);
@ -112,6 +116,12 @@ void RemotePlayer::Render(TextureAtlas& atlas, Shader& shader, Transformation tr
glTexCoord2f(u + w, v + h); glVertex3f(x+width/2., y, z); //glVertex3f(v2.x, v2.y, v2.z); //glVertex3f(50, 0, 0);
glTexCoord2f(u, v + h); glVertex3f(x-width/2., y, z); //glVertex3f(v1.x, v1.y, v1.z);// glVertex3f(0, 0, 0);
glEnd();
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendEquation(GL_FUNC_SUBTRACT);
glDisable(GL_BLEND);
shader.Disable();
//tran.ApplyTranslation(-m_position);
//glEnable(GL_DEPTH_TEST);

View File

@ -40,6 +40,9 @@ TextureAtlas::TextureIndex TextureAtlas::AddTexture(const std::string& fname) {
}
bool TextureAtlas::Generate(int textureSize, bool mipmap) {
// TODO mipmap pas encore 100% parfait...
assert(!mipmap);
@ -66,9 +69,9 @@ bool TextureAtlas::Generate(int textureSize, bool mipmap) {
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
ilEnable(IL_ORIGIN_SET);
ilEnable(IL_ALPHA);
if (!ilLoadImage((const ILstring)it->first.c_str()))
if (!ilLoad(IL_PNG,(const ILstring)it->first.c_str()))
return false;
if (!ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE))
@ -171,8 +174,10 @@ bool TextureAtlas::Generate(int textureSize, bool mipmap) {
mipmapSize /= 2;
}
m_isValid = true;
return true;
}