Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multitexturing problem (newbie)

I am new to the OpenGL and mobile programming in general.

I am trying to load 2 textures and show them on one object (I mean one set of vercicles) with different coordinates.

My approach:

glGenTextures(2, &textures[0]);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture( GL_TEXTURE0 );
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexCoordPointer(2, GL_SHORT, 0, mapTextCoords);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, map.width, map.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, [map getByteData]);

glActiveTexture(GL_TEXTURE1);
glClientActiveTexture( GL_TEXTURE1 );
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexCoordPointer(2, GL_SHORT, 0, backgroundTextCoords);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, background.width, background.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, [background getByteData]);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, mapVertices);

What am I doing wrong? And what should I do next?

glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glDrawArrays(GL_TRIANGLE_STRIP, 0, BYTES_PER_PIXEL);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);

In result i got white object (no textures at all).

like image 964
Wojtek Avatar asked Sep 01 '26 10:09

Wojtek


1 Answers

Try providing a complete set of mipmaps if you're going to use GL_TEXTURE_MIN_FILTER's default of GL_NEAREST_MIPMAP_LINEAR.

Or set GL_TEXTURE_MIN_FILTER to GL_NEAREST/GL_LINEAR.

like image 182
genpfault Avatar answered Sep 04 '26 13:09

genpfault