Professional Documents
Culture Documents
• Sistema gráfico :
Librerías Gráficas – Modelos + Visualización
Introducción a OpenGL • Visualización:
– Uso de hardware específico (2D o 3D)
– Implementación a través de librerías
1
... ...
• Gestión imágenes 3D • (... Gestión imágenes 3D)
– “Bajo nivel” – “ Alto nivel”
• Tareas • Tareas
– Gestión “en serie” de los elementos de la escena – Gestión global de los elementos de la escena
– Elementos de la escena – Árbol escena
» Primitivas gráficas – Carga/descarga de memoria
» “Atributos” (" edición imágenes) – Gestión elementos no visibles
– Variables de estado – Elección del modelo geométrico: Nivel detalle, Textura
Generación imagen – Elección de la técnica de presentación (rendering)
• Sistemas • Sistemas
– OpenGL – Inventor
– Direct 3D – Performer
– Java 3D – ( Fahrenheit )
– “ Alto nivel” … – Hewlett Packard
DirectX - Introducción
DirectX - Introducción • Objetivos de DirectX
– Desarrollo de Aplicaciones Windows de alto
• Componentes incluidos en DirectX rendimiento
– Nos permiten desarrollar aplicaciones de alto • Tarjetas aceleradoras
rendimiento y en tiempo real • Plug´n Play
• API Direct Play • Servicios de comunicaciones construidos bajo
• API Direct I nput Windows
• API Direct Sound • Recursos instalados en el sistema
• API Direct Draw – Utilización del nuevo hardware implementado
• API Direct 3D
2
DirectX - Introducción
• DirectX & COM (Component Object DirectX - DirectDraw
Model)
• Obj et o: caja negra que representa el hardware y
• Se encarga del manejo de la memoria de vídeo
requiere comunicación con las aplicaciones a través • Proporciona herramientas para
de una interface. – Manipulación de múltiples buffers de vídeo
• Mét odo: comandos enviados y recibidos por el – Acceso directo a la memoria de vídeo
objeto a través de la interface COM – Page flipping
– Ej.: Método Get DisplayMode es enviado a – Back Buffering
través de la interface I Direct Draw2 para – Manejo de la paleta gráfica
tomar el valor de la actual resolución de la – Clipping
pantalla mediante el objeto Direct Draw
DirectX - DirectDraw
DirectX - DirectDraw
• Conceptos Gráficos y Técnicos
– Bitmaps
• Tipos de objetos – Superficies de dibujo (buffers)
– I Direct Draw – Page Flipping y Back Buffering
– I Direct DrawSurf ace – Rectángulos
– Sprites
– I Direct DrawPalet t e
– Niveles cooperativos
– I Direct DrawClipper – Modos de vídeo
– I Direct DrawVideoPort – Buffers
– Overlays
– Clippers
– Video Ports
3
DirectX - Direct3D
DirectX - DirectPlay • Interfaz gráfica para hardware 3D
• Simplifica el acceso de las aplicaciones a
– Permitir gráficos tridimensionales interactivos
los servicios de comunicación en aplicaciones de Windows
• Otorga independencia para la creación de • 2 Modos:
servidores de juegos – Inmediato
• Comunicaciones • API 3D de bajo nivel
– Peer-to-Peer • Independiente del dispositivo
– Cliente/Servidor • Programadores experimentados
– Retenido (Obsoleta)
• Desarrollo rápidos
• Capa superior del inmediato
4
Se convierte en standard porque …
Ventajas de OpenGL
• Industry standard
An independent consortium, the OpenGL Architecture Review Board, guides
the OpenGL specification. With broad industry support, OpenGL is the only
• No trata de hacer demasiadas cosas: truly open, vendor-neutral, multiplatform graphics standard.
– Sólo renderiza la imagen, no gestiona ventanas, etc... • Stable
OpenGL implementations have been available for more than seven years on
– No posee animación de alto nivel, modelado, sonido, a wide variety of platforms. Additions to the specification are well controlled,
etc... and proposed updates are announced in time for developers to adopt changes.
Backward compatibility requirements ensure that existing applications do not
• Hace lo suficiente: become obsolete.
• Reliable and portable
– Efectos de renderizado útiles y altas prestaciones All OpenGL applications produce consistent visual display results on any
OpenGL API-compliant hardware, regardless of operating system or
• Fue promovido por empresas líderes en el sector windowing system.
(SGI, Microsoft, etc)
5
Capacidades de OpenGL Capacidades de OpenGL
• Accumulation buffer A buffer in which multiple rendered frames can • Double buffering. Used to provide smooth animation of objects. Each
be composited to produce a single blended image. Used for effects successive scene of an object in motion can be constructed in the back
such as depth of field, motion blur, and full-scene anti-aliasing. or "hidden" buffer and then displayed. This allows only complete
• Alpha blending. Provides a means to create transparent objects. images to ever be displayed on the screen.
• Automatic rescaling of vertex normals changed by the modeling • Feedback. A mode where OpenGL will return the processed geometric
matrix. information (colors, pixel positions, and so on) to the application as
• BGRA pixel formats and packed pixel formats to directly support compared to rendering them into the frame buffer.
more external file and hardware frame buffer types. • Level of detail control for mipmap textures to allow loading only a
• Color-index mode. Color buffers store color indices rather than red, subset of levels.
green, blue, and alpha color components. • Materials lighting and shading. The ability to accurately compute the
• Immediate mode. Execution of OpenGL commands when they're color of any point given the material properties for the surface.
called, rather than from a display list. • Pixel operations. Storing, transforming, mapping, zooming.
• Display list. A named list of OpenGL commands. The contents of a • Polynomial evaluators. To support non-uniform rational B-splines
display list may be preprocessed and might therefore execute more (NURBS).
efficiently than the same set of OpenGL commands executed in • Primitives. A point, line, polygon, bitmap, or image.
immediate mode. • Raster primitives. Bitmaps and pixel rectangles.
• glut.lib DevStudio\Vc\lib
– Permite la portabilidad de las aplicaciones sobre
• glut.h DevStudio\Vc\include\gl
distintos sistemas de ventanas
6
Arquitectura de APIs de OpenGL Detalles de programación
• Añadir las librerías opengl32.lib glu32.lib
glut32.lib
– Project : settings : link : Object/Library Modules
• Ficheros a incluir
– #include <GL/gl.h>
– #include <GL/glu.h>
– If you are using GLUT for managing your window
manager
• #include <GL/glut.h>
• Note that glut.h includes gl.h, glu.h, and glx.h automatically,
so including all three files is redundant.
7
... (gl) ... (glut)
• pure "output", but lacks connection with display
• Window system independent management
– glClear (command)
– “ window” management
– glClearColor (state) • glutInitDisplayModeg( GLUT_RGB | GLUT_SINGLE );
– glBegin glEnd • glutInitWindowSize( WIDTH, HEIGHT );
– glVertex* (geometry) • glutInitWindowPosition ( 550, 350 );
– glColor* (attribute, state) • glutCreateWindow(“ Basic Draw");
– glFlush, glFinish (command stack & processing) – “ input” : event handling
• similar to : The X Window system, MOTIF, MFF, ...
– (debbuging)
• (event)
– (mapping from modelling coord. to display coordinates) • void Display(void); (callback function)
– (aspect ratio) • glutDisplayFunc( Display ); (binding event & callback)
– (need for a transformation management system) – void Display ( void )
• glutMainLoop(); (dispatching events)
Primitivas
...
• Otras primitivas disponibles
– Objetos (uso auxiliar, no para crear modelos)
– Vertex arrays
– Display lists
– Evaluators, NURBS, etc
• Texto
– No existe primitiva
– Usar texturas, problema aliasing
8
GL_ACCUM_BUFFER_BIT accum-buffer
GL_ALL_ATTRIB_BITS --
Grupos de GL_COLOR_BUFFER_BIT
GL_CURRENT_BIT
color-buffer
current Agrupamiento
atributos
GL_DEPTH_BUFFER_BIT depth-buffer
GL_ENABLE_BIT enable
• Arrays
GL_EVAL_BIT eval
GL_FOG_BIT fog – Evitar pérdidas de tiempo en llamadas a funciones
GL_HINT_BIT
GL_LIGHTING_BIT
hint
lighting
• Display Lists
GL_LINE_BIT line – Ídem
GL_LIST_BIT list
– La información puede está preprocesada
GL_PIXEL_MODE_BIT pixel
GL_POINT_BIT point – Almacenar en el procesador gráfico para aliviar el bus
GL_POLYGON_BIT polygon • Workstations
GL_POLYGON_STIPPLE_BI polygon-stipple
T
• PCs
GL_SCISSOR_BIT scissor
GL_STENCIL_BUFFER_BIT stencil-buffer
GL_TEXTURE_BIT texture
GL_TRANSFORM_BIT transform
GL_VIEWPORT_BIT viewport
Links Interesantes
• ww w.opengl.org Official sit e of
OpenGL
• nehe.gam edev.net NeHe, various
OpenGL t ut orials
• rom ka.dem onews.com Rom ka,
various OpenGL t ut orials
• Nexe.gam edev.net sam e as Nehe
for Dirext X