52 lines
1.7 KiB
C
52 lines
1.7 KiB
C
#include <GL/glut.h>
|
|
#include <string.h>
|
|
|
|
static int width = 640;
|
|
static int height = 480;
|
|
|
|
void init(int argc, char** argv)
|
|
{
|
|
glutInit(&argc, argv); // Initialisierung der GLUT Bibliothek
|
|
glutInitDisplayMode(GLUT_SINGLE); // Initialisierung des Single Buffer Modes
|
|
glutInitWindowSize(width, height); // Fenstergröße in Pixel (Breite, Hoehe)
|
|
glutInitWindowPosition(
|
|
100, 100); // Fensterposition in Pixel, ausgehend vom Ursprung des Window Systems
|
|
glViewport(0, 0, width, height);
|
|
glutCreateWindow("Hello world"); // Erstellen des Fensters
|
|
glMatrixMode(GL_PROJECTION);
|
|
glLoadIdentity();
|
|
gluOrtho2D(0, width, 0, height);
|
|
glMatrixMode(GL_MODELVIEW);
|
|
}
|
|
|
|
void display(void)
|
|
{
|
|
char* myText = "Hello World!";
|
|
unsigned long j;
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
glColor3f(1.0, 0.0, 0.0);
|
|
|
|
glBegin(GL_POLYGON);
|
|
glVertex3f((width / 2) - (width / 4), (height / 2) - (height / 4), 0.0);
|
|
glVertex3f((width / 2) + (width / 4), (height / 2) - (height / 4), 0.0);
|
|
glVertex3f((width / 2) + (width / 4), (height / 2) + (height / 4), 0.0);
|
|
glVertex3f((width / 2) - (width / 4), (height / 2) + (height / 4), 0.0);
|
|
glEnd();
|
|
|
|
glColor3f(1.0, 1.0, 1.0);
|
|
glRasterPos2i((width / 2) - (width / 4) + 10, (height / 2) - (height / 4) + 10);
|
|
for (j = 0ul; j < strlen(myText); j++) {
|
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, myText[j]);
|
|
}
|
|
|
|
glFlush();
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
init(argc, argv);
|
|
glutDisplayFunc(display); // Callback-Funktion für das Fenster
|
|
glutMainLoop(); // Abgabe der Kontrolle an GLUT-Bibliothek
|
|
return 0;
|
|
}
|