Jump to content
  • Advertisement
Sign in to follow this  
xeexIII

OpenGL 3d model gets darker when load a texture--TAKE A TIME AND HELP ME PLEASE, PLESE

This topic is 4057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

PLEASE I AM WORKING ON THIS AND I AM STOCK HERE, PLEASE PLEASE HELP I KNOW YOU KNOW PLEASE HELP. hi, mi problem: when i load a texture(TGA or PCX) everything is ok but the i try to load a 3d model from a obj file this model get darker. when a load a texture to a poligon from a tga the 3d model get darker and when i use pcx the 3d model get completly black. i am not using this texture to the 3d model, there are completly diferent objects ,one is a texture that i load to a polygon(to represent a wall or groung for exmple), the other is a 3d model(that represent a plant for example) i am using: -OpenGL -Allegrogl -Dev-cpp -c++ to load the texture i use: 1.-for tga i use the code from nehe tutorial 2.-for pcx i use this: GLuint LoadTexture(const char *filename) { PALETTE pal; BITMAP *bmp; GLuint textura; bmp = load_bitmap (filename, pal); if (!bmp) { allegro_message ("Error cargando textura "); exit (1); } allegro_gl_begin(); glEnable (GL_TEXTURE_2D); textura = allegro_gl_make_texture (bmp); allegro_gl_end(); destroy_bitmap (bmp); return(textura); } both give me the same problem (3d model get darker) when i load only the 3d model ,this look perfect(color is perfect), the problem is when i load the 3d model and the texture(for the ground or a wall,etc.) i use glut and allegroGl and both give me the same problem PLEASE I AM WORKING ON THIS AND I AM STOCK HERE, PLEASE PLEASE HELP I KNOW YOU KNOW PLEASE HELP.

Share this post


Link to post
Share on other sites
Advertisement
GL is a state machine, state stays set until you change it. You've left textures enabled after loading your texture so it gets applied to the model. Try a glDisable(GL_TEXTURE_2D) if you want your models untextured.

Share this post


Link to post
Share on other sites
also make sure your model has texture coordinates and normals. if there are no texture coordinates, your model will be one solid color. if your model has no normals, it will be pretty dark.

Share this post


Link to post
Share on other sites
firs thanks for take the time and answer me.

the model have normals,also i try
to enable(texture)->load texture->disable(texture)->load 3dmodel
and i try so many diferents things but this does not work,

mayve i do not expres well

the load of the model works perfectly fine alone(perfect colors)
the load of the texture for the ground fine works perfectly fine alone

but when i try both at the same time 3d model get darker(load a tga texture)
and when i load a pcx texture(for the ground) the model get completly black

PLEASE PLEASE HELP.

Share this post


Link to post
Share on other sites
i try
enable(texture)->load texture->disable(texture)->load 3dmodel
but in this way:

funtion display()
{
.
.
.
glEnable (GL_TEXTURE_2D);
pasto();//funtion that load the pcx texture for representing the ground
glDisable (GL_TEXTURE_2D);
load3dmodel();
.
.
.
}

and for my surprise it works.

i use glEnable (GL_TEXTURE_2D); glDisable (GL_TEXTURE_2D); in other part of the code, that why did not work.

THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS

Share this post


Link to post
Share on other sites
You don't need to enable texture when you upload a texture to GL.
Only enable it when you will render a model.

I suggest you read about how GL works. Some fine tutorials here http://nehe.gamedev.net

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!