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

Started by
4 comments, last by V-man 16 years, 11 months ago
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.
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.
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.
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.
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

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
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement