PDA

View Full Version : generate solit texture



3DPrgmer
10-17-2016, 07:21 AM
Hi,

i need your help again.
I read in a file that contains all information (.msh) But maybe my 3D object does not have UVs or an texture file. In that case i thought, i put for all vertex the UV to 1,0 and use a solid (red) texture.


// if texture && open ok, then
TextureTGA tempTex(TEXTURE_NAME);
glTexImage2D(GL_TEXTURE_2D, 0, tempTex.hasAlpha() ? GL_RGBA : GL_RGB, tempTex.getWidth(), tempTex.getHeight(), 0, tempTex.hasAlpha() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, tempTex.getData().data());
// else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1,0, GL_RGB, GL_UNSIGNED_BYTE, {Red color});


how would i tell the last glTexImage2D to use just red Color instead of a texture data?? I want to avoid to change the code at many parts (to use different shaders, init other variables,...) and i think this is the best way.
Or do you have a different idea??

GClements
10-17-2016, 07:37 AM
how would i tell the last glTexImage2D to use just red Color instead of a texture data??




GLubyte red[4] = {255,0,0,255};

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*) red);

3DPrgmer
10-17-2016, 08:45 AM
works, thank you very much ;)