Unit al5opengl

Uses
Classes, Interfaces, Objects and Records
Types
Constants
Variables

Description

OpenGL integration.

You can disable the detection of any OpenGL extension by Allegro with a section like this in allegro5.cfg:

[opengl_disabled_extensions]
  GL_ARB_texture_non_power_of_two=0
  GL_EXT_framebuffer_object=0

Any extension which appears in the section is treated as not available (it does not matter if you set it to 0 or any other value).

Overview

Functions and Procedures

function al_get_opengl_version: AL_UINT32; CDECL; external ALLEGRO_LIB_NAME;
function al_have_opengl_extension (const extension: AL_STR): AL_BOOL; CDECL; external ALLEGRO_LIB_NAME;
function al_get_opengl_proc_address (const name: AL_STR): AL_VOIDptr; CDECL; external ALLEGRO_LIB_NAME;
function al_get_opengl_texture (bitmap: ALLEGRO_BITMAPptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;
procedure al_remove_opengl_fbo (bitmap: ALLEGRO_BITMAPptr); CDECL; external ALLEGRO_LIB_NAME;
function al_get_opengl_fbo (bitmap: ALLEGRO_BITMAPptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;
procedure al_get_opengl_texture_size (bitmap: ALLEGRO_BITMAPptr; out w, h: AL_INT); CDECL; external ALLEGRO_LIB_NAME;
procedure al_get_opengl_texture_position (bitmap: ALLEGRO_BITMAPptr; out u, v: AL_INT); CDECL; external ALLEGRO_LIB_NAME;
function al_get_opengl_program_object (shader: ALLEGRO_SHADERptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;
procedure al_set_current_opengl_context (display: ALLEGRO_DISPLAYptr); CDECL; external ALLEGRO_LIB_NAME;
function al_get_opengl_variant: ALLEGRO_OPENGL_VARIANT; CDECL; external ALLEGRO_LIB_NAME;

Description

Functions and Procedures

function al_get_opengl_version: AL_UINT32; CDECL; external ALLEGRO_LIB_NAME;

Returns the OpenGL or OpenGL ES version number of the client (the computer the program is running on), for the current display. "1.0" is returned as $01000000, "1.2.1" is returned as $01020100, and "1.2.2" as $01020200 ,etc.

A valid OpenGL context must exist for this function to work, which means you may not call it before al_create_display.

See also
al_get_opengl_variant
Returns the variant or type of OpenGL used on the running platform.
function al_have_opengl_extension (const extension: AL_STR): AL_BOOL; CDECL; external ALLEGRO_LIB_NAME;

This function is a helper to determine whether an OpenGL extension is available on the given display or not.

Example

packedpixels := al_have_opengl_extension ('GL_EXT_packed_pixels');

If packedpixels is True then you can safely use the constants related to the packed pixels extension.

Returns

True if the extension is available; False otherwise.

See also
al_get_opengl_proc_address
Helper to get the address of an OpenGL symbol.
function al_get_opengl_proc_address (const name: AL_STR): AL_VOIDptr; CDECL; external ALLEGRO_LIB_NAME;

Helper to get the address of an OpenGL symbol.

Example

How to get the function glMultiTexCoord3fARB that comes with ARB's Multitexture extension:

TYPE
{ Define the type of the function. }
  MULTI_TEX_FUNC: PROCEDURE (a: GLenum; b, c, d: GLfloat); CDECL;
VAR
{ Declare the function pointer. }
  glMultiTexCoord3fARB: MULTI_TEX_FUNC;
BEGIN
{ get the address of the function. }
  glMultiTexCoord3fARB := MULTI_TEX_FUNC (al_get_opengl_proc_address ('glMultiTexCoord3fARB'))
END;

If glMultiTexCoord3fARB is not Nil then it can be used as if it has been defined in the OpenGL core library.

Parameters
name
The name of the symbol you want to link to.
Returns

A pointer to the symbol if available or Nil otherwise.

See also
al_have_opengl_extension
This function is a helper to determine whether an OpenGL extension is available on the given display or not.
function al_get_opengl_texture (bitmap: ALLEGRO_BITMAPptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;

Returns the OpenGL texture id internally used by the given bitmap if it uses one, else 0.

Example

Bitmap := al_load_bitmap ('my_texture.png');
Texture := al_get_opengl_texture (Bitmap);
IF texture <> NIL THEN glBindTexture (GL_TEXTURE_2D, Texture);

procedure al_remove_opengl_fbo (bitmap: ALLEGRO_BITMAPptr); CDECL; external ALLEGRO_LIB_NAME;

Explicitly frees an OpenGL FBO created for a bitmap, if it has one. Usually you do not need to worry about freeing FBOs, unless you use al_get_opengl_fbo.

See also
al_get_opengl_fbo
Returns the OpenGL FBO id internally used by the given bitmap if it uses one, otherwise returns zero.
al_set_target_bitmap
This function selects the bitmap to which all subsequent drawing operations in the calling thread will draw to.
function al_get_opengl_fbo (bitmap: ALLEGRO_BITMAPptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;

Returns the OpenGL FBO id internally used by the given bitmap if it uses one, otherwise returns zero. No attempt will be made to create an FBO if the bitmap is not owned by the current display.

The FBO returned by this function will only be freed when the bitmap is destroyed, or if you call al_remove_opengl_fbo on the bitmap.

Note: In Allegro 5.0.0 this function only returned an FBO which had previously been created by calling al_set_target_bitmap. It would not attempt to create an FBO itself. This has since been changed.

See also
al_remove_opengl_fbo
Explicitly frees an OpenGL FBO created for a bitmap, if it has one.
al_set_target_bitmap
This function selects the bitmap to which all subsequent drawing operations in the calling thread will draw to.
procedure al_get_opengl_texture_size (bitmap: ALLEGRO_BITMAPptr; out w, h: AL_INT); CDECL; external ALLEGRO_LIB_NAME;

Retrieves the size of the texture used for the bitmap. This can be different from the bitmap size if OpenGL only supports power-of-two sizes or if it is a sub-bitmap.

Returns

True on success, False on failure. Zero width and height are returned if the bitmap is not an OpenGL bitmap.

See also
al_get_opengl_texture_position
Returns the u/v coordinates for the top/left corner of the bitmap within the used texture, in pixels.
procedure al_get_opengl_texture_position (bitmap: ALLEGRO_BITMAPptr; out u, v: AL_INT); CDECL; external ALLEGRO_LIB_NAME;

Returns the u/v coordinates for the top/left corner of the bitmap within the used texture, in pixels.

See also
al_get_opengl_texture_size
Retrieves the size of the texture used for the bitmap.
function al_get_opengl_program_object (shader: ALLEGRO_SHADERptr): GLuint; CDECL; external ALLEGRO_LIB_NAME;

Returns the OpenGL program object associated with this shader, if the platform is ALLEGRO_SHADER_GLSL. Otherwise, returns 0.

procedure al_set_current_opengl_context (display: ALLEGRO_DISPLAYptr); CDECL; external ALLEGRO_LIB_NAME;

Make the OpenGL context associated with the given display current for the calling thread. If there is a current target bitmap which belongs to a different OpenGL context, the target bitmap will be changed to Nil.

Normally you do not need to use this function, as the context will be made current when you call al_set_target_bitmap or al_set_target_backbuffer. You might need it if you created an OpenGL "forward compatible" context. Then al_get_backbuffer only returns Nil, so it would not work to pass that to al_set_target_bitmap.

function al_get_opengl_variant: ALLEGRO_OPENGL_VARIANT; CDECL; external ALLEGRO_LIB_NAME;

Returns the variant or type of OpenGL used on the running platform. This function can be called before creating a display or setting properties for new displays. Possible values are:

ALLEGRO_DESKTOP_OPENGL

Regular OpenGL as seen on desktop/laptop computers.

ALLEGRO_OPENGL_ES

Trimmed down version of OpenGL used on many small consumer electronic devices such as handheld (and sometimes full size) consoles.

See also
al_get_opengl_version
Returns the OpenGL or OpenGL ES version number of the client (the computer the program is running on), for the current display.

Generated by PasDoc 0.15.0. Generated on 2024-11-10 15:15:06.