SlideShare a Scribd company logo
1 of 12
Download to read offline
1 // DEMOSTRAÇÃO DE COMO CRIAR UM 'X' EM OPENGL
2 #include <FL/Fl.H>
3 #include <FL/fl_draw.H>
4 #include <FL/Fl_Double_Window.H>
5
6 // SIMPLE BOX WIDGET THAT DRAWS AN 'X'
7 class DrawX : public Fl_Widget {
8 public:
9 DrawX(int X, int Y, int W, int H, const char*L=0) : Fl_Widget(X,Y,W,H,L)
10 {
11 }
12 void draw(void)
13 {
14 // DRAW BLACK 'X'
15 fl_color(FL_BLACK);
16 fl_line(x(), y(), x()+w()-1, y()+h()-1);
17 fl_line(x(), y()+h()-1, x()+w()-1, y());
18 }
19 };
20
21 int main(int argc, char* argv[] )
22 {
23 Fl_Double_Window win(200,200);
24 DrawX draw_x(0, 0, win.w(), win.h());
25 win.resizable(draw_x);
26 win.show();
27 return(Fl::run());
28 }
29
30
1 /*
2 * timer.cxx
3 * Exemplo das propriedades de desenho do FLTK
4 */
5
6 //
7 // FLTK drawing example showing simple line drawing animation
8 // erco 03/22/07
9 //
10 #include <FL/Fl.H>
11 #include <FL/Fl_Double_Window.H>
12 #include <FL/Fl_Box.H>
13 #include <FL/fl_draw.h>
14 #include <math.h>
15 #include <stdio.h>
16 #include <time.h>
17 #define BG_COLOR 45
18 #define TICK_COLOR 50
19 #define CIRC_COLOR 0
20 class MyTimer : public Fl_Box
21 {
22 void draw()
23 {
24 // COMPUTE NEW COORDS OF LINE
25 static long start = time(NULL);
26 long tick = time(NULL) - start;
27 char secs[80]; sprintf(secs, "%02ld:%02ld", tick/60, tick%60);
28 float pi = 3.14 - (((tick % 60) / 60.0) * 6.28);
29 int radius = h() / 2;
30 int x1 = (int)(x() + w()/2),
31 y1 = (int)(y() + h()/2),
32 x2 = (int)(x1 + (sin(pi) * radius)),
33 y2 = (int)(y1 + (cos(pi) * radius));
34
35 // TELL BASE WIDGET TO DRAW ITS BACKGROUND
36 Fl_Box::draw();
37
38 // DRAW 'SECOND HAND' OVER WIDGET'S BACKGROUND
39 fl_color(TICK_COLOR);
40 fl_line(x1, y1, x2, y2);
41 fl_color(CIRC_COLOR);
42 fl_pie(x1-10, y1-10, 20, 20, 0.0, 360.0);
43
44 // DRAW TIMER TEXT STRING
45 fl_color(TICK_COLOR);
46 fl_font(FL_HELVETICA,16);
47 fl_draw(secs, x()+4, y()+h()-4);
48 }
49
50 static void Timer_CB(void *userdata)
51 {
52 MyTimer *o = (MyTimer*)userdata;
53 o->redraw();
54 Fl::repeat_timeout(0.25, Timer_CB, userdata);
55 }
56 public:
57 // CONSTRUCTOR
58 MyTimer(int X,int Y,int W,int H,const char*L=0) : Fl_Box(X,Y,W,H,L) {
59 box(FL_FLAT_BOX);
60 color(BG_COLOR);
61 Fl::add_timeout(0.25, Timer_CB, (void*)this);
62 }
63 };
64 // MAIN
65 int main(int argc, char* argv[])
66 {
67 Fl_Double_Window win(220, 220);
68 MyTimer tim(10, 10, win.w()-20, win.h()-20);
69 win.show();
70 return(Fl::run());
71 }
72
1C:Documents and SettingsAdministradorDesktop....OpenGL_Exercicio.Exemplo.03opengl.exemplo.cxx
/*
* opengl.exemplo.cxx
* Simple resizable 2D GL window
*/
#include <FL/gl.h>
#include <FL/Fl.H>
#include <FL/Fl_Gl_Window.H>
class MyGlWindow : public Fl_Gl_Window
{
// DRAW METHOD
// OpenGL window: (w,h) is upper right, (-w,-h) is lower left, (0,0) is center
//
void draw()
{
// First time? init viewport, etc.
if (!valid()) {
valid(1);
glLoadIdentity();
glViewport(0,0,w(),h());
glOrtho(-w(),w(),-h(),h(),-1,1);
}
// Clear screen
glClear(GL_COLOR_BUFFER_BIT);
// Draw white 'X'
glColor3f(1.0, 1.0, 0.0);
glBegin(GL_LINE_STRIP); glVertex2f(w(), h()); glVertex2f(-w(),-h()); glEnd();
glBegin(GL_LINE_STRIP); glVertex2f(w(),-h()); glVertex2f(-w(), h()); glEnd();
}
// HANDLE WINDOW RESIZING
// If window reshaped, need to readjust viewport/ortho
//
void resize(int X,int Y,int W,int H)
{
Fl_Gl_Window::resize(X,Y,W,H);
glLoadIdentity();
glViewport(0,0,W,H);
glOrtho(-W,W,-H,H,-1,1);
redraw();
}
public:
// CONSTRUCTOR
MyGlWindow(int X,int Y,int W,int H,const char*L=0) : Fl_Gl_Window(X,Y,W,H,L)
{
}
};
// MAIN
int main(int argc, char* argv[])
{
Fl_Window win(500, 300);
MyGlWindow mygl(10, 10, win.w()-20, win.h()-20);
win.end();
win.resizable(mygl);
win.show();
return(Fl::run());
}
1C:Documents and SettingsAdministradorDesktop...AND.Using.OpenGL_Exercicio.Exemplo.04sphere.cxx
/*
* sphere.cxx
* Render a simple opengl shaded sphere with a single side light
* NOTE: Glut needed *only* for glutSolidSphere()
*/
#ifdef _WIN32
#include <windows.h>
#endif
#include <math.h>
#include <FL/Fl.h>
#include <FL/gl.h>
#include <FL/glut.h>
#include <FL/Fl_Window.h>
#include <FL/Fl_Gl_Window.h>
class MyGlWindow : public Fl_Gl_Window
{
public:
// RESHAPE THE VIEWPORT
void Reshape(GLfloat W, GLfloat H)
{
// (REFERENCE: SGI light.c DEMO)
GLfloat ratio = W / H;
glViewport(0, 0, (GLsizei)W, (GLsizei)H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.5*ratio, 1.5*ratio, -1.5, 1.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
// Desenhando a cena ...
void draw()
{
if (!valid())
{
valid(1);
Reshape(w(), h());
// (REFERENCE: SGI 'light.c' EXAMPLE)
GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA
GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA
GLfloat light_position[] = { 5.0, 5.0, 0.0, 0.0 }; // XYZ
glClearColor(0.0, 0.0, 0.4, 0.0); // bg color
glShadeModel(GL_SMOOTH);
//
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialf(GL_FRONT, GL_SHININESS, 20.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
//
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(0.5, 0.5, 0.5);
glutSolidSphere(0.5, 30, 30);
glPopMatrix();
}
//Constructor ...
MyGlWindow(int X,int Y,int W,int H,const char*L=0) : Fl_Gl_Window(X,Y,W,H,L)
{
}
};
/*Funcao principal*/
int main(int argc, char* argv[])
{
Fl_Window win(640, 480, "sphere");
MyGlWindow mygl(10, 10, win.w()-20, win.h()-20);
win.resizable(&mygl);
win.show();
return(Fl::run());
}
1 /**
2 * Um primeiro exemplo utilizando OpenGL + GLUT
3 **/
4
5 //Inclusão da biblioteca GLUT
6 #include <glut.h>
7
8 /*Função que executara o desenho na janela*/
9 void display(void)
10 {
11 /*Limpando a cor de fundo da janela e definindo a nova cor de desenho*/
12 glClear(GL_COLOR_BUFFER_BIT);
13 glColor3f(0.0,0.0,0.0);
14
15 /*Desenhando um polígono*/
16 glBegin(GL_POLYGON);
17 glVertex2f(0.25,0.25);
18 glVertex2f(0.75,0.25);
19 glVertex2f(0.75,0.75);
20 glVertex2f(0.25,0.75);
21 glEnd();
22
23 /*Forçando a execução dos comandos OpenGL*/
24 glFlush();
25 }
26
27 /*Função principal do programa*/
28 int main(int argc, char **argv)
29 {
30 glutInit(&argc,argv);
31 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
32 glutInitWindowSize(256,256);
33 glutInitWindowPosition(100,100);
34 glutCreateWindow(argv[0]);
35 glClearColor(1.0,1.0,1.0,0.0);
36 glShadeModel(GL_FLAT);
37 glOrtho(0,1,0,1,-1,1);
38 glutDisplayFunc(display);
39 glutMainLoop();
40 return 0;
41 }
42
1C:Documents and SettingsAdministradorDesktop_exemplos.openglMyShapePolygonWindow.cxx
//
// Tiny OpenGL demo program for the Fast Light Tool Kit (FLTK).
//
#include "config.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/math.h>
#if HAVE_GL
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>
class MyShapePolygonWindow : public Fl_Gl_Window
{
void draw();
public:
MyShapePolygonWindow(int x,int y,int w,int h,const char *l=0);
};
MyShapePolygonWindow::MyShapePolygonWindow(int x,int y,int w,int h,const char *l):
Fl_Gl_Window(x,y,w,h,l)
{
}
void MyShapePolygonWindow::draw()
{
// the valid() property may be used to avoid reinitializing your
// GL transformation for each redraw:
if (!valid())
{
valid(1);
glLoadIdentity();
glViewport(0, 0, w(), h());
}
// draw an amazing graphic:
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(-0.5f, -0.5f);
glVertex2f( 0.5f, -0.5f);
glVertex2f( 0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);
glEnd();
glFlush();
}
#else
#include <FL/Fl_Box.H>
class MyShapePolygonWindow : public Fl_Box
{
public:
MyShapePolygonWindow(int x,int y,int w,int h,const char *l=0)
:Fl_Box(FL_DOWN_BOX,x,y,w,h,l)
{
this->label("Esse exemplo não trabalha sem OpenGL !");
}
};
#endif
int main(int argc, char *argv[])
{
Fl_Window window(300, 300);
MyShapePolygonWindow sw(10, 10, 280, 280);
window.resizable(&sw);
window.end();
window.show(argc,argv);
return Fl::run();
}
1 /**
2 * Um programa OpenGL simples que desenha um quadrado em uma janela GLUT.
3 */
4 #include <glut.h>
5
6 // Função callback chamada para fazer o desenho
7 void Desenha(void)
8 {
9 // Inicializa o sistema de coordenadas
10 glMatrixMode(GL_MODELVIEW);
11 glLoadIdentity();
12
13 // Limpa a janela de visualização com a cor de fundo especificada
14 glClear(GL_COLOR_BUFFER_BIT);
15
16 // Especifica que a cor corrente é amarela
17 // R G B
18 glColor3f(1.0f, 1.0f, 0.0f);
19
20 // Desenha um quadrado preenchido com a cor corrente
21 glBegin(GL_QUADS);
22 glVertex2i(100,150);
23 glVertex2i(100,100);
24 // Especifica que a cor corrente é vermelha
25 glColor3f(1.0f, 0.0f, 0.0f);
26 glVertex2i(150,100);
27 glVertex2i(150,150);
28 glEnd();
29
30 // Executa os comandos OpenGL
31 glFlush();
32 }
33
34 // Inicializa parâmetros de rendering
35 void Inicializa (void)
36 {
37 // Define a cor de fundo da janela de visualização como preta
38 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
39 }
40
41 // Função callback chamada quando o tamanho da janela é alterado
42 void AlteraTamanhoJanela(GLsizei w, GLsizei h)
43 {
44 // Evita a divisao por zero
45 if(h == 0) h = 1;
46
47 // Especifica as dimensões da Viewport
48 glViewport(0, 0, w, h);
49
50 // Inicializa o sistema de coordenadas
51 glMatrixMode(GL_PROJECTION);
52 glLoadIdentity();
53
54 // Estabelece a janela de seleção (left, right, bottom, top)
55 if (w <= h)
56 gluOrtho2D (0.0f, 250.0f, 0.0f, 250.0f*h/w);
57 else
58 gluOrtho2D (0.0f, 250.0f*w/h, 0.0f, 250.0f);
59 }
60
61 // Programa Principal
62 int main(int argc, char* argv[])
63 {
64 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
65 glutInitWindowSize(400,350);
66 glutInitWindowPosition(10,10);
67 glutCreateWindow("O primeiro quadrado ...");
68 glutDisplayFunc(Desenha);
69 glutReshapeFunc(AlteraTamanhoJanela);
70 Inicializa();
71 glutMainLoop();
72 }
1 /**
2 * Exemplo de programa usando OpenGL + GLUT.
3 **/
4 #include <cstdlib>
5 #include <glut.h>
6
7 //Função callback de desenho da janela de visualização
8 void Desenha(void)
9 {
10 //Limpa a janela de visualização com a cor branca
11 glClearColor(1.0,1.0,1.0,0);
12 glClear(GL_COLOR_BUFFER_BIT);
13
14 //Define a cor de desenho: vermelho
15 glColor3f(1.0,0.0,0.0);
16
17 //Desenha um triangulo no centro da janela com interpolaçao de cores
18 glBegin(GL_TRIANGLES);
19 glColor3f(1.0,0.0,0.0); glVertex3f(-0.5,-0.5,0);
20 glColor3f(0.0,1.0,0.0); glVertex3f( 0.0, 0.5,0);
21 glColor3f(0.0,0.0,1.0); glVertex3f( 0.5,-0.5,0);
22 glEnd();
23
24 //Executa os comandos OpenGL
25 glFlush();
26 }
27
28 //Função callback chamada para gerenciar eventos de teclas
29 void Teclado(unsigned char key, int x, int y)
30 {
31 if (key == 27 ) exit(EXIT_SUCCESS);
32 }
33
34 //Funcção responsável por inicializar parametros e variaveis
35 void Inicializa(void)
36 {
37 //Define a janela de visualização 2D
38 glMatrixMode(GL_PROJECTION);
39 gluOrtho2D(-1.0,1.0,-1.0,1.0);
40 glMatrixMode(GL_MODELVIEW);
41 }
42
43 //Programa Principal
44 int main(int argc, char* argv[])
45 {
46
47 //Define o modo de operação da GLUT
48 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
49
50 //Especifica o tamanho inicial em pixels da janela GLUT
51 glutInitWindowSize(400,400);
52
53 //Cria a janela passando como argumento o título da mesma
54 glutCreateWindow("Primeiro Programa usando GLUT ...");
55
56 //Registra a função callback de redesenho da janela de visualização
57 glutDisplayFunc(Desenha);
58
59 //Registra a função callback para tratamento das teclas ASCII
60 glutKeyboardFunc(Teclado);
61
62 //Chama a função responsável por fazer as inicializações
63 Inicializa();
64
65 //Inicia o processamento e aguarda interações do usuário
66 glutMainLoop();
67
68 return EXIT_SUCCESS;
69 }
70
1 //
2 // Tiny OpenGL demo program for the Fast Light Tool Kit (FLTK).
3 //
4
5 #include "config.h"
6 #include <FL/Fl.H>
7 #include <FL/Fl_Window.H>
8 #include <FL/Fl_Hor_Slider.H>
9 #include <FL/math.h>
10
11 #if HAVE_GL
12
13 #include <FL/gl.h>
14 #include <FL/Fl_Gl_Window.H>
15
16 class shape_window : public Fl_Gl_Window {
17 void draw();
18 public:
19 int sides;
20 shape_window(int x,int y,int w,int h,const char *l=0);
21 };
22
23 shape_window::shape_window(int x,int y,int w,int h,const char *l) :
24 Fl_Gl_Window(x,y,w,h,l) {
25 sides = 3;
26 }
27
28 void shape_window::draw() {
29 // the valid() property may be used to avoid reinitializing your
30 // GL transformation for each redraw:
31 if (!valid()) {
32 valid(1);
33 glLoadIdentity();
34 glViewport(0, 0, w(), h());
35 }
36 // draw an amazing graphic:
37 glClear(GL_COLOR_BUFFER_BIT);
38 glColor3f(.5,.6,.7);
39 glBegin(GL_POLYGON);
40 for (int j=0; j<sides; j++) {
41 double ang = j*2*M_PI/sides;
42 glVertex3f(cos(ang),sin(ang),0);
43 }
44 glEnd();
45 }
46
47 #else
48
49 #include <FL/Fl_Box.H>
50 class shape_window : public Fl_Box {
51 public:
52 int sides;
53 shape_window(int x,int y,int w,int h,const char *l=0)
54 :Fl_Box(FL_DOWN_BOX,x,y,w,h,l){
55 label("This demo doesnnot work without GL");
56 }
57 };
58
59 #endif
60
61 // when you change the data, as in this callback, you must call redraw():
62 void sides_cb(Fl_Widget *o, void *p) {
63 shape_window *sw = (shape_window *)p;
64 sw->sides = int(((Fl_Slider *)o)->value());
65 sw->redraw();
66 }
67
68 int main(int argc, char **argv) {
69
70 Fl_Window window(300, 330);
71
72 // the shape window could be it's own window, but here we make it
73 // a child window:
74 shape_window sw(10, 10, 280, 280);
75 // make it resize:
76 window.resizable(&sw);
77 // window.size_range(300,330,0,0,1,1,1);
78 // add a knob to control it:
79 Fl_Hor_Slider slider(50, 295, window.w()-60, 30, "Sides:");
80 slider.align(FL_ALIGN_LEFT);
81 slider.callback(sides_cb,&sw);
82 slider.value(sw.sides);
83 slider.step(1);
84 slider.bounds(3,40);
85
86 window.end();
87 window.show(argc,argv);
88
89 return Fl::run();
90 }
91
92 //
93 // End of "$Id: shape.cxx 5845 2007-05-20 00:01:06Z mike $".
94 //
95
1 /**
2 * Programa exemplo utilizando OpenGL + GLUT
3 * Parametros de linkagem : -lGL -lglut
4 */
5
6 #include <GL/glut.h>
7
8 void initFunc(void)
9 {
10 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
11 glClearDepth(1.0f);
12 glEnable(GL_DEPTH_TEST);
13 glDepthFunc(GL_LEQUAL);
14 }
15
16 void reshapeFunc(int width, int height)
17 {
18 float aspect = 0.0f;
19 glViewport(0, 0, width, height);
20
21 glMatrixMode(GL_PROJECTION);
22 glLoadIdentity();
23
24 height = (height == 0 ? 1 : height);
25 aspect = (float) width / (float) height;
26
27 gluPerspective (45.0f, aspect, 0.01f, 100.0f);
28
29 glMatrixMode(GL_MODELVIEW);
30 glLoadIdentity();
31 }
32
33 void displayFunc(void)
34 {
35 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
36 glLoadIdentity();
37
38 gluLookAt(2.0f, 2.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
39
40 glLineWidth(2.0f);
41 glColor3f(0.15f, 0.45f, 0.15f);
42 glutWireCube(1.0f);
43 glColor3f(0.5f, 1.0f, 0.5f);
44 glutSolidCube(1.0f);
45
46 glutSwapBuffers();
47 }
48
49 int main(int argc, char* argv[])
50 {
51 glutInit(&argc, argv);
52 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
53 glutInitWindowSize(800, 600);
54 glutInitWindowPosition(50, 100);
55 glutCreateWindow("OpenGL Cube");
56 glutReshapeFunc(reshapeFunc);
57 glutDisplayFunc(displayFunc);
58 glutIdleFunc(displayFunc);
59 initFunc();
60 glutMainLoop();
61 return 0;
62 }
63
1C:Documents and SettingsAdministradorDesktop_exemplos.openglMySecondGlutCube.cxx
//#include <GL/glut.h>
#include "glut.h"
#include <cstdlib>
/*Estrutura que compoe o material do cubo e os efeitos de iluminacao*/
typedef struct {float ambiente[4]; float diffuse[4]; float specular[4];
float shininess[1]; } Material;
Material brass={{0.33f, 0.22f, 0.03f, 1}, {0.78f, 0.57f, 0.11f, 1},
{0.99f, 0.91f, 0.81f, 1}, {27.8f}};
void setMaterial(Material* p)
{
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, p->ambiente);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, p->diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, p->specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, p->shininess);
}
void displayCall(void)
{
glClearColor(0.4f,0.4f,0.4f,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
setMaterial(&brass);
glutSolidCube(1);
glFlush();
} /* Callback de REDISPLAY */
void reshapeCall(int width, int height)
{
glViewport(0, 0, (GLsizei)(width), (GLsizei)(height));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,4./3,0.5,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(1.5,1.5,1.2, 0,0,0, 0,0,1);
} /* Callback de RESHAPE */
void keyboardCall(unsigned char key, int x, int y)
{
switch (key) { case 27: exit(EXIT_SUCCESS); }
}/* Callback de KEYBOARD */
void initLight( )
{
float position[]={ 0.5f,2.f,0.f,1.f};
float low[]={0.2f,0.2f,0.2f,1};
float white[]={1,1,1,1};
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightfv(GL_LIGHT0, GL_AMBIENT, low);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
glLightfv(GL_LIGHT0, GL_SPECULAR, white);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
int main(int argc, char **argv)
{
glutInit(&argc, argv); /* Inicializando a GLUT */
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("FCG:Simple Light");
glutDisplayFunc(displayCall);
glutReshapeFunc(reshapeCall);
glutKeyboardFunc(keyboardCall);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
initLight(); /* Inicializando a luz e o material */
glutMainLoop(); /* GLUT main loop */
return 0;
}

More Related Content

What's hot

systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in cMeghna Roy
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Syed Umair
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Jaydip JK
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
Basic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersBasic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersAppier
 
Keypad program
Keypad programKeypad program
Keypad programksaianil1
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nmmohamed sikander
 

What's hot (20)

systems programming lab programs in c
systems programming lab programs in csystems programming lab programs in c
systems programming lab programs in c
 
Vcs15
Vcs15Vcs15
Vcs15
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Opp compile
Opp compileOpp compile
Opp compile
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
C++ TUTORIAL 10
C++ TUTORIAL 10C++ TUTORIAL 10
C++ TUTORIAL 10
 
Roslyn: el futuro de C#
Roslyn: el futuro de C#Roslyn: el futuro de C#
Roslyn: el futuro de C#
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
C lab programs
C lab programsC lab programs
C lab programs
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
Basic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python ProgrammersBasic C++ 11/14 for Python Programmers
Basic C++ 11/14 for Python Programmers
 
OpenGL Starter L01
OpenGL Starter L01OpenGL Starter L01
OpenGL Starter L01
 
Cquestions
Cquestions Cquestions
Cquestions
 
Keypad program
Keypad programKeypad program
Keypad program
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 

Similar to FLTK Summer Course - Part VIII - Eighth Impact - Exercises

Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Aila Gema Safitri
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportBijoy679
 
computer graphics at openGL
computer graphics at openGLcomputer graphics at openGL
computer graphics at openGLYasir Khan
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.pptadil104135
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp OpenMikeEly930
 
01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.pptEngrZamaan
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wireRené Domínguez
 
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docxajoy21
 
computer graphics at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)Yasir Khan
 
Rotate an object in open gl(glut) sample example with source
Rotate an object in open gl(glut) sample example with sourceRotate an object in open gl(glut) sample example with source
Rotate an object in open gl(glut) sample example with sourcekunalashutosh92
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flagRobi Parvez
 
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Robi Parvez
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184Mahmoud Samir Fayed
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Jannat Jamshed
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Jannat Jamshed
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210Mahmoud Samir Fayed
 
Problem 8T2 The code below attached to the Lab 7 is tem.pdf
Problem 8T2 The code below attached to the Lab 7 is tem.pdfProblem 8T2 The code below attached to the Lab 7 is tem.pdf
Problem 8T2 The code below attached to the Lab 7 is tem.pdfaadeshwarexports
 

Similar to FLTK Summer Course - Part VIII - Eighth Impact - Exercises (20)

Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
computer graphics at openGL
computer graphics at openGLcomputer graphics at openGL
computer graphics at openGL
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp Open
 
01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
 
Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
 
computer graphics at openGL (2)
computer graphics at openGL (2)computer graphics at openGL (2)
computer graphics at openGL (2)
 
Rotate an object in open gl(glut) sample example with source
Rotate an object in open gl(glut) sample example with sourceRotate an object in open gl(glut) sample example with source
Rotate an object in open gl(glut) sample example with source
 
2D Drawing
2D Drawing2D Drawing
2D Drawing
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
 
Open gl polygon code review
Open gl polygon code reviewOpen gl polygon code review
Open gl polygon code review
 
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function
 
Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function Robot In OpenGL Using Line Function
Robot In OpenGL Using Line Function
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
 
Problem 8T2 The code below attached to the Lab 7 is tem.pdf
Problem 8T2 The code below attached to the Lab 7 is tem.pdfProblem 8T2 The code below attached to the Lab 7 is tem.pdf
Problem 8T2 The code below attached to the Lab 7 is tem.pdf
 

More from Michel Alves

Texture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseTexture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseMichel Alves
 
Intelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesIntelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesMichel Alves
 
A Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresA Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresMichel Alves
 
Effectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesEffectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesMichel Alves
 
Introduction to Kernel Functions
Introduction to Kernel FunctionsIntroduction to Kernel Functions
Introduction to Kernel FunctionsMichel Alves
 
About Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceAbout Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceMichel Alves
 
Color Harmonization - Results
Color Harmonization - ResultsColor Harmonization - Results
Color Harmonization - ResultsMichel Alves
 
Wave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseWave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseMichel Alves
 
Similarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexSimilarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexMichel Alves
 
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationQualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationMichel Alves
 
TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsMichel Alves
 
Month Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMonth Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMichel Alves
 
Color Palettes in R
Color Palettes in RColor Palettes in R
Color Palettes in RMichel Alves
 
Hue Wheel Prototype
Hue Wheel PrototypeHue Wheel Prototype
Hue Wheel PrototypeMichel Alves
 
Triangle Mesh Plot
Triangle Mesh PlotTriangle Mesh Plot
Triangle Mesh PlotMichel Alves
 
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesCapacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesMichel Alves
 
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogCapacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogMichel Alves
 

More from Michel Alves (20)

Texture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU UseTexture Synthesis: An Approach Based on GPU Use
Texture Synthesis: An Approach Based on GPU Use
 
Intelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color PalettesIntelligent Transfer of Thematic Harmonic Color Palettes
Intelligent Transfer of Thematic Harmonic Color Palettes
 
A Framework for Harmonic Color Measures
A Framework for Harmonic Color MeasuresA Framework for Harmonic Color Measures
A Framework for Harmonic Color Measures
 
Effectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment IndexesEffectiveness of Image Quality Assessment Indexes
Effectiveness of Image Quality Assessment Indexes
 
Introduction to Kernel Functions
Introduction to Kernel FunctionsIntroduction to Kernel Functions
Introduction to Kernel Functions
 
About Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV SpaceAbout Perception and Hue Histograms in HSV Space
About Perception and Hue Histograms in HSV Space
 
Color Harmonization - Results
Color Harmonization - ResultsColor Harmonization - Results
Color Harmonization - Results
 
Wave Simulation Using Perlin Noise
Wave Simulation Using Perlin NoiseWave Simulation Using Perlin Noise
Wave Simulation Using Perlin Noise
 
Similarity Maps Using SSIM Index
Similarity Maps Using SSIM IndexSimilarity Maps Using SSIM Index
Similarity Maps Using SSIM Index
 
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color HarmonizationQualifying Exam - Image-Based Reconstruction With Color Harmonization
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
 
TMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and ReportsTMS - Schedule of Presentations and Reports
TMS - Schedule of Presentations and Reports
 
Month Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJMonth Presentations Schedule - March/2015 - LCG/UFRJ
Month Presentations Schedule - March/2015 - LCG/UFRJ
 
Color Palettes in R
Color Palettes in RColor Palettes in R
Color Palettes in R
 
Sigmoid Curve Erf
Sigmoid Curve ErfSigmoid Curve Erf
Sigmoid Curve Erf
 
Hue Wheel Prototype
Hue Wheel PrototypeHue Wheel Prototype
Hue Wheel Prototype
 
Cosine Curve
Cosine CurveCosine Curve
Cosine Curve
 
Triangle Mesh Plot
Triangle Mesh PlotTriangle Mesh Plot
Triangle Mesh Plot
 
Triangle Plot
Triangle PlotTriangle Plot
Triangle Plot
 
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video SlidesCapacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Video Slides
 
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function CatalogCapacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Density Function Catalog
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 

FLTK Summer Course - Part VIII - Eighth Impact - Exercises

  • 1. 1 // DEMOSTRAÇÃO DE COMO CRIAR UM 'X' EM OPENGL 2 #include <FL/Fl.H> 3 #include <FL/fl_draw.H> 4 #include <FL/Fl_Double_Window.H> 5 6 // SIMPLE BOX WIDGET THAT DRAWS AN 'X' 7 class DrawX : public Fl_Widget { 8 public: 9 DrawX(int X, int Y, int W, int H, const char*L=0) : Fl_Widget(X,Y,W,H,L) 10 { 11 } 12 void draw(void) 13 { 14 // DRAW BLACK 'X' 15 fl_color(FL_BLACK); 16 fl_line(x(), y(), x()+w()-1, y()+h()-1); 17 fl_line(x(), y()+h()-1, x()+w()-1, y()); 18 } 19 }; 20 21 int main(int argc, char* argv[] ) 22 { 23 Fl_Double_Window win(200,200); 24 DrawX draw_x(0, 0, win.w(), win.h()); 25 win.resizable(draw_x); 26 win.show(); 27 return(Fl::run()); 28 } 29 30
  • 2. 1 /* 2 * timer.cxx 3 * Exemplo das propriedades de desenho do FLTK 4 */ 5 6 // 7 // FLTK drawing example showing simple line drawing animation 8 // erco 03/22/07 9 // 10 #include <FL/Fl.H> 11 #include <FL/Fl_Double_Window.H> 12 #include <FL/Fl_Box.H> 13 #include <FL/fl_draw.h> 14 #include <math.h> 15 #include <stdio.h> 16 #include <time.h> 17 #define BG_COLOR 45 18 #define TICK_COLOR 50 19 #define CIRC_COLOR 0 20 class MyTimer : public Fl_Box 21 { 22 void draw() 23 { 24 // COMPUTE NEW COORDS OF LINE 25 static long start = time(NULL); 26 long tick = time(NULL) - start; 27 char secs[80]; sprintf(secs, "%02ld:%02ld", tick/60, tick%60); 28 float pi = 3.14 - (((tick % 60) / 60.0) * 6.28); 29 int radius = h() / 2; 30 int x1 = (int)(x() + w()/2), 31 y1 = (int)(y() + h()/2), 32 x2 = (int)(x1 + (sin(pi) * radius)), 33 y2 = (int)(y1 + (cos(pi) * radius)); 34 35 // TELL BASE WIDGET TO DRAW ITS BACKGROUND 36 Fl_Box::draw(); 37 38 // DRAW 'SECOND HAND' OVER WIDGET'S BACKGROUND 39 fl_color(TICK_COLOR); 40 fl_line(x1, y1, x2, y2); 41 fl_color(CIRC_COLOR); 42 fl_pie(x1-10, y1-10, 20, 20, 0.0, 360.0); 43 44 // DRAW TIMER TEXT STRING 45 fl_color(TICK_COLOR); 46 fl_font(FL_HELVETICA,16); 47 fl_draw(secs, x()+4, y()+h()-4); 48 } 49 50 static void Timer_CB(void *userdata) 51 { 52 MyTimer *o = (MyTimer*)userdata; 53 o->redraw(); 54 Fl::repeat_timeout(0.25, Timer_CB, userdata); 55 } 56 public: 57 // CONSTRUCTOR 58 MyTimer(int X,int Y,int W,int H,const char*L=0) : Fl_Box(X,Y,W,H,L) { 59 box(FL_FLAT_BOX); 60 color(BG_COLOR); 61 Fl::add_timeout(0.25, Timer_CB, (void*)this); 62 } 63 }; 64 // MAIN 65 int main(int argc, char* argv[]) 66 { 67 Fl_Double_Window win(220, 220); 68 MyTimer tim(10, 10, win.w()-20, win.h()-20); 69 win.show(); 70 return(Fl::run()); 71 } 72
  • 3. 1C:Documents and SettingsAdministradorDesktop....OpenGL_Exercicio.Exemplo.03opengl.exemplo.cxx /* * opengl.exemplo.cxx * Simple resizable 2D GL window */ #include <FL/gl.h> #include <FL/Fl.H> #include <FL/Fl_Gl_Window.H> class MyGlWindow : public Fl_Gl_Window { // DRAW METHOD // OpenGL window: (w,h) is upper right, (-w,-h) is lower left, (0,0) is center // void draw() { // First time? init viewport, etc. if (!valid()) { valid(1); glLoadIdentity(); glViewport(0,0,w(),h()); glOrtho(-w(),w(),-h(),h(),-1,1); } // Clear screen glClear(GL_COLOR_BUFFER_BIT); // Draw white 'X' glColor3f(1.0, 1.0, 0.0); glBegin(GL_LINE_STRIP); glVertex2f(w(), h()); glVertex2f(-w(),-h()); glEnd(); glBegin(GL_LINE_STRIP); glVertex2f(w(),-h()); glVertex2f(-w(), h()); glEnd(); } // HANDLE WINDOW RESIZING // If window reshaped, need to readjust viewport/ortho // void resize(int X,int Y,int W,int H) { Fl_Gl_Window::resize(X,Y,W,H); glLoadIdentity(); glViewport(0,0,W,H); glOrtho(-W,W,-H,H,-1,1); redraw(); } public: // CONSTRUCTOR MyGlWindow(int X,int Y,int W,int H,const char*L=0) : Fl_Gl_Window(X,Y,W,H,L) { } }; // MAIN int main(int argc, char* argv[]) { Fl_Window win(500, 300); MyGlWindow mygl(10, 10, win.w()-20, win.h()-20); win.end(); win.resizable(mygl); win.show(); return(Fl::run()); }
  • 4. 1C:Documents and SettingsAdministradorDesktop...AND.Using.OpenGL_Exercicio.Exemplo.04sphere.cxx /* * sphere.cxx * Render a simple opengl shaded sphere with a single side light * NOTE: Glut needed *only* for glutSolidSphere() */ #ifdef _WIN32 #include <windows.h> #endif #include <math.h> #include <FL/Fl.h> #include <FL/gl.h> #include <FL/glut.h> #include <FL/Fl_Window.h> #include <FL/Fl_Gl_Window.h> class MyGlWindow : public Fl_Gl_Window { public: // RESHAPE THE VIEWPORT void Reshape(GLfloat W, GLfloat H) { // (REFERENCE: SGI light.c DEMO) GLfloat ratio = W / H; glViewport(0, 0, (GLsizei)W, (GLsizei)H); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.5*ratio, 1.5*ratio, -1.5, 1.5, -10.0, 10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } // Desenhando a cena ... void draw() { if (!valid()) { valid(1); Reshape(w(), h()); // (REFERENCE: SGI 'light.c' EXAMPLE) GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA GLfloat mat_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; // RGBA GLfloat light_position[] = { 5.0, 5.0, 0.0, 0.0 }; // XYZ glClearColor(0.0, 0.0, 0.4, 0.0); // bg color glShadeModel(GL_SMOOTH); // glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialf(GL_FRONT, GL_SHININESS, 20.0); glLightfv(GL_LIGHT0, GL_POSITION, light_position); // glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glColor3f(0.5, 0.5, 0.5); glutSolidSphere(0.5, 30, 30); glPopMatrix(); } //Constructor ... MyGlWindow(int X,int Y,int W,int H,const char*L=0) : Fl_Gl_Window(X,Y,W,H,L) { } }; /*Funcao principal*/ int main(int argc, char* argv[]) { Fl_Window win(640, 480, "sphere"); MyGlWindow mygl(10, 10, win.w()-20, win.h()-20); win.resizable(&mygl); win.show(); return(Fl::run()); }
  • 5. 1 /** 2 * Um primeiro exemplo utilizando OpenGL + GLUT 3 **/ 4 5 //Inclusão da biblioteca GLUT 6 #include <glut.h> 7 8 /*Função que executara o desenho na janela*/ 9 void display(void) 10 { 11 /*Limpando a cor de fundo da janela e definindo a nova cor de desenho*/ 12 glClear(GL_COLOR_BUFFER_BIT); 13 glColor3f(0.0,0.0,0.0); 14 15 /*Desenhando um polígono*/ 16 glBegin(GL_POLYGON); 17 glVertex2f(0.25,0.25); 18 glVertex2f(0.75,0.25); 19 glVertex2f(0.75,0.75); 20 glVertex2f(0.25,0.75); 21 glEnd(); 22 23 /*Forçando a execução dos comandos OpenGL*/ 24 glFlush(); 25 } 26 27 /*Função principal do programa*/ 28 int main(int argc, char **argv) 29 { 30 glutInit(&argc,argv); 31 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 32 glutInitWindowSize(256,256); 33 glutInitWindowPosition(100,100); 34 glutCreateWindow(argv[0]); 35 glClearColor(1.0,1.0,1.0,0.0); 36 glShadeModel(GL_FLAT); 37 glOrtho(0,1,0,1,-1,1); 38 glutDisplayFunc(display); 39 glutMainLoop(); 40 return 0; 41 } 42
  • 6. 1C:Documents and SettingsAdministradorDesktop_exemplos.openglMyShapePolygonWindow.cxx // // Tiny OpenGL demo program for the Fast Light Tool Kit (FLTK). // #include "config.h" #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/math.h> #if HAVE_GL #include <FL/gl.h> #include <FL/Fl_Gl_Window.H> class MyShapePolygonWindow : public Fl_Gl_Window { void draw(); public: MyShapePolygonWindow(int x,int y,int w,int h,const char *l=0); }; MyShapePolygonWindow::MyShapePolygonWindow(int x,int y,int w,int h,const char *l): Fl_Gl_Window(x,y,w,h,l) { } void MyShapePolygonWindow::draw() { // the valid() property may be used to avoid reinitializing your // GL transformation for each redraw: if (!valid()) { valid(1); glLoadIdentity(); glViewport(0, 0, w(), h()); } // draw an amazing graphic: glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_POLYGON); glVertex2f(-0.5f, -0.5f); glVertex2f( 0.5f, -0.5f); glVertex2f( 0.5f, 0.5f); glVertex2f(-0.5f, 0.5f); glEnd(); glFlush(); } #else #include <FL/Fl_Box.H> class MyShapePolygonWindow : public Fl_Box { public: MyShapePolygonWindow(int x,int y,int w,int h,const char *l=0) :Fl_Box(FL_DOWN_BOX,x,y,w,h,l) { this->label("Esse exemplo não trabalha sem OpenGL !"); } }; #endif int main(int argc, char *argv[]) { Fl_Window window(300, 300); MyShapePolygonWindow sw(10, 10, 280, 280); window.resizable(&sw); window.end(); window.show(argc,argv); return Fl::run(); }
  • 7. 1 /** 2 * Um programa OpenGL simples que desenha um quadrado em uma janela GLUT. 3 */ 4 #include <glut.h> 5 6 // Função callback chamada para fazer o desenho 7 void Desenha(void) 8 { 9 // Inicializa o sistema de coordenadas 10 glMatrixMode(GL_MODELVIEW); 11 glLoadIdentity(); 12 13 // Limpa a janela de visualização com a cor de fundo especificada 14 glClear(GL_COLOR_BUFFER_BIT); 15 16 // Especifica que a cor corrente é amarela 17 // R G B 18 glColor3f(1.0f, 1.0f, 0.0f); 19 20 // Desenha um quadrado preenchido com a cor corrente 21 glBegin(GL_QUADS); 22 glVertex2i(100,150); 23 glVertex2i(100,100); 24 // Especifica que a cor corrente é vermelha 25 glColor3f(1.0f, 0.0f, 0.0f); 26 glVertex2i(150,100); 27 glVertex2i(150,150); 28 glEnd(); 29 30 // Executa os comandos OpenGL 31 glFlush(); 32 } 33 34 // Inicializa parâmetros de rendering 35 void Inicializa (void) 36 { 37 // Define a cor de fundo da janela de visualização como preta 38 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 39 } 40 41 // Função callback chamada quando o tamanho da janela é alterado 42 void AlteraTamanhoJanela(GLsizei w, GLsizei h) 43 { 44 // Evita a divisao por zero 45 if(h == 0) h = 1; 46 47 // Especifica as dimensões da Viewport 48 glViewport(0, 0, w, h); 49 50 // Inicializa o sistema de coordenadas 51 glMatrixMode(GL_PROJECTION); 52 glLoadIdentity(); 53 54 // Estabelece a janela de seleção (left, right, bottom, top) 55 if (w <= h) 56 gluOrtho2D (0.0f, 250.0f, 0.0f, 250.0f*h/w); 57 else 58 gluOrtho2D (0.0f, 250.0f*w/h, 0.0f, 250.0f); 59 } 60 61 // Programa Principal 62 int main(int argc, char* argv[]) 63 { 64 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 65 glutInitWindowSize(400,350); 66 glutInitWindowPosition(10,10); 67 glutCreateWindow("O primeiro quadrado ..."); 68 glutDisplayFunc(Desenha); 69 glutReshapeFunc(AlteraTamanhoJanela); 70 Inicializa(); 71 glutMainLoop(); 72 }
  • 8. 1 /** 2 * Exemplo de programa usando OpenGL + GLUT. 3 **/ 4 #include <cstdlib> 5 #include <glut.h> 6 7 //Função callback de desenho da janela de visualização 8 void Desenha(void) 9 { 10 //Limpa a janela de visualização com a cor branca 11 glClearColor(1.0,1.0,1.0,0); 12 glClear(GL_COLOR_BUFFER_BIT); 13 14 //Define a cor de desenho: vermelho 15 glColor3f(1.0,0.0,0.0); 16 17 //Desenha um triangulo no centro da janela com interpolaçao de cores 18 glBegin(GL_TRIANGLES); 19 glColor3f(1.0,0.0,0.0); glVertex3f(-0.5,-0.5,0); 20 glColor3f(0.0,1.0,0.0); glVertex3f( 0.0, 0.5,0); 21 glColor3f(0.0,0.0,1.0); glVertex3f( 0.5,-0.5,0); 22 glEnd(); 23 24 //Executa os comandos OpenGL 25 glFlush(); 26 } 27 28 //Função callback chamada para gerenciar eventos de teclas 29 void Teclado(unsigned char key, int x, int y) 30 { 31 if (key == 27 ) exit(EXIT_SUCCESS); 32 } 33 34 //Funcção responsável por inicializar parametros e variaveis 35 void Inicializa(void) 36 { 37 //Define a janela de visualização 2D 38 glMatrixMode(GL_PROJECTION); 39 gluOrtho2D(-1.0,1.0,-1.0,1.0); 40 glMatrixMode(GL_MODELVIEW); 41 } 42 43 //Programa Principal 44 int main(int argc, char* argv[]) 45 { 46 47 //Define o modo de operação da GLUT 48 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 49 50 //Especifica o tamanho inicial em pixels da janela GLUT 51 glutInitWindowSize(400,400); 52 53 //Cria a janela passando como argumento o título da mesma 54 glutCreateWindow("Primeiro Programa usando GLUT ..."); 55 56 //Registra a função callback de redesenho da janela de visualização 57 glutDisplayFunc(Desenha); 58 59 //Registra a função callback para tratamento das teclas ASCII 60 glutKeyboardFunc(Teclado); 61 62 //Chama a função responsável por fazer as inicializações 63 Inicializa(); 64 65 //Inicia o processamento e aguarda interações do usuário 66 glutMainLoop(); 67 68 return EXIT_SUCCESS; 69 } 70
  • 9. 1 // 2 // Tiny OpenGL demo program for the Fast Light Tool Kit (FLTK). 3 // 4 5 #include "config.h" 6 #include <FL/Fl.H> 7 #include <FL/Fl_Window.H> 8 #include <FL/Fl_Hor_Slider.H> 9 #include <FL/math.h> 10 11 #if HAVE_GL 12 13 #include <FL/gl.h> 14 #include <FL/Fl_Gl_Window.H> 15 16 class shape_window : public Fl_Gl_Window { 17 void draw(); 18 public: 19 int sides; 20 shape_window(int x,int y,int w,int h,const char *l=0); 21 }; 22 23 shape_window::shape_window(int x,int y,int w,int h,const char *l) : 24 Fl_Gl_Window(x,y,w,h,l) { 25 sides = 3; 26 } 27 28 void shape_window::draw() { 29 // the valid() property may be used to avoid reinitializing your 30 // GL transformation for each redraw: 31 if (!valid()) { 32 valid(1); 33 glLoadIdentity(); 34 glViewport(0, 0, w(), h()); 35 } 36 // draw an amazing graphic: 37 glClear(GL_COLOR_BUFFER_BIT); 38 glColor3f(.5,.6,.7); 39 glBegin(GL_POLYGON); 40 for (int j=0; j<sides; j++) { 41 double ang = j*2*M_PI/sides; 42 glVertex3f(cos(ang),sin(ang),0); 43 } 44 glEnd(); 45 } 46 47 #else 48 49 #include <FL/Fl_Box.H> 50 class shape_window : public Fl_Box { 51 public: 52 int sides; 53 shape_window(int x,int y,int w,int h,const char *l=0) 54 :Fl_Box(FL_DOWN_BOX,x,y,w,h,l){ 55 label("This demo doesnnot work without GL"); 56 } 57 }; 58 59 #endif 60 61 // when you change the data, as in this callback, you must call redraw(): 62 void sides_cb(Fl_Widget *o, void *p) { 63 shape_window *sw = (shape_window *)p; 64 sw->sides = int(((Fl_Slider *)o)->value()); 65 sw->redraw(); 66 } 67 68 int main(int argc, char **argv) { 69 70 Fl_Window window(300, 330); 71 72 // the shape window could be it's own window, but here we make it
  • 10. 73 // a child window: 74 shape_window sw(10, 10, 280, 280); 75 // make it resize: 76 window.resizable(&sw); 77 // window.size_range(300,330,0,0,1,1,1); 78 // add a knob to control it: 79 Fl_Hor_Slider slider(50, 295, window.w()-60, 30, "Sides:"); 80 slider.align(FL_ALIGN_LEFT); 81 slider.callback(sides_cb,&sw); 82 slider.value(sw.sides); 83 slider.step(1); 84 slider.bounds(3,40); 85 86 window.end(); 87 window.show(argc,argv); 88 89 return Fl::run(); 90 } 91 92 // 93 // End of "$Id: shape.cxx 5845 2007-05-20 00:01:06Z mike $". 94 // 95
  • 11. 1 /** 2 * Programa exemplo utilizando OpenGL + GLUT 3 * Parametros de linkagem : -lGL -lglut 4 */ 5 6 #include <GL/glut.h> 7 8 void initFunc(void) 9 { 10 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 11 glClearDepth(1.0f); 12 glEnable(GL_DEPTH_TEST); 13 glDepthFunc(GL_LEQUAL); 14 } 15 16 void reshapeFunc(int width, int height) 17 { 18 float aspect = 0.0f; 19 glViewport(0, 0, width, height); 20 21 glMatrixMode(GL_PROJECTION); 22 glLoadIdentity(); 23 24 height = (height == 0 ? 1 : height); 25 aspect = (float) width / (float) height; 26 27 gluPerspective (45.0f, aspect, 0.01f, 100.0f); 28 29 glMatrixMode(GL_MODELVIEW); 30 glLoadIdentity(); 31 } 32 33 void displayFunc(void) 34 { 35 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 36 glLoadIdentity(); 37 38 gluLookAt(2.0f, 2.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); 39 40 glLineWidth(2.0f); 41 glColor3f(0.15f, 0.45f, 0.15f); 42 glutWireCube(1.0f); 43 glColor3f(0.5f, 1.0f, 0.5f); 44 glutSolidCube(1.0f); 45 46 glutSwapBuffers(); 47 } 48 49 int main(int argc, char* argv[]) 50 { 51 glutInit(&argc, argv); 52 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); 53 glutInitWindowSize(800, 600); 54 glutInitWindowPosition(50, 100); 55 glutCreateWindow("OpenGL Cube"); 56 glutReshapeFunc(reshapeFunc); 57 glutDisplayFunc(displayFunc); 58 glutIdleFunc(displayFunc); 59 initFunc(); 60 glutMainLoop(); 61 return 0; 62 } 63
  • 12. 1C:Documents and SettingsAdministradorDesktop_exemplos.openglMySecondGlutCube.cxx //#include <GL/glut.h> #include "glut.h" #include <cstdlib> /*Estrutura que compoe o material do cubo e os efeitos de iluminacao*/ typedef struct {float ambiente[4]; float diffuse[4]; float specular[4]; float shininess[1]; } Material; Material brass={{0.33f, 0.22f, 0.03f, 1}, {0.78f, 0.57f, 0.11f, 1}, {0.99f, 0.91f, 0.81f, 1}, {27.8f}}; void setMaterial(Material* p) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, p->ambiente); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, p->diffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, p->specular); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, p->shininess); } void displayCall(void) { glClearColor(0.4f,0.4f,0.4f,1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); setMaterial(&brass); glutSolidCube(1); glFlush(); } /* Callback de REDISPLAY */ void reshapeCall(int width, int height) { glViewport(0, 0, (GLsizei)(width), (GLsizei)(height)); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,4./3,0.5,10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(1.5,1.5,1.2, 0,0,0, 0,0,1); } /* Callback de RESHAPE */ void keyboardCall(unsigned char key, int x, int y) { switch (key) { case 27: exit(EXIT_SUCCESS); } }/* Callback de KEYBOARD */ void initLight( ) { float position[]={ 0.5f,2.f,0.f,1.f}; float low[]={0.2f,0.2f,0.2f,1}; float white[]={1,1,1,1}; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLightfv(GL_LIGHT0, GL_AMBIENT, low); glLightfv(GL_LIGHT0, GL_DIFFUSE, white); glLightfv(GL_LIGHT0, GL_SPECULAR, white); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } int main(int argc, char **argv) { glutInit(&argc, argv); /* Inicializando a GLUT */ glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(640, 480); glutCreateWindow("FCG:Simple Light"); glutDisplayFunc(displayCall); glutReshapeFunc(reshapeCall); glutKeyboardFunc(keyboardCall); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); initLight(); /* Inicializando a luz e o material */ glutMainLoop(); /* GLUT main loop */ return 0; }