Autor Beitrag
MysticMike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Mo 01.05.06 01:29 
Hi!

Ich hab eine Frage zum Binden von Texturen auf Quads. Ich möchte auf dem Bildschirm gerne ein weißes Quadrat darstellen und rechts daneben ein Quadrat, welches mit einer Wasser-Textur belegt ist. Die Textur lade ich mit dem SDLloader im TForm1.create Ereignis.

Beim Rendern erscheint das linke Quadrat allerdings nicht weiß, sondern hellblau...

thx Mystix


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.Render;
begin
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glLoadIdentity;
  glTranslatef(-30, -5);

  glBegin(GL_QUADS);
  glVertex3f(-1,-1,0);
  glVertex3f(-1,1,0);
  glVertex3f(1,1,0);
  glVertex3f(1,-1,0);
  glEnd;

  glLoadIdentity;
  glTranslatef(30, -5);
  glEnable(gl_texture_2d);

  glBegin(GL_QUADS);
  glbindtexture(gl_Texture_2D, textur);
  glTexCoord2f(0,0); glVertex3f(-1,-1,0);
  glTexCoord2f(0,1); glVertex3f(-1,1,0);
  glTexCoord2f(1,1); glVertex3f(1,1,0);
  glTexCoord2f(1,0); glVertex3f(1,-1,0);
  glEnd;

  SwapBuffers(DC);
end;
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 01.05.06 03:17 
Hi,

du mußt deine Textur deaktivieren wenn du das weiße Quad zeichnest, sonst bekommt das die gleiche textur.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
procedure TForm1.Render;
begin
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glLoadIdentity;
  glTranslatef(-30, -5);

  glDisable(GL_TEXTURE_2D);
  glBegin(GL_QUADS);
  glVertex3f(-1,-1,0);
  glVertex3f(-1,1,0);
  glVertex3f(1,1,0);
  glVertex3f(1,-1,0);
  glEnd;

  glLoadIdentity;
  glTranslatef(30, -5);
  glEnable(gl_texture_2d);

  glBegin(GL_QUADS);
  glbindtexture(gl_Texture_2D, textur);
  glTexCoord2f(0,0); glVertex3f(-1,-1,0);
  glTexCoord2f(0,1); glVertex3f(-1,1,0);
  glTexCoord2f(1,1); glVertex3f(1,1,0);
  glTexCoord2f(1,0); glVertex3f(1,-1,0);
  glEnd;

  SwapBuffers(DC);
end;


Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
MysticMike Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 21



BeitragVerfasst: Mo 01.05.06 17:08 
Dann sag ich mal: Recht herzlichen Dank!

greetz Mystix
Lossy eX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1048
Erhaltene Danke: 4



BeitragVerfasst: Di 02.05.06 10:35 
Außerdem ist der Aufruf von glBindTexture zwischen glBegin und glEnd nicht gestattet! Der einzige Grund warum du derzeit überhaupt noch eine Textur siehst ist der, da sie beim Laden bereits gebunden wurde. Das wirst du spätestens dann merken, wenn du versucht eine weitere Textur ins Spiel zu bringen. Dann nimmt er permanent die Letzte.

Einfach das glBindTexture vor dem glBegin aufrufen und alles in Ordnung.

_________________
Nur die Menschheit ist arrogant genug, um zu glauben sie sei die einzige intelligente Lebensform im All. Wo nicht mal das nachhaltig bewiesen wurde.