OpenGL/fr

From Free Pascal wiki
Revision as of 13:37, 9 December 2016 by E-ric (talk | contribs) (→‎Third party OpenGL units)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Deutsch (de) English (en) français (fr) 日本語 (ja) português (pt) русский (ru) Tiếng Việt (vi) 中文(中国大陆)‎ (zh_CN)

OpenGL (Open Graphics Library) est une plate-forme croisé avec une interface de programmation(API) pour produire des images de synthèse 3D. La plupart des cartes vidéo modernes fournissent une accélération matérielle OpenGL, ce qui fait que OpenGL est une bonne solution pour l'écriture logiciel avancé avec des graphiques.

Les unités OpenGL dans Free Pascal

L'interface OpenGL de FreePascal se compose des unités suivantes:

  • gl: Cette unité contient les principales fonctionnalités telles que le dessin de polygones, l'application de transformations, le réglage des couleurs et des matériaux,... Les procédures commencent toujours avec la préposition "gl".
  • glu: Cette unité contient les outils OpenGL. Même si elle a des fonctions utiles, cette unité n'est pas nécessaire puisque vous pouvez implémenter toutes les procédures glu avec les fonctionnalités de l'unité gl. Les procédures commencent toujours avec la préposition "glu".
  • glext: Les fournisseurs de cartes peuvent fournir des fonctions supplémentaires grâce à des extensions. Utilisez cette unité pour utiliser ces extensions.

    The functionality specific to higher OpenGL versions (1.2 and later) is available in this unit as well. Initializing this functionality is similar to initializing normal OpenGL extensions: just call Load_GL_version_X_Y function. If your OpenGL library version is older than X.Y, Load_GL_version_X_Y will return false.

  • glut: Cette unité contient les outils pour créer une fenêtre OpenGL. Bien qu'il s'agisse d'une unité multi-plateforme, la plupart des systèmes Windows ne disposent pas de la bibliothèque glut (glut dll) par defaut.
  • glx: glx provides functionality to set up an OpenGL window in an x window system. Procedures always start with the preposition "glx". Obviously, you cannot use this unit on non-x window systems such as Windows.

OpenGL units in Lazarus

Lazarus includes a TOpenGLControl - a LCL control with an OpenGL context. The lazarus package LazOpenGLContext can be found lazarus/components/opengl/lazopenglcontext.lpk. An example can be found in lazarus/examples/openglcontrol/openglcontrol_demo.lpi.

Third party OpenGL units

  • GLScene is a Lazarus package with lots of extra features for OpenGL applications.
  • Castle Game Engine allows you to navigate and render 3D worlds (in VRML, X3D and other 3D formats).

Tutorial

OpenGL Tutorial

Q/A using OpenGL binding

Q: I don't understand why the ARB version does not work. AFAIK it has the same entry points as the core functionality and OpenGL versions are required to support the ARB version of functions even if the non ARB version is in the core now.

A: No. OpenGL doesn't have to support the extension entry points, even when it supports the same functionality in core already. Vendor is free to remove the extensions, and support only the "core" functions.

Also, sometimes when functionality is promoted from ARB extension into core it's slightly changed (although in 99% cases it stays the same). Example is the GLSL shaders, that expose (very slightly) different API through ARB extensions and through core 2.0 specification.

Basically, what is exposed through extensions is completely orthogonal to what is exposed through core functionality, so they should be initialized separately. In particular cases, you can make tricks like

 if glIsBufferARB = nil then glIsBufferARB := @glIsBuffer;

but this should be left to the final programmer that knows that "ARB_vertex_buffer_object" behavior is identical to how it works in core.


Go to back Packages List