OpenGL

API per scrivere applicazioni che producono computer grafica 2D e 3D

Template:Da tradurre

OpenGL (da Open Graphics Library, ossia libreria aperta di grafica) è una specifica che definisce una API per più linguaggi e per più piattaforme per scrivere applicazioni che producono computer grafica 3D e 2D. L'interfaccia consiste in circa 250 diverse chiamate di funzione che si possono usare per disegnare complesse sxcene tridimensionali da semplici primitive. È molto usato nell'industria dei videogiochi (nella quale compete con Direct3D su Microsoft Windows). OpenGL viene usato anche per applicazioni di CAD, realtà virtuale, e CAE.

Esistono implementazioni efficienti di OpenGL (che sfruttano in modo più o meno completo le GPU) per Microsoft Windows, molte piattaforme Unix, la Playstation 3, e il Mac OS. Queste implementazioni vengono normalmente fornite dai costruttori di dispositivi video e si affidano pesantemente sull'hardware fornito dal costruttore. La libreria open source Mesa è un'API grafica basata solamente su librerie software che è compatibile con OpenGL. Tuttavia, a causa della licenza, può solo sostenere di di essere un'API "molto simile".

La specifica di OpenGL è supervisionata dall'OpenGL Architecture Review Board (ARB), che si è formato nel 1992. L'ARB consiste in un insieme di aziende interessate a creare un'API coerente e ampiamente disponibile. Secondo il sito Web ufficiale di OpenGL, i membri votanti dell'ARB nel novembre del 2004 erano: 3Dlabs, Apple Computer, ATI Technologies, Dell, Evans & Sutherland, Hewlett-Packard, IBM, Intel, Matrox, NVIDIA, SGI e Sun Microsystems. (Microsoft, uno dei membri fondatori, se n'è andato nel marzo del 2003.)

Estensioni

Lo standard OpenGL permette ai produttori individuali di fornire funzionalità aggiuntive tramite le estensioni man mano che vengono create nuove tecnologie. Un'estensione viene poi distribuita in due parti: come file di intestazione che contiene i prototipi di funzione dell'estensione, e come driver del produttore. Ogni produttore ha un'abbreviazione alfabetica che viene usata nel denominare le loro nuove funzioni e costanti. Per esempio, l'abbreviazione di NVIDIA (NV) viene usata nel definire la loro funzione propriataria glCombinerParameterfvNV() e la loro costante GL_NORMAL_MAP_NV. Può succedere che più di un produttore si accordi per implementare la stessa funzionalità estesa.

In tal caso, si usa l'abbreviazione EXT. Può anche accadere che l'ARB approvi l'estensione. Allora essa diventa nota come una estensione standard, e si usa l'abbreviazione ARB. La prima estensione ARB è stata la GL_ARB_multitexture. Avendo seguito il percorso di promozione per le estensioni ufficiali, la multitexture non è più un'estensione ARB implementata opzionalmente, ma è stata integrata nell'API base di OpenGL a partire dalla versione 1.4. Le specifiche per quasi tutte le estensioni si trovano nel repository ufficiale delle estensioni: [1].

Varie librerie sono state costruite sopra OpenGL per fornire funzionalità non disponibili in OpenGL stesso:

In particolare, la libreria OpenGL Performer, sviluppata da SGI e disponibile per IRIX, Linux, e varie versioni di Microsoft Windows, si appoggia a OpenGL per abilitare la creazione di applicazioni di simulazione visuale in real-time.

Binding

Al fine di imporre le sue caratteristiche multi-linguaggio e multi-piattaforma, vari bindings e port sono stati sviluppati per OpenGL in molti linguaggi. Tra i più notevoli, la libreria Java 3D può appoggiarsi su OpenGL per sfruttare l'accelerazione hardware. Molto recentemente, Sun ha rilasciato le versioni beta del sistema JOGL, che fornisce binding ai comandi OpenGL in C, diversamente da Java 3D che non fornisce tale supporto a basso livello. la pagina OpenGL ufficiale [2] elenca vari bindings per i linguaggi Java, Fortran 90, Perl, Pike, Python, Ada, e Visual Basic. I binding sono disponibili anche per C++ e C#, vedere [3].

Funzionalità ad alto livello

OpenGL è sato progettato per essere di solo output: fornisce solamente funzioni di rendering. L'API di base non contempla la gestione di finestre, l'audio, la stampa, la tastiera, il mouse, né altri dispositivi di input. Per quanto questo può sembrare restrittivo, permette al codice di rendering di essere completamente indipendente dal sistema operativo su cui funziona, permettendo lo sviluppo di codice indipendente dalla piattaforma. Tuttavia, per consentire un'interazione con il sistema ospitante, è necessario integrare il software con il sistema a finestre nativo. Ciò viene effettuato tramite le seguenti API aggiuntive:

In aggiunta le librerie GLUT e SDL forniscono funzionalità per una gestione elementare delle finestre con OpenGL, in manera portabile. Mac OS X ha tre API per ottenere il supporto di OpenGL: AGL per Carbon, NSOpenGL per Cocoa e CGL per l'accesso diretto.

History

OpenGL evolved from (and is very similar in style to) SGI's earlier 3D interface, IRIS GL. One of the restrictions of IRIS GL was that it only provided access to features supported by the underlying hardware. If the graphics hardware did not support a feature, then the application could not use it. OpenGL overcame this problem by providing support in software for features unsupported by hardware, allowing applications to use advanced graphics on relatively low-powered systems. The Fahrenheit project was a joint effort between Microsoft, SGI, and Hewlett-Packard with the goal of unifying the OpenGL and Direct3D interfaces. It initially showed some promise of bringing order to the world of interactive 3D computer graphics APIs, but due to financial constraints at SGI and general lack of industry support, it has since been abandoned.

Future in Microsoft Windows

On 6th August [2005], Microsoft's intentions for OpenGL support in Windows Vista were revealed on in an Opengl.org news announcement:

Microsoft's current plan for OpenGL on Windows Vista is to layer OpenGL over Direct3D in order to use OpenGL with a composited desktop to obtain the Aeroglass experience. If an OpenGL ICD is run - the desktop compositor will switch off - significantly degrading the user experience.

In practice this means for OpenGL under Aeroglass:

OpenGL performance will be significantly reduced - perhaps as much as 50%

OpenGL on Windows will be fixed at a vanilla version of OpenGL 1.4

No extensions will be possible to expose future hardware innovations

It would be technically straightforward to provide an OpenGL ICD within the full Aeroglass experience without compromising the stability or the security of the operating system. Layering OpenGL over Direct3D is a policy more than a technical decision.

As a result, the future of OpenGL as a mainstream library for computer and video games now looks precarious. Microsoft have taken the decision not to release the information necessary to allow third parties (such as those at NVidia, ATI or the other large graphics card manufacturers) to develop replacement drivers, leaving no way to avoid the 50% speed drop. A 3Dlabs employee states in the same Opengl.org thread:

This information came from the OpenGL BOF held at Siggraph 2005 in LA this last Wednesday evening. This was confirmed at the BOF by NVIDIA, ATI and us (3Dlabs).

As soon as an [installable client driver] is loaded the composited desktop is turned off on Windows Vista. If you want the composited desktop Aeroglass experience, you will need to make your application go through Microsoft's OpenGL implementation, which is layered on top of DirectX. As pointed out earlier, this layering can have performance implications. Their implementation supports OpenGL version 1.4 only, without extension support.

We believe it possible to provide an ICD with full composited desktop support while adhering to the stability and security requirements in Windows Vista. But we need Microsoft's help in doing so.

Therefore, as mentioned before, please let your contact in the ISV or IHV or OEM community know how you feel about this and spread the word.

For some more information, you can browse these Microsoft Winhec slides:

"Windows Graphics Overview [WinHEC 2005; 171 KB]" http://download.microsoft.com/download/9/8/f/98f3fe47-dfc3-4e74-92a3-088782200fe7/TWPR05007_WinHEC05.ppt

"Advances in Display and Composition Architecture for Windows [WinHEC 2005; 422 KB]" http://download.microsoft.com/download/9/8/f/98f3fe47-dfc3-4e74-92a3-088782200fe7/TWPR05005_WinHEC05.ppt

Regards,

Barthold

3Dlabs

An installable client driver is the glue provided by a card manufacturer to connect Windows and your graphics card.

OpenGL 2.0

OpenGL 2.0 was conceived of by 3Dlabs to address concerns that OpenGL was stagnating and lacked a strong direction. 3Dlabs proposed a number of major additions to the standard, the most significant of which was GLSL (the OpenGL Shading Language). This would enable the programmer to replace the OpenGL fixed-function vertex and fragment pipelines with shaders written in a C-like language. GLSL was notable for making relatively few concessions to the limitations of the hardware then available; this harked back to the earlier tradition of OpenGL setting ambitious, forward-looking targets for new 3D accelerators rather than merely tracking the state of currently available hardware. The final OpenGL 2.0 spec [4] included support for GLSL, but omitted many of the other features originally proposed - these were deferred to future versions of OpenGL, although some are now available as extensions.

Further reading

  • Fosner, Ron: OpenGL Programming for Windows 95 and Windows NT, Addison Wesley, ISBN 0-201-40709-4
  • OpenGL Architecture Review Board, et al: OpenGL Reference Manual: The Official Reference Document to OpenGL, Version 1.4, Addison Wesley, ISBN 0-321-17383-X
  • Rost, Randi J.: OpenGL Shading Language, Addison Wesley, ISBN 0-321-19789-5
  • OpenGL Architecture Review Board, et al: OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 1.4, Fourth Edition, Addison Wesley, ISBN 0-321-17348-1

Programmer resources