Autor Beitrag
mathias
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 58
Erhaltene Danke: 3



BeitragVerfasst: Fr 21.06.02 20:45 
Beispiel mit einem halttransparenten Würfel.

DrawScene von "OpenGL erstes Beispiel" mit folgender Drawscene ersetzen.
ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
procedure TForm1.DrawScene;
begin
  glEnable(GL_DEPTH_TEST);
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glMatrixMode(GL_MODELVIEW);

  glEnable(GL_BLEND);  // Alphablending einschalten
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

  glLoadIdentity;
  glTranslatef(00, -10);

  glRotatef(winkel1, 100);
  glRotatef(winkel2, 010);
  glRotatef(winkel3, 001);

  glBegin(GL_POLYGON);
    glColor4f(1100.5);        // der 4. Wert ist der Alphawert
    glVertex3f( 1.0,  1.0, -1.0);
    glVertex3f( 1.0, -1.0, -1.0);
    glVertex3f(-1.0, -1.0, -1.0);
    glVertex3f(-1.0,  1.0, -1.0);
  glEnd;

  glBegin(GL_POLYGON);
    glColor4f(0010.5);
    glVertex3f( 1.0,  1.01.0);
    glVertex3f(-1.0,  1.01.0);
    glVertex3f(-1.0, -1.01.0);
    glVertex3f( 1.0, -1.01.0);
  glEnd;

  glBegin(GL_POLYGON);
    glColor4f(1010.5);
    glVertex3f(-1.0,  1.0,  1.0);
    glVertex3f(-1.0,  1.0, -1.0);
    glVertex3f(-1.0, -1.0, -1.0);
    glVertex3f(-1.0, -1.0,  1.0);
  glEnd;

  glBegin(GL_POLYGON);
    glColor4f(0110.5);
    glVertex3f( 1.0,  1.0,  1.0);
    glVertex3f( 1.0, -1.0,  1.0);
    glVertex3f( 1.0, -1.0, -1.0);
    glVertex3f( 1.0,  1.0, -1.0);
  glEnd;

  glBegin(GL_POLYGON);
    glColor4f(1000.5);
    glVertex3f(-1.0, -1.0, -1.0);
    glVertex3f( 1.0, -1.0, -1.0);
    glVertex3f( 1.0, -1.0,  1.0);
    glVertex3f(-1.0, -1.0,  1.0);
  glEnd;

  glBegin(GL_POLYGON);
    glColor4f(0100.5);
    glVertex3f(-1.0,  1.0, -1.0);
    glVertex3f(-1.0,  1.0,  1.0);
    glVertex3f( 1.0,  1.0,  1.0);
    glVertex3f( 1.0,  1.0, -1.0);
  glEnd;

  glEnable(GL_BLEND);  // Alphablending ausschalten

  SwapBuffers(DC);
end;