[OpenGL] 2 Texturen - 1 wird angezeigt
-
Hi,
mit folgendem Code lade ich, so dachte ich zumindest, 2 Texturen aus 2 verschiedenen Dateien:void InitOpenGL() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glEnable(GL_TEXTURE_2D); normaldata = LoadBMP("normal.bmp", &bitmapinfoheader_normal); if ( !normaldata ) { MessageBox(0, "...but couldn't load normal.bmp!", "Sorry...", 0); return; } glGenTextures(1, &normal); glBindTexture(GL_TEXTURE_2D, normal); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapinfoheader_normal.biWidth, bitmapinfoheader_normal.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, normaldata); mipmapdata = LoadBMP("mipmap.bmp", &bitmapinfoheader_mipmap); if ( !mipmapdata ) { MessageBox(0, "...but couldn't load mipmap.bmp!", "Sorry...", 0); return; } glGenTextures(1, &mipmap); glBindTexture(GL_TEXTURE_2D, mipmap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, bitmapinfoheader_mipmap.biWidth, bitmapinfoheader_mipmap.biHeight, GL_RGB, GL_UNSIGNED_BYTE, mipmapdata); }
Wenn ich aber meine 2 Würfel rendere, wird nur die 2te Texture (mipmap) angezeigt!
void Render() { glMatrixMode(GL_MODELVIEW); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -5.0f); glPushMatrix(); glBindTexture(1, mipmap); DrawCube(-1.0f, 0.0f, 0.0f, g_angle, 0.3f, 0.5f, 0.4f); glPopMatrix(); glPushMatrix(); glBindTexture(1, normal); DrawCube(1.0f, 0.0f, 0.0f, g_angle, 0.3f, 0.5f, 0.4f); glPopMatrix(); glFlush(); SwapBuffers(g_hdc); g_angle += 0.5f; }
Was mache ich falsch?
-
Frage:
Wo lädst Du die Extensions für Multitexturing?Such mal nach diesen Extensions:
glActiveTextureARB
glClientActiveTextureARB
glMultiTexCoord2fARBDie wirst Du für Multitexturing brauchen.
-
Patrick schrieb:
Frage:
Wo lädst Du die Extensions für Multitexturing?Such mal nach diesen Extensions:
glActiveTextureARB
glClientActiveTextureARB
glMultiTexCoord2fARBDie wirst Du für Multitexturing brauchen.
es geht hier wohl nicht um multitexturing, er will je eine textur auf je einen cube setzen, wobei er insgesammt 2 cubes zeichnen möchte
right?
rapso->greets();
-
Jupp, sorry falls ich mich unklar ausgedrückt habe, ich wollte lediglich 2 Würfel mit 2 versch. Texturen belegen. Problem ist auch schon gelöst, folgende Codezeile
glBindTexture(1, mipmap);
muß in
[cpp]glBindTexture(GL_TEXTURE_2D, mipmap);[/cpp]
geändert werden.