Kod: Zaznacz cały
/*
(c) Janusz Ganczarski (Power)
http://www.januszg.hg.pl
JanuszG@enter.net.pl
*/
#include <GL/glut.h>
#include <stdlib.h>
// funkcja generuj�ca scen� 3D
void Display ()
{
// kolor t�a - zawarto�� bufora koloru
glClearColor (1.0,1.0,1.0,1.0);
// czyszczenie bufora koloru
glClear (GL_COLOR_BUFFER_BIT);
// kolor kwadratu
glColor3f (1.0,0.0,0.0);
// pocz�tek definicji wielok�ta
glBegin (GL_POLYGON);
// kolejne wierzcho�ki wielok�ta
glVertex3f (0.0, 0.0, 0.0);
glVertex3f (0.0, 1.0, 0.0);
glVertex3f (1.0, 1.0, 0.0);
glVertex3f (1.0, 0.0, 0.0);
// koniec definicji prymitywu
glEnd ();
// skierowanie polece� do wykonania
glFlush ();
// zamiana bufor�w koloru
glutSwapBuffers();
}
// zmiana wielko�ci okna
void Reshape (int width, int height)
{
// generowanie sceny 3D
Display ();
}
// sta�e do obs�ugi menu podr�cznego
enum
{
EXIT // wyj�cie
};
// obs�uga menu podr�cznego
void Menu (int value)
{
switch (value)
{
// wyj�cie
case EXIT:
exit (0);
}
}
int main (int argc, char *argv[])
{
// inicjalizacja biblioteki GLUT
glutInit (&argc,argv);
// inicjalizacja bufora ramki
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
// rozmiary g��wnego okna programu
glutInitWindowSize (400,400);
// utworzenie g��wnego okna programu
glutCreateWindow ("Kwadrat 1");
// do��czenie funkcji generuj�cej scen� 3D
glutDisplayFunc (Display);
// do��czenie funkcji wywo�ywanej przy zmianie rozmiaru okna
glutReshapeFunc (Reshape);
// utworzenie menu podr�cznego
glutCreateMenu (Menu);
// dodadnie pozycji do menu podr�cznego
#ifdef WIN32
glutAddMenuEntry ("Wyj�cie",EXIT);
#else
glutAddMenuEntry ("Wyjscie",EXIT);
#endif
// okre�lenie przycisku myszki obs�uguj�cej menu podr�czne
glutAttachMenu (GLUT_RIGHT_BUTTON);
// wprowadzenie programu do obs�ugi p�tli komunikat�w
glutMainLoop ();
return 0;
}
Kod: Zaznacz cały
kwadrat1.cpp:7:21: error: GL/glut.h: No such file or directory
kwadrat1.cpp: In function `void Display(),:
kwadrat1.cpp:15: błąd: `glClearColor, was not declared in this scope
kwadrat1.cpp:18: błąd: `GL_COLOR_BUFFER_BIT, was not declared in this scope
kwadrat1.cpp:18: błąd: `glClear, was not declared in this scope
kwadrat1.cpp:21: błąd: `glColor3f, was not declared in this scope
kwadrat1.cpp:24: błąd: `GL_POLYGON, was not declared in this scope
kwadrat1.cpp:24: błąd: `glBegin, was not declared in this scope
kwadrat1.cpp:27: błąd: `glVertex3f, was not declared in this scope
kwadrat1.cpp:33: błąd: `glEnd, was not declared in this scope
kwadrat1.cpp:36: błąd: `glFlush, was not declared in this scope
kwadrat1.cpp:39: błąd: `glutSwapBuffers, was not declared in this scope
kwadrat1.cpp: In function `int main(int, char**),:
kwadrat1.cpp:72: błąd: `glutInit, was not declared in this scope
kwadrat1.cpp:75: błąd: `GLUT_DOUBLE, was not declared in this scope
kwadrat1.cpp:75: błąd: `GLUT_RGB, was not declared in this scope
kwadrat1.cpp:75: błąd: `glutInitDisplayMode, was not declared in this scope
kwadrat1.cpp:78: błąd: `glutInitWindowSize, was not declared in this scope
kwadrat1.cpp:81: błąd: `glutCreateWindow, was not declared in this scope
kwadrat1.cpp:84: błąd: `glutDisplayFunc, was not declared in this scope
kwadrat1.cpp:87: błąd: `glutReshapeFunc, was not declared in this scope
kwadrat1.cpp:90: błąd: `glutCreateMenu, was not declared in this scope
kwadrat1.cpp:98: błąd: `glutAddMenuEntry, was not declared in this scope
kwadrat1.cpp:102: błąd: `GLUT_RIGHT_BUTTON, was not declared in this scope
kwadrat1.cpp:102: błąd: `glutAttachMenu, was not declared in this scope
kwadrat1.cpp:105: błąd: `glutMainLoop, was not declared in this scope