OpenGL - GLUT

S

Sribo

Neues Mitglied
Thread Starter
Dabei seit
26.10.2003
Beiträge
7
Reaktionspunkte
0
Hallo Ppls!

Ich bin ein Neuling in Sachen OpenGL und GLUT!

Habe folgendes porgrammiert:

#include <OpenGL/gl.h>
#include <GLUT/glut.h>

// Fuellmuster
static GLubyte test[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x7E, 0x7E, 0x00, 0x18, 0x7E, 0x7E, 0x00,
0x18, 0x60, 0x06, 0x00, 0x18, 0x7E, 0x7E, 0x00,
0x18, 0x7E, 0x7E, 0x00, 0x18, 0x60, 0x60, 0x00,
0x7E, 0x7E, 0x7E, 0x00, 0x7E, 0x7E, 0x7E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

void display(void)
{
// Hintergrund lˆschen
glClear(GL_COLOR_BUFFER_BIT);

// Graues Rechteck mit schwarzem F¸llmuster
glColor3f(0.5, 0.5, 0.5);
glRectf(1.0, 0.5, 10.0, 1.5);

glPolygonStipple(test);
glEnable(GL_POLYGON_STIPPLE);
glColor3f(0.0, 0.0, 0.0);
glRectf(1.0, 0.5, 10.0, 1.5);
glDisable(GL_POLYGON_STIPPLE);

glColor3f(1.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2f(2.5, 4.0);
glVertex2f(2.5, 7.0);
glVertex2f(1.5, 7.0);
glVertex2f(3.5, 7.0);
glEnd();

glColor3f(0.0,0.0,0.0);
glBegin(GL_POINTS);
glVertex2f(7.0, 2.5);
glVertex2f(6.0, 2.5);
glVertex2f(5.0, 2.5);
glVertex2f(5.0, 3.25);
glVertex2f(5.0, 4.0);
glVertex2f(6.0, 4.0);
glVertex2f(7.0, 4.0);
glVertex2f(5.0, 4.75);
glVertex2f(5.0, 5.5);
glVertex2f(6.0, 5.5);
glVertex2f(7.0, 5.5);
glEnd();

glColor3f(0.0, 1.0, 0.0);
glLineStipple(1, 0xA0A0);
glEnable(GL_LINE_STIPPLE);
glBegin(GL_LINE_STRIP);
glVertex2f(7.5, 6.5);
glVertex2f(9.5, 6.5);
glVertex2f(9.5, 8.0);
glVertex2f(7.5, 8.0);
glVertex2f(7.5, 9.5);
glVertex2f(9.5, 9.5);
glEnd();
glDisable(GL_LINE_STIPPLE);

glColor3f(0.0, 0.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(11.25, 5.25);
glVertex2f(11.75, 5.75);
glVertex2f(13.5, 4.0);
glVertex2f(13.0, 3.5);
glEnd();


glBegin(GL_POLYGON);
glVertex2f(12.5, 6.5);
glVertex2f(12.0, 7.0);
glVertex2f(10.0, 5.0);
glVertex2f(10.5, 4.5);
glEnd();
glFlush();
}

void reshape(int width, int height)
{
glViewport(0,0,width,height);
}

void init(void)
{
// Hintergrundfarbe weiss
glClearColor(1.0, 1.0, 1.0, 0.0);

// Koordinatenbereich initialisieren
gluOrtho2D(0.0, 15.0, 0.0, 10.0);
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(300, 200);
glutInitWindowPosition(100, 100);
glutCreateWindow("Grundelemente");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();

return 0;
}

Das Programm wird problemlos ausgeführt. Nur die Funktionen mit GLPolygonStipple und GLLineStipple funktionieren unter Jaguar nicht. Unter Windows aber funktionieren die. Woran kann es liegen?
 
finde ich leider bedauerlich, dass keiner mir bislang auch irgendetwas geschrieben hat.
 
Hallo,
also ich habe Dein Problem nicht nachvollziehen können. Habe mal dein Progi bei mir compiliert und einen Screenshot gemacht. Das GL_POLYGON_STIPPLE erzeugt ein Muster,
und GL_LINE_STIPPLE macht eine gestrichelte Linie.
Das einzige was Dir bei solchen Sachen passieren kann ist das die Muster falsch interpretiert werden. Liegt an der unterschiedlichen "Endianess" von z.B. x86 Hardware und PPC. Sollte dein Pattern nicht wie es jetzt dransteht "23T" lauten sondert "SET" dann musst du noch in der init() folgendes dazuschreiben:
glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
Damit bekommst du dann deine Byteorder anders herum interpretiert, also das LSB (last significant bit) zuerst.
Falls du immer noch Probleme hast, sag einfach bescheid.

Gruß Sascha
 

Anhänge

  • test.jpg
    test.jpg
    6,1 KB · Aufrufe: 100
Zurück
Oben Unten