A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

Sistemas de Interfaces com o Usuário e OpenGL/Glut

Apresentações semelhantes


Apresentação em tema: "Sistemas de Interfaces com o Usuário e OpenGL/Glut"— Transcrição da apresentação:

1 Sistemas de Interfaces com o Usuário e OpenGL/Glut
Computação Gráfica Interativa - Gattass 3/25/2017 Sistemas de Interfaces com o Usuário e OpenGL/Glut Interfaces Gráficas

2 Objetos de comuns interface
Computação Gráfica Interativa - Gattass 3/25/2017 Objetos de comuns interface MGattass Interfaces Gráficas

3 Computação Gráfica Interativa - Gattass
3/25/2017 Modelo de Programação Toolkit de Interface (GLUT, SDK, ... ) Programa Gráfico- Interativo Sistema Gráfico (OpenGL, Direct3D, ...) Dispositivos Computador Usuário MGattass Interfaces Gráficas

4 Programação Convencional
Computação Gráfica Interativa - Gattass 3/25/2017 Programação Convencional inicio Programação Convencional Os comandos são executados segundo uma ordem pré-estabelecida e sequencial. captura dados processa dados fim MGattass Interfaces Gráficas

5 Eventos típicos (WIMP)
Computação Gráfica Interativa - Gattass 3/25/2017 Eventos típicos (WIMP) KeyPress KeyRelease ButtonPress ButtonRelease Motion LeaveNotify EnterNotify WindowExposure (repaint) Resize Timer Idle Janela A Janela B Janela C MGattass Interfaces Gráficas

6 Computação Gráfica Interativa - Gattass
3/25/2017 Modelo de Call Backs Processa Evento Tipo 1 Eventos Examina eventos, chama os módulos de processamento Processa Evento Tipo 2 Motif Visual Basic Glut IUP ... Processa Evento Tipo 3 Programa de Aplicação MGattass Interfaces Gráficas

7 Computação Gráfica Interativa - Gattass
3/25/2017 Visual Basic Interfaces Gráficas

8 OpenGL/GLUT #include <glut.h> #include <image.h>
/* Variaveis globais */ typedef struct window_impl { int width; int height;} Window; Window window; IMAGE pic; int main(int argc, char **argv) { pic = imgReadBMP(“teste.bmp”); imgGetDimensions(pic, &window.width, &window.height); /* GLUT - Initialization */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(window.width, window.height); glutCreateWindow("CG-T1"); /* Registrando callbacks */ glutDisplayFunc(displayCall); glutReshapeFunc(reshapeCall); glutMouseFunc(mouseCall); glutMotionFunc(motionCall); glutKeyboardFunc(keyboardCall); glutIdleFunc(idleCall); /* GLUT main loop */ glutMainLoop(); return 0; } MGattass

9 Exemplo simples da GLUT
void displayCall(void) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); imgDraw(pic); glFlush(); glutSwapBuffers(); } void reshapeCall(int width, int height) { glViewport(0, 0, (GLsizei)width, (GLsizei)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D (0.0, (GLsizei)width, 0.0, (GLsizei)height); glMatrixMode(GL_MODELVIEW); window.width = width; window.height = height; } MGattass

10 OpenGL/IUP – Exemplo Simples
void main(void) { IupOpen(); IupGLCanvasOpen(); if ( init() ) IupMainLoop(); IupClose(); }

11 Elementos de interface
Canvas 1 Canvas 2 HBox Eventos: RESIZE, REPAINT, BUTTON

12 Elementos de interface
w h xv yv int resize_cb(Ihandle *self, int w, int h) { IupGLMakeCurrent(self); glViewport(0,0,w,h); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); gluOrtho2D (0., w, 0., h); glRasterPos2d(0.0,0.0); return IUP_DEFAULT; } xe ye ze w h Evento: RESIZE

13 Elementos de interface
int repaint_cb1(Ihandle *self) { IupGLMakeCurrent(self); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); imgGLDrawPixels(image1); glFlush(); return IUP_DEFAULT; } xe ye ze w h Evento: REPAINT void imgGLDrawPixels(Image image) { glDrawPixels (image->width, image->height, GL_RGB,GL_UNSIGNED_BYTE, (GLubyte *) image->buf); }


Carregar ppt "Sistemas de Interfaces com o Usuário e OpenGL/Glut"

Apresentações semelhantes


Anúncios Google