📄 opengl12.pas
字号:
unit OpenGL12;
//----------------------------------------------------------------------------------------------------------------------
//
// This is an interface unit for the use of OpenGL from within Delphi and contains
// the translations of gl.h, glu.h as well as some support functions.
// OpenGL12.pas contains bug fixes and enhancements of Delphi's and other translations
// as well as support for extensions.
//
//----------------------------------------------------------------------------------------------------------------------
//
// function InitOpenGL: Boolean;
// Needed to load the OpenGL DLLs and all addresses of the standard functions.
// In case OpenGL is already initialized this function does nothing. No error
// is raised, if something goes wrong, but you need to inspect the result in order
// to know if all went okay.
// RESULT: True if successful or already loaded, False otherwise
//
// function InitOpenGLFromLibrary(GL_Name, GLU_Name: String): Boolean;
// Same as InitOpenGL, but you can specify specific DLLs. Useful if you want to
// use different DLLs then those of Windows. This function closes eventually
// loaded DLLs before it tries to open the newly given.
// RESULT: True if successful, false otherwise
//
// procedure CloseOpenGL;
// Unloads the OpenGL DLLs and sets all function addresses to nil, including
// extensions. You can load and unload the DLLs as often as you like.
//
// procedure ClearExtensions;
// Sets all extension routines to nil. This is needed when you change the Pixelformat
// of your OpenGL window, since the availability of these routines changes from
// PixelFormat to Pixelformat (and also between various vendors).
//
// function CreateRenderingContext(DC: HDC; Options: TRCOptions; ColorBits, StencilBits, AccumBits, AuxBuffers: Integer;
// Layer: Integer): HGLRC;
// Sets up a pixel format and creates a new rendering context depending of the
// given parameters:
// DC - the device context for which the rc is to be created
// Options - options for the context, which the application would like to have
// (it is not guaranteed they will be available)
// ColorBits - the color depth of the device context (Note: Because of the internal DC handling of the VCL you
// should avoid using GetDeviceCaps for memory DCs which are members of a TBitmap class.
// Translate the Pixelformat member instead!)
// StencilBits - wished size of the stencil buffer
// AccumBits - wished size of the accumulation buffer
// AuxBuffers - wished number of auxiliary buffers
// Layer - ID for the layer for which the RC will be created (-1..-15 for underlays, 0 for main plane,
// 1..15 for overlay planes)
// Note: The layer handling is not yet complete as there is very few information
// available and (until now) no OpenGL implementation with layer support on the low budget market.
// Hence use 0 (for the main plane) as layer ID.
// RESULT: the newly created context or 0 if setup failed
//
// procedure ActivateRenderingContext(DC: HDC; RC: HGLRC);
// Makes RC in DC 'current' (wglMakeCurrent(..)) and loads all extension addresses
// and flags if necessary.
//
// procedure DeactivateRenderingContext;
// Counterpart to ActivateRenderingContext.
//
// procedure DestroyRenderingContext(RC: HGLRC);
// RC will be destroyed and must be recreated if you want to use it again. No
// additional functionality to wglDeleteContext yet.
//
// procedure ReadExtensions;
// Determines which extensions for the current rendering context are available and
// loads their addresses. This procedure is called from ActivateRenderingContext
// if a new pixel format is used, but you can safely call it from where you want
// to actualize those values (under the condition that a rendering context MUST be
// active).
//
// procedure ReadImplementationProperties;
// Determines other properties of the OpenGL DLL (version, availability of extensions).
// Again, a valid rendering context must be active.
//
//----------------------------------------------------------------------------------------------------------------------
//
// This translation is based on different sources:
//
// - first translation from Artemis Alliance Inc.
// - previous versions from Mike Lischke
// - Alexander Staubo
// - Borland OpenGL.pas (from Delphi 3)
// - Microsoft and SGI OpenGL header files
// - www.opengl.org, www.sgi.com/OpenGL
// - NVidia extension reference as of December 1999
//
// Contact: public@lischke-online.de
//
// last change: 04. January 2000
//
//----------------------------------------------------------------------------------------------------------------------
{ ------ Original copyright notice by SGI -----
Copyright 1996 Silicon Graphics, Inc.
All Rights Reserved.
This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
the contents of this file may not be disclosed to third parties, copied or
duplicated in any form, in whole or in part, without the prior written
permission of Silicon Graphics, Inc.
RESTRICTED RIGHTS LEGEND:
Use, duplication or disclosure by the Government is subject to restrictions
as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
and Computer Software clause at DFARS 252.227-7013, and/or in similar or
successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
rights reserved under the Copyright Laws of the United States.}
interface
uses
Windows, Geometry;
type
TRCOptions = set of (opDoubleBuffered, opGDI, opStereo);
TGLenum = UINT; PGLenum = ^TGLenum;
TGLboolean = UCHAR; PGLboolean = ^TGLboolean;
TGLbitfield = UINT; PGLbitfield = ^TGLbitfield;
TGLbyte = ShortInt; PGLbyte = ^TGLbyte;
TGLshort = SHORT; PGLshort = ^TGLshort;
TGLint = Integer; PGLint = ^TGLint;
TGLsizei = Integer; PGLsizei = ^TGLsizei;
TGLubyte = UCHAR; PGLubyte = ^TGLubyte;
TGLushort = Word; PGLushort = ^TGLushort;
TGLuint = UINT; PGLuint = ^TGLuint;
TGLfloat = Single; PGLfloat = ^TGLfloat;
TGLclampf = Single; PGLclampf = ^TGLclampf;
TGLdouble = Double; PGLdouble = ^TGLdouble;
TGLclampd = Double; PGLclampd = ^TGLclampd;
var
GL_VERSION_1_0,
GL_VERSION_1_1,
GL_VERSION_1_2,
GLU_VERSION_1_1,
GLU_VERSION_1_2,
GLU_VERSION_1_3: Boolean;
// Extensions (gl)
GL_EXT_abgr,
GL_EXT_bgra,
GL_EXT_packed_pixels,
GL_EXT_paletted_texture,
GL_EXT_vertex_array,
GL_EXT_index_array_formats,
GL_EXT_index_func,
GL_EXT_index_material,
GL_EXT_index_texture,
GL_WIN_swap_hint,
GL_EXT_blend_color,
GL_EXT_blend_logic_op,
GL_EXT_blend_minmax,
GL_EXT_blend_subtract,
GL_EXT_convolution,
GL_EXT_copy_texture,
GL_EXT_histogram,
GL_EXT_polygon_offset,
GL_EXT_subtexture,
GL_EXT_texture_object,
GL_EXT_texture3D,
GL_EXT_cmyka,
GL_EXT_rescale_normal,
GL_SGI_color_matrix,
GL_EXT_texture_color_table,
GL_SGI_color_table,
GL_EXT_clip_volume_hint,
GL_EXT_compiled_vertex_array,
GL_EXT_cull_vertex,
GL_EXT_point_parameters,
GL_EXT_texture_env_add,
GL_EXT_misc_attribute,
GL_EXT_scene_marker,
GL_EXT_shared_texture_palette,
GL_EXT_texture_env_combine,
GL_NV_texgen_reflection,
GL_NV_texture_env_combine4,
GL_ARB_multitexture,
GL_ARB_imaging,
GL_EXT_fog_coord,
GL_EXT_light_max_exponent,
GL_EXT_secondary_color,
GL_EXT_separate_specular_color,
GL_EXT_stencil_wrap,
GL_EXT_texture_cube_map,
GL_EXT_texture_filter_anisotropic,
GL_EXT_texture_lod_bias,
GL_EXT_vertex_weighting,
GL_KTX_buffer_region,
GL_NV_blend_square,
GL_NV_fog_distance,
GL_NV_register_combiners,
GL_NV_texgen_emboss,
GL_NV_vertex_array_range,
GL_SGIS_multitexture,
GL_SGIS_texture_lod,
WGL_EXT_swap_control,
// Extensions (glu)
GLU_EXT_Texture,
GLU_EXT_object_space_tess,
GLU_EXT_nurbs_tessellator: Boolean;
const
// ********** GL generic constants **********
// errors
GL_NO_ERROR = 0;
GL_INVALID_ENUM = $0500;
GL_INVALID_VALUE = $0501;
GL_INVALID_OPERATION = $0502;
GL_STACK_OVERFLOW = $0503;
GL_STACK_UNDERFLOW = $0504;
GL_OUT_OF_MEMORY = $0505;
// attribute bits
GL_CURRENT_BIT = $00000001;
GL_POINT_BIT = $00000002;
GL_LINE_BIT = $00000004;
GL_POLYGON_BIT = $00000008;
GL_POLYGON_STIPPLE_BIT = $00000010;
GL_PIXEL_MODE_BIT = $00000020;
GL_LIGHTING_BIT = $00000040;
GL_FOG_BIT = $00000080;
GL_DEPTH_BUFFER_BIT = $00000100;
GL_ACCUM_BUFFER_BIT = $00000200;
GL_STENCIL_BUFFER_BIT = $00000400;
GL_VIEWPORT_BIT = $00000800;
GL_TRANSFORM_BIT = $00001000;
GL_ENABLE_BIT = $00002000;
GL_COLOR_BUFFER_BIT = $00004000;
GL_HINT_BIT = $00008000;
GL_EVAL_BIT = $00010000;
GL_LIST_BIT = $00020000;
GL_TEXTURE_BIT = $00040000;
GL_SCISSOR_BIT = $00080000;
GL_ALL_ATTRIB_BITS = $000FFFFF;
// client attribute bits
GL_CLIENT_PIXEL_STORE_BIT = $00000001;
GL_CLIENT_VERTEX_ARRAY_BIT = $00000002;
GL_CLIENT_ALL_ATTRIB_BITS = $FFFFFFFF;
// boolean values
GL_FALSE = 0;
GL_TRUE = 1;
// primitives
GL_POINTS = $0000;
GL_LINES = $0001;
GL_LINE_LOOP = $0002;
GL_LINE_STRIP = $0003;
GL_TRIANGLES = $0004;
GL_TRIANGLE_STRIP = $0005;
GL_TRIANGLE_FAN = $0006;
GL_QUADS = $0007;
GL_QUAD_STRIP = $0008;
GL_POLYGON = $0009;
// blending
GL_ZERO = 0;
GL_ONE = 1;
GL_SRC_COLOR = $0300;
GL_ONE_MINUS_SRC_COLOR = $0301;
GL_SRC_ALPHA = $0302;
GL_ONE_MINUS_SRC_ALPHA = $0303;
GL_DST_ALPHA = $0304;
GL_ONE_MINUS_DST_ALPHA = $0305;
GL_DST_COLOR = $0306;
GL_ONE_MINUS_DST_COLOR = $0307;
GL_SRC_ALPHA_SATURATE = $0308;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -