fpc/packages/opengl/build/gl_linux.tem
peter 7039100d0d * new updated version
* gtkglarea unit and demo
  * win32 opengl headers
  * morph3d demo
2000-09-03 21:25:44 +00:00

311 lines
7.1 KiB
Plaintext

{
$Id$
Translation of the Mesa GL headers for FreePascal
Copyright (C) 1999 Sebastian Guenther
Mesa 3-D graphics library
Version: 3.0
Copyright (C) 1995-1998 Brian Paul
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
{$MODE delphi} // objfpc would not work because of direct proc var assignments
{You have to enable Macros (compiler switch "-Sm") for compiling this unit!
This is necessary for supporting different platforms with different calling
conventions via a single unit.}
unit GL;
interface
{$DEFINE GL1_0}
{$DEFINE GL1_1}
{$DEFINE GL1_2}
{$DEFINE MESA} {enable if you want to use some special mesa extensions}
{$DEFINE EXTENSIONS} {enable if you need one/all of extensions}
{$DEFINE SGI_EXTENSIONS} {enable if you need one/all of extensions}
{$MACRO ON}
{$IFDEF Linux}
{$LINKLIB c}
{$ELSE}
{$MESSAGE Unsupported platform.}
{$ENDIF}
// =======================================================
// Unit specific extensions
// =======================================================
function InitGLFromLibrary(libname: PChar): Boolean;
// determines automatically which libraries to use:
function InitGL: Boolean;
var
GLDumpUnresolvedFunctions,
GLInitialized: Boolean;
// =======================================================
// GL consts, types and functions
// =======================================================
// -------------------------------------------------------
// GL types
// -------------------------------------------------------
type
PSingle = ^Single;
PDouble = ^Double;
GLvoid = Pointer;
GLboolean = Byte;
GLbyte = ShortInt; // 1-byte signed
GLshort = Integer; // 2-byte signed
GLint = LongInt; // 4-byte signed
GLubyte = Byte; // 1-byte unsigned
GLushort = Word; // 2-byte unsigned
GLuint = DWord; // 4-byte signed
GLsizei = LongInt; // 4-byte signed
GLfloat = Single; // single precision float
GLclampf = Single; // single precision float in [0,1]
GLdouble = Double; // double precision float
GLclampd = Double; // double precision float in [0,1]
GLenum = DWord;
PGLBoolean = ^GLBoolean;
PGLFloat = ^GLfloat;
PGLDouble = ^GLDouble;
type
GLbitfield = DWord; { was an enum - no corresponding thing in pascal }
const
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;
// -------------------------------------------------------
// GL constants
// -------------------------------------------------------
{$IFDEF GL1_0}
%GLDeclsIF10
{$ENDIF GL1_0}
{$IFDEF GL1_1}
%GLDeclsIF11
{$ENDIF GL1_1}
{$IFDEF GL1_2}
%GLDeclsIF12
{$ENDIF GL1_2}
const
// Utility
GL_VENDOR = $1F00;
GL_RENDERER = $1F01;
GL_VERSION = $1F02;
GL_EXTENSIONS = $1F03;
// Errors
GL_INVALID_VALUE = $0501;
GL_INVALID_ENUM = $0500;
GL_INVALID_OPERATION = $0502;
GL_STACK_OVERFLOW = $0503;
GL_STACK_UNDERFLOW = $0504;
GL_OUT_OF_MEMORY = $0505;
// -------------------------------------------------------
// GL extensions constants
// -------------------------------------------------------
{$IFDEF EXTENSIONS}
%GLDeclsIF10Ext
{$ENDIF EXTENSIONS}
{$IFDEF SGI_EXTENSIONS}
%GLDeclsIF10SGI
{$ENDIF SGI_EXTENSIONS}
{$IFDEF MESA}
%GLDeclsIF10Mesa
{$ENDIF MESA}
// -------------------------------------------------------
// GL procedures and functions
// -------------------------------------------------------
{$IFDEF GL1_0}
var
%GLProcsPD10
{$ENDIF GL1_0}
{$IFDEF GL1_1}
var
%GLProcsPD11
{$ENDIF GL1_1}
{$IFDEF GL1_2}
var
%GLProcsPD12
{$ENDIF GL1_2}
// -------------------------------------------------------
// GL Extensions
// -------------------------------------------------------
{$IFDEF EXTENSIONS}
var
%GLProcsPD10Ext
{$ENDIF EXTENSIONS}
// library dependent extensions
{$IFDEF SGI_EXTENSIONS}
var
%GLProcsPD10SGI
{$ENDIF SGI_EXTENSIONS}
{$ifdef MESA}
var
%GLProcsPD10Mesa
{$endif MESA}
// =======================================================
// =======================================================
implementation
{$LINKLIB m}
function dlopen(AFile: PChar; mode: LongInt): Pointer; external 'dl';
function dlclose(handle: Pointer): LongInt; external 'dl';
function dlsym(handle: Pointer; name: PChar): Pointer; external 'dl';
function LoadLibrary(name: PChar): Pointer;
begin
Result := dlopen(name, $101 {RTLD_GLOBAL or RTLD_LAZY});
end;
function GetProc(handle: Pointer; name: PChar): Pointer;
begin
Result := dlsym(handle, name);
if (Result = nil) and GLDumpUnresolvedFunctions then
WriteLn('Unresolved: ', name);
end;
var
libGL : Pointer;
function InitGLFromLibrary(libname: PChar): Boolean;
begin
Result := False;
libGL := LoadLibrary(libname);
if not Assigned(libGL) then exit;
{$ifdef GL1_0}
%GLProcsPL10
{$endif GL1_0}
{$ifdef GL1_1}
%GLProcsPL11
{$endif GL1_1}
{$ifdef GL1_2}
%GLProcsPL12
{$endif GL1_2}
{$ifdef EXTENSIONS}
%GLProcsPL10Ext
{$endif EXTENSIONS}
{$ifdef SGI_EXTENSIONS}
%GLProcsPL10SGI
{$endif SGI_EXTENSIONS}
{$ifdef MESA}
%GLProcsPL10Mesa
{$endif MESA}
GLInitialized := True;
Result := True;
end;
function InitGL: Boolean;
begin
Result := InitGLFromLibrary('libGL.so') or
InitGLFromLibrary('libGL.so.1') or
InitGLFromLibrary('libMesaGL.so') or
InitGLFromLibrary('libMesaGL.so.3');
end;
initialization
InitGL;
finalization
if Assigned(libGL) then dlclose(libGL);
end.
{
$Log$
Revision 1.1 2000-09-03 21:25:45 peter
* new updated version
* gtkglarea unit and demo
* win32 opengl headers
* morph3d demo
Revision 1.1 2000/07/13 06:34:17 michael
+ Initial import
Revision 1.2 2000/05/31 00:34:28 alex
made templates work
}