⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opengl12.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{******************************************************************************}
{                                                       	               }
{       Borland Delphi Runtime Library                  		       }
{       OpenGL interface unit                                                  }
{                                                       	               }
{                                                       	               }
{ This is an interface unit for the use of OpenGL from within Delphi and Kylix.}
{ It contains the translations of gl.h, glu.h, glx.h as well as some support   }
{ functions.                                                                   }
{                                                                              }
{ 									       }
{ Portions created by Microsoft are 					       }
{ Copyright (C) 1995-2001 Microsoft Corporation. 			       }
{ All Rights Reserved. 							       }
{ 									       }
{ Portions created by Silicon Graphics Incorporated are 		       }
{ Copyright (C) 1995-2001 Silicon Graphics Incorporated 		       }
{ All Rights Reserved. 							       }
{ 									       }
{ Portions created by NVidia are                        		       }
{ Copyright (C) 1995-2001 NVidia 		                               }
{ All Rights Reserved. 							       }
{ 									       }
{ Portions created by Brian Paul                       		               }
{ Copyright (C) 1995-2001 Brian Paul 		                               }
{ All Rights Reserved. 							       }
{ 									       }
{ 									       }
{ The original file is: gl.h                                                   }
{ The original file is: glut.h                                                 }
{ The original file is: glx.h                                                  }
{ The original file is: glx.h                                                  }
{ 									       }
{ The original Pascal code is: OpenGL12.pas 	                               }
{ The initial developer of the Pascal code is Mike Lischke                     }
{                                                                              }
{ Portions created by Mike Lischke are    				       }
{ Copyright (C) 2001 Mike Lischke. 					       }
{ 									       }
{ Portions created by John O'Harrow are    				       }
{ Copyright (C) 2001 John O'Harrow. 					       }
{                                                                              }
{ Portions created by Eric Grange are    				       }
{ Copyright (C) 2001 Eric Grange. 					       }
{                                                                              }
{ Portions created by Olivier Chatelain    				       }
{ Copyright (C) 2001 Olivier Chatelain. 				       }
{                                                                              }
{ Portions created by Tom Nuydens            				       }
{ Copyright (C) 2001 Tom Nuydens.       				       }
{                                                                              }
{ Portions created by Matthias Thoma are    				       }
{ Copyright (C) 2001 Matthias Thoma. 					       }
{                                                                              }
{ Portions created by Sven Bobrowski are    				       }
{ Copyright (C) 2001 Sven Bobrowski 					       }
{                                                                              }
{                                                                              }
{       Obtained through:                               		       }
{ 									       }
{       Joint Endeavour of Delphi Innovators (Project JEDI)                    }
{									       }
{ You may retrieve the latest version of this file at the Project              }
{ JEDI home page, located at http://delphi-jedi.org                            }
{									       }
{ The contents of this file are used with permission, subject to               }
{ the Mozilla Public License Version 1.1 (the "License"); you may              }
{ not use this file except in compliance with the License. You may             }
{ obtain a copy of the License at                                              }
{ http://www.mozilla.org/MPL/MPL-1.1.html 	                               }
{ 									       }
{ Software distributed under the License is distributed on an 	               }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or               }
{ implied. See the License for the specific language governing                 }
{ rights and limitations under the License. 				       }
{ 									       }
{******************************************************************************}

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; var Palette: HPALETTE): 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 - requested size of the stencil buffer
//     AccumBits   - requested size of the accumulation buffer
//     AuxBuffers  - requested number of auxiliary buffers
//     Layer       - ID for the layer for which the RC will be created (-1..-15 for underlay planes, 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.
//     Palette     - Palette Handle created within function (need to use DeleteObject(Palette) to free this)
//   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.
//
// 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.
//
// function HasActiveContext: Boolean; 
//   Determines whether the calling thread has currently an active rendering context.
//----------------------------------------------------------------------------------------------------------------------
//
// 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
// - nVidia extension reference as of January 2001
// - vertex_array_range sample by Tom Nuydens at Delphi3D
// - minor bug fixes and greatly extended by John O'Harrow (john@elmcrest.demon.co.uk)
// - context activation balancing by Eric Grange (egrange@infonie.fr)
// - additional nVidia extensions by Olivier Chatelain (Olivier.Chatelain@xitact.com)
//
//  Contact: public@lischke-online.de
//
//  Version: 1.2.7
//----------------------------------------------------------------------------------------------------------------------
//
// 05-JUL-2001 ml:
//   - own exception type for OpenGL
//   - TGLboolean is now of type BYTEBOOL
// 05-MAY-2001 ml:
//   - correct tracking of RC creation and release as well as multithreaded RC activation
//   - compatibility routines for users of other OpenGL unit variants
//   - improved rendering context creation
//   - bug fixes
// 01-MAY-2001 ml:
//   - added more nVidia extensions
//----------------------------------------------------------------------------------------------------------------------

interface

uses
  {$IFDEF Win32}
    Windows
  {$ENDIF}

  {$IFDEF LINUX}
    LibC, XLib, Types
  {$ENDIF}
  ;

type
  TRCOptions = set of (
    opDoubleBuffered,
    opGDI,
    opStereo); 

  TGLenum     = UINT; 
  PGLenum     = ^TGLenum; 

  TGLboolean  = BYTEBOOL;
  PGLboolean  = ^TGLboolean; 

  TGLbitfield = UINT; 
  PGLbitfield = ^TGLbitfield; 

  TGLbyte     = ShortInt; 
  PGLbyte     = ^TGLbyte; 

  TGLshort    = SmallInt; 
  PGLshort    = ^TGLshort; 

  TGLint      = Integer; 
  PGLint      = ^TGLint; 

  TGLsizei    = Integer; 
  PGLsizei    = ^TGLsizei; 

  TGLubyte    = CHAR; 
  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; 

  TVector3d = array[0..2] of Double;
  
  TVector4i = array[0..3] of Integer;
  TVector4f = array[0..3] of Single;
  TVector4p = array[0..3] of Pointer;

  TMatrix4f = array[0..3, 0..3] of Single;
  TMatrix4d = array[0..3, 0..3] of Double;
  
  PPointer = ^Pointer;

var
  GL_VERSION_1_0,
  GL_VERSION_1_1,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -