removed gtkglarea, it is now part of the lazopenglcontext package

git-svn-id: trunk@8436 -
This commit is contained in:
mattias 2006-01-04 12:43:19 +00:00
parent 68755c278e
commit dfcf4299a7
16 changed files with 4 additions and 7168 deletions

9
.gitattributes vendored
View File

@ -118,15 +118,6 @@ components/fpcunit/ide/testcaseopts.lfm svneol=native#text/plain
components/fpcunit/ide/testcaseopts.lrs svneol=native#text/pascal
components/fpcunit/ide/testcaseopts.pas svneol=native#text/pascal
components/fpcunit/lib/README.txt svneol=native#text/plain
components/gtk/gtkglarea/gtkglarea.lrs svneol=native#text/pascal
components/gtk/gtkglarea/gtkglarea_int.pp svneol=native#text/pascal
components/gtk/gtkglarea/gtkglareacontrol.pas svneol=native#text/pascal
components/gtk/gtkglarea/gtkopengl.lpk svneol=native#text/pascal
components/gtk/gtkglarea/gtkopengl.pas svneol=native#text/pascal
components/gtk/gtkglarea/nvgl.pp svneol=native#text/pascal
components/gtk/gtkglarea/nvglx.pp svneol=native#text/pascal
components/gtk/gtkglarea/openglgtkwidget.pas svneol=native#text/pascal
components/gtk/gtkglarea/tgtkglareacontrol.xpm -text svneol=native#image/x-xpixmap
components/images/examples/README.txt svneol=native#text/plain
components/images/examples/imagesexample.lpi svneol=native#text/plain
components/images/examples/imagesexample.lpr svneol=native#text/pascal

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
# $Id$
#
# Makefile.fpc for Lazarus TGTKGLAreaControl for Free Pascal
#
[package]
name=gtkopengl
version=1.0
[compiler]
options=-gl -k-lGL
unitdir=. ../../../lcl/units ../../../lcl/units/gtk
[target]
units=gtkglareacontrol
implicitunits=gtkglarea_int nvgl gtkglareacontrol
[default]
[require]
packages=rtl fcl gtk opengl
[clean]
files=$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) $(wildcard *$(RSTEXT))
[install]
[dist]
zipname=lazarus.gtkglarea.$(ZIPSUFFIX)
[rules]
.PHONY: cleartarget all makefile makefiles
all: cleartarget gtkglareacontrol$(PPUEXT)
# end.

View File

@ -1,36 +0,0 @@
Package GtkOpenGL
Contains the lcl component TGTKGLAreaControl, which wraps the gtkglarea, a
gtk widget for opengl. This component works only with the gtk interface.
There is an example in examples/gtkglarea/.
WARNINGS and HINTS:
Make sure your program links to libgtkgl, not to libgtkgl-2.0. Linking to
libgtkgl-2.0 will result in mixing gtk1 and gtk2 in your program/IDE, which
will result in al kinds of strange errors, including freezing your
windowmanager.
You can find out, what libs were linked to your program with the ldd program:
[]$ ldd yourprogram
For *BSD:
In the fpc file dllfuncs.pp all external functions link to lib dl.
These functions are in libc under *BSD, so should read
external lib "c" for FreeBSD. If you don't, building lazarus will bomb
out with a "can't find lib -ldl" error while linking.
Fixed compiled units working with 1.0.10 are in
http://www.stack.nl/~marcov/openglfreebsd.tar.gz
ToDo:
Add an example using the package.

View File

@ -1,73 +0,0 @@
LazarusResources.Add('tgtkglareacontrol','XPM',[
'/* XPM */'#10'static char * tgtkglareacontrol_xpm[] = {'#10'"18 21 187 2",'
+#10'" '#9'c None",'#10'". '#9'c #C2DAFE",'#10'"+ '#9'c #BECEFE",'#10'"@ '#9
+'c #B2C2FE",'#10'"# '#9'c #B6CAFE",'#10'"$ '#9'c #AABAFE",'#10'"% '#9'c #A2A'
+'EFE",'#10'"& '#9'c #96A2FE",'#10'"* '#9'c #A2B2FE",'#10'"= '#9'c #929EFE",'
+#10'"- '#9'c #8E92FE",'#10'"; '#9'c #868AFE",'#10'"> '#9'c #8A82FE",'#10'", '
+#9'c #62AAFE",'#10'"'' '#9'c #7EAAFA",'#10'") '#9'c #A6BEFA",'#10'"! '#9'c #'
+'AEBEFE",'#10'"~ '#9'c #9AA2FE",'#10'"{ '#9'c #9296FE",'#10'"] '#9'c #7E86F6'
+'",'#10'"^ '#9'c #3E66DE",'#10'"/ '#9'c #064ABA",'#10'"( '#9'c #66AAFE",'#10
+'"_ '#9'c #5E96F6",'#10'": '#9'c #5A92F6",'#10'"< '#9'c #7E9AF6",'#10'"[ '#9
+'c #92A2FA",'#10'"} '#9'c #7E92FA",'#10'"| '#9'c #4E76E6",'#10'"1 '#9'c #125'
+'2C6",'#10'"2 '#9'c #0246B2",'#10'"3 '#9'c #06429E",'#10'"4 '#9'c #66A2FA",'
+#10'"5 '#9'c #5E8AEE",'#10'"6 '#9'c #5A8EEE",'#10'"7 '#9'c #527EE6",'#10'"8 '
+#9'c #527AE6",'#10'"9 '#9'c #2262E6",'#10'"0 '#9'c #0252CE",'#10'"a '#9'c #0'
+'24ABA",'#10'"b '#9'c #0642A6",'#10'"c '#9'c #0A4296",'#10'"d '#9'c #5286FA"'
+','#10'"e '#9'c #527AE2",'#10'"f '#9'c #5276DA",'#10'"g '#9'c #4272E2",'#10
+'"h '#9'c #0A5ADE",'#10'"i '#9'c #024EBE",'#10'"j '#9'c #0246AA",'#10'"k '#9
+'c #063A92",'#10'"l '#9'c #06367E",'#10'"m '#9'c #FEDADA",'#10'"n '#9'c #FAC'
+'ECE",'#10'"o '#9'c #3E76EE",'#10'"p '#9'c #5272DA",'#10'"q '#9'c #4E6ED6",'
+#10'"r '#9'c #3A5AC6",'#10'"s '#9'c #0A4EC2",'#10'"t '#9'c #0646AA",'#10'"u '
+#9'c #063E92",'#10'"v '#9'c #06327A",'#10'"w '#9'c #062E72",'#10'"x '#9'c #F'
+'EC2C2",'#10'"y '#9'c #F6B6B6",'#10'"z '#9'c #3266DE",'#10'"A '#9'c #4A66CE"'
+','#10'"B '#9'c #4A62CA",'#10'"C '#9'c #0A46AE",'#10'"D '#9'c #063686",'#10
+'"E '#9'c #062E6A",'#10'"F '#9'c #0A2656",'#10'"G '#9'c #FEB6B6",'#10'"H '#9
+'c #F6A6AA",'#10'"I '#9'c #4662CE",'#10'"J '#9'c #425ACA",'#10'"K '#9'c #3E5'
+'2C2",'#10'"L '#9'c #324EB6",'#10'"M '#9'c #0A3272",'#10'"N '#9'c #12223E",'
+#10'"O '#9'c #FE6666",'#10'"P '#9'c #FE8686",'#10'"Q '#9'c #FEAAAA",'#10'"R '
+#9'c #FEAEB2",'#10'"S '#9'c #FEA6A2",'#10'"T '#9'c #E67E7E",'#10'"U '#9'c #8'
+'64666",'#10'"V '#9'c #4A4EAA",'#10'"W '#9'c #3E4ABA",'#10'"X '#9'c #2E42AA"'
+','#10'"Y '#9'c #0A368A",'#10'"Z '#9'c #0E2652",'#10'"` '#9'c #223E46",'#10
+'" .'#9'c #5A6E26",'#10'"..'#9'c #FA4E4E",'#10'"+.'#9'c #F64646",'#10'"@.'#9
+'c #F64A4A",'#10'"#.'#9'c #F66E72",'#10'"$.'#9'c #F28A86",'#10'"%.'#9'c #DA6'
+'E6E",'#10'"&.'#9'c #862626",'#10'"*.'#9'c #461206",'#10'"=.'#9'c #3A529A",'
+#10'"-.'#9'c #0A2E6E",'#10'";.'#9'c #425A32",'#10'">.'#9'c #5E8222",'#10'",.'
+#9'c #5E9626",'#10'"''.'#9'c #629622",'#10'").'#9'c #F24242",'#10'"!.'#9'c #'
+'EE3E3E",'#10'"~.'#9'c #EE3A3A",'#10'"{.'#9'c #E63232",'#10'"].'#9'c #9E0A0A'
+'",'#10'"^.'#9'c #6A0202",'#10'"/.'#9'c #72DE3E",'#10'"(.'#9'c #96EE6A",'#10
+'"_.'#9'c #5ADA26",'#10'":.'#9'c #6EB23E",'#10'"<.'#9'c #6ABA3E",'#10'"[.'#9
+'c #66BA3E",'#10'"}.'#9'c #5EBE32",'#10'"|.'#9'c #4AA21E",'#10'"1.'#9'c #367'
+'A0E",'#10'"2.'#9'c #EE4242",'#10'"3.'#9'c #E63636",'#10'"4.'#9'c #A60606",'
+#10'"5.'#9'c #7A0206",'#10'"6.'#9'c #3ECE02",'#10'"7.'#9'c #3ECA0A",'#10'"8.'
+#9'c #76E64A",'#10'"9.'#9'c #8AFE62",'#10'"0.'#9'c #76FA4E",'#10'"a.'#9'c #6'
+'2DA3A",'#10'"b.'#9'c #329616",'#10'"c.'#9'c #1E6E06",'#10'"d.'#9'c #1A6206"'
+','#10'"e.'#9'c #E63632",'#10'"f.'#9'c #E62E2E",'#10'"g.'#9'c #E22626",'#10
+'"h.'#9'c #960206",'#10'"i.'#9'c #6E0206",'#10'"j.'#9'c #3EC606",'#10'"k.'#9
+'c #3AC606",'#10'"l.'#9'c #36BA02",'#10'"m.'#9'c #32B602",'#10'"n.'#9'c #4EC'
+'226",'#10'"o.'#9'c #36961E",'#10'"p.'#9'c #1E7206",'#10'"q.'#9'c #1A6202",'
+#10'"r.'#9'c #165E02",'#10'"s.'#9'c #1A5A06",'#10'"t.'#9'c #EA3636",'#10'"u.'
+#9'c #E22E2E",'#10'"v.'#9'c #DE2A2A",'#10'"w.'#9'c #D61E1E",'#10'"x.'#9'c #8'
+'20202",'#10'"y.'#9'c #560206",'#10'"z.'#9'c #36B606",'#10'"A.'#9'c #32AE06"'
+','#10'"B.'#9'c #2EA206",'#10'"C.'#9'c #1E6606",'#10'"D.'#9'c #1A5E06",'#10
+'"E.'#9'c #165606",'#10'"F.'#9'c #164E06",'#10'"G.'#9'c #420206",'#10'"H.'#9
+'c #32AA06",'#10'"I.'#9'c #2EA606",'#10'"J.'#9'c #269606",'#10'"K.'#9'c #124'
+'606",'#10'"L.'#9'c #5E0206",'#10'"M.'#9'c #2AA206",'#10'"N.'#9'c #2A9E06",'
+#10'"O.'#9'c #268E06",'#10'"P.'#9'c #165206",'#10'"Q.'#9'c #164A06",'#10'"R.'
+#9'c #123E06",'#10'"S.'#9'c #2AA606",'#10'"T.'#9'c #2A9A06",'#10'"U.'#9'c #2'
+'28606",'#10'"V.'#9'c #124E06",'#10'"W.'#9'c #124206",'#10'"X.'#9'c #0E3A06"'
+','#10'"Y.'#9'c #123606",'#10'"Z.'#9'c #228A06",'#10'"`.'#9'c #1A7A06",'#10
+'" +'#9'c #0E3E06",'#10'".+'#9'c #1A6E06",'#10'"++'#9'c #0E3606",'#10'" '
+' . + ",'#10'" @ @ # $ % & '
+'",'#10'" @ @ @ @ @ * = - ; > ",'#10'" , '' ) ! % '
+'~ { ] ^ / ",'#10'" ( _ : < [ } | 1 2 3 ",'#10'" '
+' 4 5 6 7 8 9 0 a b c ",'#10'" d 7 e f g h i j k l ",'
+#10'" m n o f p q r s t u v w ",'#10'" x x x y z q A B r C k D'
+' E F ",'#10'"x x x x G H I B J K L c v M F N ",'#10'"O P Q G R S T '
,'U V W X Y w Z ` . ",'#10'"..+.@.#.$.%.&.*.*.*.=.-.` ;. .>.,.''.",'#10'"'
+'@.).!.~.{.].^.*./.(._.:.:.<.[.}.|.1.",'#10'"2.!.3.3.{.4.5.*.6.7._.8.9.0.a.b'
+'.c.d.",'#10'"!.e.{.f.g.h.i.*.j.k.l.m.n.o.p.q.r.s.",'#10'"t.u.v.g.w.x.y.*.l.'
+'z.z.A.B.r.C.D.E.F.",'#10'" w.w.w.i.G.*.z.H.I.I.J.D.D.E.F.K.",'#10'" '
+' w.L. H.I.M.N.O.E.P.Q.K.R.",'#10'" S.T.J.O.U.Q.V.W.X.Y.'
+'",'#10'" Z.Z.`.W. +X. ",'#10'" '
+' .+++ "};'#10
]);

View File

@ -1,185 +0,0 @@
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program 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. *
* *
*****************************************************************************
Author: Mattias Gaertner
Abstract:
FPC bindings to the gtkglarea library.
The library is not big and was translated completely to FPC ().
}
unit GTKGLArea_Int;
{$mode objfpc}{$H+}
{$PACKRECORDS C}
interface
uses gdk, gtk, gl;
// gdkgl
const
// enum _GDK_GL_CONFIGS
GDK_GL_NONE = 0;
GDK_GL_USE_GL = 1;
GDK_GL_BUFFER_SIZE = 2;
GDK_GL_LEVEL = 3;
GDK_GL_RGBA = 4;
GDK_GL_DOUBLEBUFFER = 5;
GDK_GL_STEREO = 6;
GDK_GL_AUX_BUFFERS = 7;
GDK_GL_RED_SIZE = 8;
GDK_GL_GREEN_SIZE = 9;
GDK_GL_BLUE_SIZE = 10;
GDK_GL_ALPHA_SIZE = 11;
GDK_GL_DEPTH_SIZE = 12;
GDK_GL_STENCIL_SIZE = 13;
GDK_GL_ACCUM_RED_SIZE = 14;
GDK_GL_ACCUM_GREEN_SIZE = 15;
GDK_GL_ACCUM_BLUE_SIZE = 16;
GDK_GL_ACCUM_ALPHA_SIZE = 17;
// GLX_EXT_visual_info extension
GDK_GL_X_VISUAL_TYPE_EXT = $22;
GDK_GL_TRANSPARENT_TYPE_EXT = $23;
GDK_GL_TRANSPARENT_INDEX_VALUE_EXT = $24;
GDK_GL_TRANSPARENT_RED_VALUE_EXT = $25;
GDK_GL_TRANSPARENT_GREEN_VALUE_EXT = $26;
GDK_GL_TRANSPARENT_BLUE_VALUE_EXT = $27;
GDK_GL_TRANSPARENT_ALPHA_VALUE_EXT = $28;
type
TGdkGLContext = record end;
PGdkGLContext = ^TGdkGLContext;
// GLX_EXT_visual_info extension
function gdk_gl_query: Integer;cdecl;external;
// function gdk_gl_get_info:^char;cdecl;external;
function gdk_gl_choose_visual(attrlist:Plongint):PGdkVisual;cdecl;external;
function gdk_gl_get_config(visual:PGdkVisual; attrib:longint):longint;cdecl;external;
function gdk_gl_context_new(visual:PGdkVisual):PGdkGLContext;cdecl;external;
function gdk_gl_context_share_new(visual:PGdkVisual; sharelist:PGdkGLContext; direct:Integer):PGdkGLContext;cdecl;external;
function gdk_gl_context_attrlist_share_new(attrlist:Plongint; sharelist:PGdkGLContext; direct:Integer):PGdkGLContext;cdecl;external;
function gdk_gl_context_ref(context:PGdkGLContext):PGdkGLContext;cdecl;external;
procedure gdk_gl_context_unref(context:PGdkGLContext);cdecl;external;
function gdk_gl_make_current(drawable:PGdkDrawable; context:PGdkGLContext):Integer;cdecl;external;
procedure gdk_gl_swap_buffers(drawable:PGdkDrawable);cdecl;external;
procedure gdk_gl_wait_gdk;cdecl;external;
procedure gdk_gl_wait_gl;cdecl;external;
{ glpixmap stuff }
type
TGdkGLPixmap = record end;
PGdkGLPixmap = ^TGdkGLPixmap;
TGtkGlAreaMakeCurrentType = integer;
function gdk_gl_pixmap_new(visual:PGdkVisual; pixmap:PGdkPixmap):PGdkGLPixmap;cdecl;external;
function gdk_gl_pixmap_ref(glpixmap:PGdkGLPixmap):PGdkGLPixmap;cdecl;external;
procedure gdk_gl_pixmap_unref(glpixmap:PGdkGLPixmap);cdecl;external;
function gdk_gl_pixmap_make_current(glpixmap:PGdkGLPixmap; context:PGdkGLContext):Integer;cdecl;external;
{ fonts }
procedure gdk_gl_use_gdk_font(font:PGdkFont; first:longint; count:longint; list_base:longint);cdecl;external;
// gtkglarea
function GTK_TYPE_GL_AREA: TGtkType; cdecl; external 'gtkgl' name 'gtk_gl_area_get_type';
{ return type might be wrong }
{ argument types are unknown }
{ return type might be wrong }
//function GTK_GL_AREA(obj : longint) : longint;
{ argument types are unknown }
{ return type might be wrong }
//function GTK_GL_AREA_CLASS(klass : longint) : longint;
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_GL_AREA(obj : Pointer) : Boolean;
function GTK_IS_GL_AREA_CLASS(klass: Pointer): Boolean;
{ return type might be wrong }
type
PGtkGLArea = ^TGtkGLArea;
TGtkGLArea = record
darea: TGtkDrawingArea;
glcontext: PGdkGLContext;
end;
PGtkGLAreaClass = ^TGtkGLAreaClass;
TGtkGLAreaClass = record
parent_class: TGtkDrawingAreaClass;
end;
function gtk_gl_area_get_type:TGtkType;cdecl;external;
function gtk_gl_area_new(attrList:Plongint):PGtkWidget;cdecl;external;
function gtk_gl_area_share_new(attrList:Plongint; share:PGtkGLArea):PGtkWidget;cdecl;external;
function gtk_gl_area_new_vargs(share:PGtkGLArea; args:array of const):PGtkWidget;cdecl;external;
function gtk_gl_area_new_vargs(share:PGtkGLArea):PGtkWidget;cdecl;external;
function gtk_gl_area_make_current(glarea:PGtkGLArea):Integer;cdecl;external;
function gtk_gl_area_begingl(glarea:PGtkGLArea):Integer;cdecl;external;
{ deprecated, use gtk_gl_area_make_current }
procedure gtk_gl_area_endgl(glarea:PGtkGLArea);cdecl;external;
{ deprecated }
procedure gtk_gl_area_swapbuffers(glarea:PGtkGLArea);cdecl;external;
{ deprecated }
procedure gtk_gl_area_swap_buffers(glarea:PGtkGLArea);cdecl;external;
{ deprecated, use gtk_drawing_area_size() }
procedure gtk_gl_area_size(glarea:PGtkGLArea; width:Integer; height:Integer);cdecl;external;
implementation
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
{ function GTK_GL_AREA(obj : longint) : longint;
begin
GTK_GL_AREA:=GTK_CHECK_CAST(obj,GTK_TYPE_GL_AREA,GtkGLArea);
end;}
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
{ function GTK_GL_AREA_CLASS(klass : longint) : longint;
begin
GTK_GL_AREA_CLASS:=GTK_CHECK_CLASS_CAST(klass,GTK_TYPE_GL_AREA,GtkGLAreaClass);
end;}
{ was #define dname(params) para_def_expr }
{ argument types are unknown }
{ return type might be wrong }
function GTK_IS_GL_AREA(obj: Pointer): Boolean;
begin
// GTK_IS_GL_AREA:=GTK_CHECK_TYPE(obj,GTK_TYPE_GL_AREA);
Result := Assigned(obj) and GTK_IS_GL_AREA_CLASS(PGtkTypeObject(obj)^.klass);
end;
{ was #define dname def_expr }
function GTK_IS_GL_AREA_CLASS(klass: Pointer): Boolean;
{ return type might be wrong }
begin
// GTK_IS_GL_AREA_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_GL_AREA);
Result := Assigned(klass) and (PGtkTypeClass(klass)^.thetype = GTK_TYPE_GL_AREA);
end;
end.

View File

@ -1,387 +0,0 @@
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program 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. *
* *
*****************************************************************************
Author: Mattias Gaertner
}
unit GTKGLAreaControl;
{$MODE objfpc}{$H+}
interface
uses
Classes, SysUtils, LCLProc, LCLType, LCLIntf,
Unix,
Forms, Controls, Graphics, LMessages, InterfaceBase, WSLCLClasses, WSControls,
LResources, GTKInt, Gtk, NVGL,
{$IFDEF UseGtkGlAreaLib}
GTKGLArea_Int
{$ELSE}
OpenGLGtkWidget
{$ENDIF}
;
type
TGtkGlAreaMakeCurrentEvent = procedure(Sender: TObject;
var Allow: boolean) of object;
{ TCustomGTKGLAreaControl }
TCustomGTKGLAreaControl = class(TWinControl)
private
FCanvas: TCanvas; // only valid at designtime
FOnMakeCurrent: TGtkGlAreaMakeCurrentEvent;
FOnPaint: TNotifyEvent;
FCurrentFrameTime: integer; // in msec
FLastFrameTime: integer; // in msec
FFrameDiffTime: integer; // in msec
FSharedArea: TCustomGTKGLAreaControl;
FSharingAreas: TList;
function GetSharingAreas(Index: integer): TCustomGTKGLAreaControl;
procedure SetSharedArea(const AValue: TCustomGTKGLAreaControl);
protected
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
function GetWidget: PGtkGLArea;
procedure UpdateFrameTimeDiff;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; virtual;
procedure RealizeBounds; override;
procedure DoOnPaint; virtual;
procedure SwapBuffers; virtual;
function MakeCurrent: boolean; virtual;
function RestoreOldGtkGLAreaControl: boolean;
function SharingAreasCount: integer;
property SharingAreas[Index: integer]: TCustomGTKGLAreaControl read GetSharingAreas;
public
property FrameDiffTimeInMSecs: integer read FFrameDiffTime;
property OnMakeCurrent: TGtkGlAreaMakeCurrentEvent read FOnMakeCurrent
write FOnMakeCurrent;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
property SharedArea: TCustomGTKGLAreaControl read FSharedArea write SetSharedArea;
property Widget: PGtkGLArea read GetWidget;
end;
{ TGTKGLAreaControl }
TGTKGLAreaControl = class(TCustomGTKGLAreaControl)
published
property Align;
property Anchors;
property BorderSpacing;
property Enabled;
property OnClick;
property OnConstrainedResize;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnPaint;
property OnResize;
property OnShowHint;
property PopupMenu;
property SharedArea;
property ShowHint;
property Visible;
end;
{ TWSGTKGLAreaControl }
TWSGTKGLAreaControl = class(TWSWinControl)
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
end;
function GetCurrentGtkGLAreaControl: TGTKGLAreaControl;
procedure Register;
implementation
const
InitAttrList: array [1..13] of LongInt = (
GDK_GL_RGBA,
GDK_GL_RED_SIZE, 1,
GDK_GL_GREEN_SIZE, 1,
GDK_GL_BLUE_SIZE, 1,
GDK_GL_DEPTH_SIZE, 1,
GDK_GL_STENCIL_SIZE, 1,
GDK_GL_DOUBLEBUFFER,
GDK_GL_None
);
var
GtkGLAreaControlStack: TList;
function GetCurrentGtkGLAreaControl: TGTKGLAreaControl;
begin
if (GtkGLAreaControlStack<>nil)
and (GtkGLAreaControlStack.Count>0) then
Result:=TGTKGLAreaControl(GtkGLAreaControlStack[GtkGLAreaControlStack.Count-1])
else
Result:=nil;
end;
procedure Register;
begin
RegisterComponents('OpenGL',[TGTKGLAreaControl]);
end;
{ TCustomGTKGLAreaControl }
constructor TCustomGTKGLAreaControl.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ControlStyle:=ControlStyle-[csSetCaption];
if (csDesigning in ComponentState) then begin
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
end else
FCompStyle:=csNonLCL;
SetInitialBounds(0, 0, 160, 90);
end;
destructor TCustomGTKGLAreaControl.Destroy;
begin
if FSharingAreas<>nil then begin
while SharingAreasCount>0 do
SharingAreas[SharingAreasCount-1].SharedArea:=nil;
FreeAndNil(FSharingAreas);
end;
SharedArea:=nil;
FCanvas.Free;
FCanvas:=nil;
inherited Destroy;
end;
procedure TCustomGTKGLAreaControl.Paint;
begin
if (not (csDesigning in ComponentState))
and Enabled and Visible and HandleAllocated
and MakeCurrent then begin
try
UpdateFrameTimeDiff;
DoOnPaint;
finally
RestoreOldGtkGLAreaControl;
end;
end;
end;
procedure TCustomGTKGLAreaControl.RealizeBounds;
var
RestoreNeeded: Boolean;
begin
RestoreNeeded:=false;
if (not (csDesigning in ComponentState))
and Enabled and Visible and HandleAllocated
and MakeCurrent then begin
RestoreNeeded:=true;
glViewport (0, 0, Width, Height);
end;
try
inherited RealizeBounds;
finally
if RestoreNeeded then
RestoreOldGtkGLAreaControl;
end;
end;
procedure TCustomGTKGLAreaControl.DoOnPaint;
begin
if Assigned(OnPaint) then OnPaint(Self);
end;
procedure TCustomGTKGLAreaControl.SwapBuffers;
begin
gtk_gl_area_swap_buffers(Widget);
end;
function TCustomGTKGLAreaControl.MakeCurrent: boolean;
var
Allowed: Boolean;
begin
if Assigned(FOnMakeCurrent) then begin
Allowed:=true;
OnMakeCurrent(Self,Allowed);
if not Allowed then begin
Result:=False;
exit;
end;
end;
// make sure the widget is realized
gtk_widget_realize(PGtkWidget(Widget));
// make current
Result:=gtk_gl_area_make_current(Widget)
{$IFDEF UseGtkGlAreaLib}=gint(True){$ENDIF};
if Result then begin
// on success push on stack
if GtkGLAreaControlStack=nil then
GtkGLAreaControlStack:=TList.Create;
GtkGLAreaControlStack.Add(Self);
end;
end;
function TCustomGTKGLAreaControl.RestoreOldGtkGLAreaControl: boolean;
var
RestoredControl: TGTKGLAreaControl;
begin
Result:=false;
// check if the current context is on stack
if (GtkGLAreaControlStack=nil) or (GtkGLAreaControlStack.Count=0) then exit;
// pop
GtkGLAreaControlStack.Delete(GtkGLAreaControlStack.Count-1);
// make old control the current control
if GtkGLAreaControlStack.Count>0 then begin
RestoredControl:=
TGTKGLAreaControl(GtkGLAreaControlStack[GtkGLAreaControlStack.Count-1]);
{$IFDEF UseGtkGlAreaLib}
if gtk_gl_area_make_current(RestoredControl.Widget)<>gint(true) then
{$ELSE}
if not gtk_gl_area_make_current(RestoredControl.Widget) then
{$ENDIF}
exit;
end;
Result:=true;
end;
function TCustomGTKGLAreaControl.SharingAreasCount: integer;
begin
if FSharingAreas=nil then
Result:=0
else
Result:=FSharingAreas.Count;
end;
procedure TCustomGTKGLAreaControl.SetSharedArea(
const AValue: TCustomGTKGLAreaControl);
begin
if FSharedArea=AValue then exit;
if AValue=Self then
Raise Exception.Create('An area can not be shared by itself.');
// unshare old
if (AValue<>nil) and (AValue.SharedArea<>nil) then
Raise Exception.Create('Target area is sharing too. A sharing area can not be shared.');
if FSharedArea<>nil then FSharedArea.FSharingAreas.Remove(Self);
// share new
if (AValue<>nil) and (csDestroying in AValue.ComponentState) then
FSharedArea:=nil
else begin
FSharedArea:=AValue;
if (FSharedArea<>nil) then begin
if FSharedArea.FSharingAreas=nil then
FSharedArea.FSharingAreas:=TList.Create;
FSharedArea.FSharingAreas.Add(Self);
end;
end;
// recreate handle if needed
if HandleAllocated and (not (csDesigning in ComponentState)) then
ReCreateWnd(Self);
end;
function TCustomGTKGLAreaControl.GetSharingAreas(Index: integer
): TCustomGTKGLAreaControl;
begin
Result:=TCustomGTKGLAreaControl(FSharingAreas[Index]);
end;
procedure TCustomGTKGLAreaControl.WMPaint(var Message: TLMPaint);
begin
Include(FControlState, csCustomPaint);
inherited WMPaint(Message);
//debugln('TCustomGTKGLAreaControl.WMPaint A ',dbgsName(Self),' ',dbgsName(FCanvas));
if (csDesigning in ComponentState) and (FCanvas<>nil) then begin
with FCanvas do begin
Brush.Color:=clLtGray;
Pen.Color:=clRed;
Rectangle(0,0,Self.Width-1,Self.Height-1);
MoveTo(0,0);
LineTo(Self.Width,Self.Height);
MoveTo(0,Self.Height);
LineTo(Self.Width,0);
end;
end else begin
Paint;
end;
Exclude(FControlState, csCustomPaint);
end;
function TCustomGTKGLAreaControl.GetWidget: PGtkGLArea;
begin
if HandleAllocated then
Result:=PGtkGLArea(Handle)
else
Result:=nil;
end;
procedure TCustomGTKGLAreaControl.UpdateFrameTimeDiff;
begin
FCurrentFrameTime:=integer(GetTickCount);
if FLastFrameTime=0 then
FLastFrameTime:=FCurrentFrameTime;
// calculate time since last call:
FFrameDiffTime:=FCurrentFrameTime-FLastFrameTime;
// if the counter is reset restart:
if (FFrameDiffTime<0) then FFrameDiffTime:=1;
FLastFrameTime:=FCurrentFrameTime;
end;
{ TWSGTKGLAreaControl }
function TWSGTKGLAreaControl.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
NewWidget: Pointer;
Area: TCustomGTKGLAreaControl;
begin
//debugln('TWSGTKGLAreaControl.CreateHandle A AWinControl=',dbgsName(AWinControl),' csDesigning=',dbgs(csDesigning in AWinControl.ComponentState));
if csDesigning in AWinControl.ComponentState then
Result:=inherited CreateHandle(AWinControl,AParams)
else begin
Area:=AWinControl as TCustomGTKGLAreaControl;
if (Area.SharedArea<>nil) and (not (csDestroying in Area.ComponentState))
then
NewWidget:=gtk_gl_area_share_new(Plongint(@InitAttrList),
Area.SharedArea.Widget)
else
NewWidget:=gtk_gl_area_new(Plongint(@InitAttrList));
Result:=longint(NewWidget);
TGTKWidgetSet(WidgetSet).FinishComponentCreate(AWinControl,NewWidget,
true);
end;
end;
initialization
{$i gtkglarea.lrs}
GtkGLAreaControlStack:=nil;
RegisterWSComponent(TCustomGTKGLAreaControl,TWSGTKGLAreaControl);
finalization
FreeAndNil(GtkGLAreaControlStack);
end.

View File

@ -1,72 +0,0 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="2">
<Name Value="GTKOpenGL"/>
<Author Value="Mattias Gaertner, Satan"/>
<CompilerOptions>
<Version Value="5"/>
<SearchPaths>
<UnitOutputDirectory Value="lib/"/>
<LCLWidgetType Value="gtk"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="OpenGL for LCL - components: TGtkGlAreaControl
Please make sure that you link to the right libgtkgl. If you accidently link to libgtkgl-2.0 then you will mix gtk1 and gtk2 libraries, which will result in strange errors, up to freezing your windowmanager."/>
<License Value="LGPL-2"/>
<Version Major="1"/>
<Files Count="6">
<Item1>
<Filename Value="gtkglarea.lrs"/>
<Type Value="LRS"/>
</Item1>
<Item2>
<Filename Value="gtkglareacontrol.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GTKGLAreaControl"/>
</Item2>
<Item3>
<Filename Value="gtkglarea_int.pp"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="GTKGLArea_Int"/>
</Item3>
<Item4>
<Filename Value="openglgtkwidget.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="OpenGLGtkWidget"/>
</Item4>
<Item5>
<Filename Value="nvgl.pp"/>
<UnitName Value="nvGL"/>
</Item5>
<Item6>
<Filename Value="nvglx.pp"/>
<UnitName Value="nvGLX"/>
</Item6>
</Files>
<AutoIncrementVersionOnBuild Value="False"/>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)/gtkopengl/"/>
<CommandAfter Value="/bin/tar -cz -C $(TestDir) -f /tmp/gtkopengl.tgz gtkopengl/"/>
<UseExcludeFileFilter Value="True"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -1,21 +0,0 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit GTKOpenGL;
interface
uses
gtkglareacontrol, nvgl, nvglx, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('gtkglareacontrol', @gtkglareacontrol.Register);
end;
initialization
RegisterPackage('GTKOpenGL', @Register);
end.

View File

@ -1 +0,0 @@
This is the output directory of the package GTKOpenGL.

File diff suppressed because it is too large Load Diff

View File

@ -1,421 +0,0 @@
// File: nvGLX.pp
// modified: 29-07-2003
//
// FreePascal Bindings for libGLX
// Version 0.7.0
// supported NVIDIA Driver Version: 4494
// Author: Reimar Grabowski
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program 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. *
* *
*****************************************************************************
}
{$mode objfpc}{$H+}
{$LinkLib GL}
{$PACKRECORDS C}
unit nvGLX;
interface
uses
X, XLib, XUtil, nvGL;
const
GLX_VERSION_1_1 = 1;
GLX_VERSION_1_2 = 1;
GLX_VERSION_1_3 = 1;
{ GLX Extensions }
GLX_EXT_import_context = 1;
GLX_EXT_visual_info = 1;
GLX_EXT_visual_rating = 1;
GLX_SGIX_fbconfig = 1;
GLX_SGIX_pbuffer = 1;
GLX_NV_float_buffer = 1;
GLX_ARB_get_proc_address = 1;
{ Names for attributes to glXGetConfig. }
{ support GLX rendering }
GLX_USE_GL = 1;
{ depth of the color buffer }
GLX_BUFFER_SIZE = 2;
{ level in plane stacking }
GLX_LEVEL = 3;
{ true if RGBA mode }
GLX_RGBA = 4;
{ double buffering supported }
GLX_DOUBLEBUFFER = 5;
{ stereo buffering supported }
GLX_STEREO = 6;
{ number of aux buffers }
GLX_AUX_BUFFERS = 7;
{ number of red component bits }
GLX_RED_SIZE = 8;
{ number of green component bits }
GLX_GREEN_SIZE = 9;
{ number of blue component bits }
GLX_BLUE_SIZE = 10;
{ number of alpha component bits }
GLX_ALPHA_SIZE = 11;
{ number of depth bits }
GLX_DEPTH_SIZE = 12;
{ number of stencil bits }
GLX_STENCIL_SIZE = 13;
{ number of red accum bits }
GLX_ACCUM_RED_SIZE = 14;
{ number of green accum bits }
GLX_ACCUM_GREEN_SIZE = 15;
{ number of blue accum bits }
GLX_ACCUM_BLUE_SIZE = 16;
{ number of alpha accum bits }
GLX_ACCUM_ALPHA_SIZE = 17;
{ number of multisample buffers }
GLX_SAMPLE_BUFFERS_ARB = 100000;
{ number of multisample samples }
GLX_SAMPLES_ARB = 100001;
{ FBConfig-specific attributes }
GLX_X_VISUAL_TYPE = $22;
{ Like visual_info VISUAL_CAVEAT }
GLX_CONFIG_CAVEAT = $20;
GLX_TRANSPARENT_TYPE = $23;
GLX_TRANSPARENT_INDEX_VALUE = $24;
GLX_TRANSPARENT_RED_VALUE = $25;
GLX_TRANSPARENT_GREEN_VALUE = $26;
GLX_TRANSPARENT_BLUE_VALUE = $27;
GLX_TRANSPARENT_ALPHA_VALUE = $28;
GLX_DRAWABLE_TYPE = $8010;
GLX_RENDER_TYPE = $8011;
GLX_X_RENDERABLE = $8012;
GLX_FBCONFIG_ID = $8013;
GLX_MAX_PBUFFER_WIDTH = $8016;
GLX_MAX_PBUFFER_HEIGHT = $8017;
GLX_MAX_PBUFFER_PIXELS = $8018;
GLX_VISUAL_ID = $800B;
GLX_DRAWABLE_TYPE_SGIX = GLX_DRAWABLE_TYPE;
GLX_RENDER_TYPE_SGIX = GLX_RENDER_TYPE;
GLX_X_RENDERABLE_SGIX = GLX_X_RENDERABLE;
GLX_FBCONFIG_ID_SGIX = GLX_FBCONFIG_ID;
GLX_MAX_PBUFFER_WIDTH_SGIX = GLX_MAX_PBUFFER_WIDTH;
GLX_MAX_PBUFFER_HEIGHT_SGIX = GLX_MAX_PBUFFER_HEIGHT;
GLX_MAX_PBUFFER_PIXELS_SGIX = GLX_MAX_PBUFFER_PIXELS;
GLX_OPTIMAL_PBUFFER_WIDTH_SGIX = $8019;
GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX = $801A;
{ Error return values from glXGetConfig. Success is indicated by a value of 0. }
{ screen # is bad }
GLX_BAD_SCREEN = 1;
{ attribute to get is bad }
GLX_BAD_ATTRIBUTE = 2;
{ no glx extension on server }
GLX_NO_EXTENSION = 3;
{ visual # not known by GLX }
GLX_BAD_VISUAL = 4;
GLX_BAD_CONTEXT = 5;
GLX_BAD_VALUE = 6;
GLX_BAD_ENUM = 7;
{ FBConfig attribute values }
{ Generic "don't care" value for glX ChooseFBConfig attributes (except GLX_LEVEL). }
GLX_DONT_CARE = $FFFFFFFF;
{ GLX_RENDER_TYPE bits }
GLX_RGBA_BIT = $00000001;
GLX_COLOR_INDEX_BIT = $00000002;
GLX_RGBA_BIT_SGIX = GLX_RGBA_BIT;
GLX_COLOR_INDEX_BIT_SGIX = GLX_COLOR_INDEX_BIT;
{ GLX_DRAWABLE_TYPE bits }
GLX_WINDOW_BIT = $00000001;
GLX_PIXMAP_BIT = $00000002;
GLX_PBUFFER_BIT = $00000004;
GLX_WINDOW_BIT_SGIX = GLX_WINDOW_BIT;
GLX_PIXMAP_BIT_SGIX = GLX_PIXMAP_BIT;
GLX_PBUFFER_BIT_SGIX = GLX_PBUFFER_BIT;
{ GLX_CONFIG_CAVEAT attribute values }
GLX_NONE = $8000;
GLX_SLOW_CONFIG = $8001;
GLX_NON_CONFORMANT_CONFIG = $800D;
{ GLX_X_VISUAL_TYPE attribute values }
GLX_TRUE_COLOR = $8002;
GLX_DIRECT_COLOR = $8003;
GLX_PSEUDO_COLOR = $8004;
GLX_STATIC_COLOR = $8005;
GLX_GRAY_SCALE = $8006;
GLX_STATIC_GRAY = $8007;
{ GLX_TRANSPARENT_TYPE attribute values }
{ #define GLX_NONE 0x8000 }
GLX_TRANSPARENT_RGB = $8008;
GLX_TRANSPARENT_INDEX = $8009;
{ glXCreateGLXPbuffer attributes }
GLX_PRESERVED_CONTENTS = $801B;
GLX_LARGEST_PBUFFER = $801C;
{ New for GLX 1.3 }
GLX_PBUFFER_HEIGHT = $8040;
{ New for GLX 1.3 }
GLX_PBUFFER_WIDTH = $8041;
GLX_PRESERVED_CONTENTS_SGIX = GLX_PRESERVED_CONTENTS;
GLX_LARGEST_PBUFFER_SGIX = GLX_LARGEST_PBUFFER;
{ glXQueryGLXPBuffer attributes }
GLX_WIDTH = $801D;
GLX_HEIGHT = $801E;
GLX_EVENT_MASK = $801F;
GLX_WIDTH_SGIX = GLX_WIDTH;
GLX_HEIGHT_SGIX = GLX_HEIGHT;
GLX_EVENT_MASK_SGIX = GLX_EVENT_MASK;
{ glXCreateNewContext render_type attribute values }
GLX_RGBA_TYPE = $8014;
GLX_COLOR_INDEX_TYPE = $8015;
GLX_RGBA_TYPE_SGIX = GLX_RGBA_TYPE;
GLX_COLOR_INDEX_TYPE_SGIX = GLX_COLOR_INDEX_TYPE;
{ glXQueryContext attributes }
{ #define GLX_FBCONFIG_ID 0x8013 }
{ #define GLX_RENDER_TYPE 0x8011 }
GLX_SCREEN = $800C;
{ glXSelectEvent event mask bits }
GLX_PBUFFER_CLOBBER_MASK = $08000000;
GLX_PBUFFER_CLOBBER_MASK_SGIX = GLX_PBUFFER_CLOBBER_MASK;
{ GLXPbufferClobberEvent event_type values }
GLX_DAMAGED = $8020;
GLX_SAVED = $8021;
GLX_DAMAGED_SGIX = GLX_DAMAGED;
GLX_SAVED_SGIX = GLX_SAVED;
{ GLXPbufferClobberEvent draw_type values }
GLX_WINDOW = $8022;
GLX_PBUFFER = $8023;
GLX_WINDOW_SGIX = GLX_WINDOW;
GLX_PBUFFER_SGIX = GLX_PBUFFER;
{ GLXPbufferClobberEvent buffer_mask bits }
GLX_FRONT_LEFT_BUFFER_BIT = $00000001;
GLX_FRONT_RIGHT_BUFFER_BIT = $00000002;
GLX_BACK_LEFT_BUFFER_BIT = $00000004;
GLX_BACK_RIGHT_BUFFER_BIT = $00000008;
GLX_AUX_BUFFERS_BIT = $00000010;
GLX_DEPTH_BUFFER_BIT = $00000020;
GLX_STENCIL_BUFFER_BIT = $00000040;
GLX_ACCUM_BUFFER_BIT = $00000080;
GLX_FRONT_LEFT_BUFFER_BIT_SGIX = GLX_FRONT_LEFT_BUFFER_BIT;
GLX_FRONT_RIGHT_BUFFER_BIT_SGIX = GLX_FRONT_RIGHT_BUFFER_BIT;
GLX_BACK_LEFT_BUFFER_BIT_SGIX = GLX_BACK_LEFT_BUFFER_BIT;
GLX_BACK_RIGHT_BUFFER_BIT_SGIX = GLX_BACK_RIGHT_BUFFER_BIT;
GLX_AUX_BUFFERS_BIT_SGIX = GLX_AUX_BUFFERS_BIT;
GLX_DEPTH_BUFFER_BIT_SGIX = GLX_DEPTH_BUFFER_BIT;
GLX_STENCIL_BUFFER_BIT_SGIX = GLX_STENCIL_BUFFER_BIT;
GLX_ACCUM_BUFFER_BIT_SGIX = GLX_ACCUM_BUFFER_BIT;
{ Extension return values from glXGetConfig. These are also
accepted as parameter values for glXChooseVisual. }
{ visual_info extension type }
GLX_X_VISUAL_TYPE_EXT = $22;
{ visual_info extension }
GLX_TRANSPARENT_TYPE_EXT = $23;
{ visual_info extension }
GLX_TRANSPARENT_INDEX_VALUE_EXT = $24;
{ visual_info extension }
GLX_TRANSPARENT_RED_VALUE_EXT = $25;
{ visual_info extension }
GLX_TRANSPARENT_GREEN_VALUE_EXT = $26;
{ visual_info extension }
GLX_TRANSPARENT_BLUE_VALUE_EXT = $27;
{ visual_info extension }
GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28;
{ Property values for visual_type }
GLX_TRUE_COLOR_EXT = $8002;
GLX_DIRECT_COLOR_EXT = $8003;
GLX_PSEUDO_COLOR_EXT = $8004;
GLX_STATIC_COLOR_EXT = $8005;
GLX_GRAY_SCALE_EXT = $8006;
GLX_STATIC_GRAY_EXT = $8007;
{ Property values for transparent pixel }
GLX_NONE_EXT = $8000;
GLX_TRANSPARENT_RGB_EXT = $8008;
GLX_TRANSPARENT_INDEX_EXT = $8009;
{ Property values for visual_rating }
{ visual_rating extension type }
GLX_VISUAL_CAVEAT_EXT = $20;
GLX_SLOW_VISUAL_EXT = $8001;
GLX_NON_CONFORMANT_VISUAL_EXT = $800D;
{ Names for attributes to glXGetClientString. }
GLX_VENDOR = $1;
GLX_VERSION = $2;
GLX_EXTENSIONS = $3;
{ Names for attributes to glXQueryContextInfoEXT. }
{ id of share context }
GLX_SHARE_CONTEXT_EXT = $800A;
{ id of context's visual }
GLX_VISUAL_ID_EXT = $800B;
{ screen number }
GLX_SCREEN_EXT = $800C;
{ NV_float_buffer }
GLX_FLOAT_COMPONENTS_NV = $20B0;
{ GLX resources. }
type
PGLXContextID = ^GLXContextID;
GLXContextID = TXID;
PGLXPixmap = ^GLXPixmap;
GLXPixmap = TXID;
PGLXDrawable = ^GLXDrawable;
GLXDrawable = TXID;
PGLXPbuffer = ^GLXPbuffer;
GLXPbuffer = TXID;
PGLXWindow = ^GLXWindow;
GLXWindow = TXID;
PGLXFBConfigID = ^GLXFBConfigID;
GLXFBConfigID = TXID;
{ GLXContext is a pointer to opaque data. }
//GLXContext = __GLXcontextRec;
PGLXContext = ^TGLXContext;
TGLXContext = pointer;
{ GLXFBConfig is a pointer to opaque data. }
PGLXFBConfig = ^TGLXFBConfig;
TGLXFBConfig = pointer;
PGLXFBConfigSGIX = ^TGLXFBConfigSGIX;
TGLXFBConfigSGIX = pointer;
{ GLX 1.0 functions. }
function glXChooseVisual(dpy:PDisplay; screen:longint; attrib_list:Plongint):PXVisualInfo;cdecl;external;
procedure glXCopyContext(dpy:PDisplay; src:TGLXContext; dst:TGLXContext; mask: cardinal);cdecl;external;
function glXCreateContext(dpy:PDisplay; vis:PXVisualInfo; share_list:TGLXContext; direct:TBool):TGLXContext;cdecl;external;
function glXCreateGLXPixmap(dpy:PDisplay; vis:PXVisualInfo; pixmap:TPixmap):GLXPixmap;cdecl;external;
procedure glXDestroyContext(dpy:PDisplay; ctx:TGLXContext);cdecl;external;
procedure glXDestroyGLXPixmap(dpy:PDisplay; pix:GLXPixmap);cdecl;external;
function glXGetConfig(dpy:PDisplay; vis:PXVisualInfo; attrib:longint; value:Plongint):longint;cdecl;external;
function glXGetCurrentContext:TGLXContext;cdecl;external;
function glXGetCurrentDrawable:GLXDrawable;cdecl;external;
function glXIsDirect(dpy:PDisplay; ctx:TGLXContext):TBool;cdecl;external;
function glXMakeCurrent(dpy:PDisplay; drawable:GLXDrawable; ctx:TGLXContext):TBool;cdecl;external;
function glXQueryExtension(dpy:PDisplay; error_base:Plongint; event_base:Plongint):TBool;cdecl;external;
function glXQueryVersion(dpy:PDisplay; major:Plongint; minor:Plongint):TBool;cdecl;external;
procedure glXSwapBuffers(dpy:PDisplay; drawable:GLXDrawable);cdecl;external;
procedure glXUseXFont(font:TFont; first:longint; count:longint; list_base:longint);cdecl;external;
procedure glXWaitGL;cdecl;external;
procedure glXWaitX;cdecl;external;
{ GLX 1.1 functions. }
function glXGetClientString(dpy:PDisplay; name:longint):Pchar;cdecl;external;
function glXQueryServerString(dpy:PDisplay; screen:longint; name:longint):Pchar;cdecl;external;
function glXQueryExtensionsString(dpy:PDisplay; screen:longint):Pchar;cdecl;external;
{ GLX 1.2 functions. }
function glXGetCurrentDisplay:PDisplay;cdecl;external;
{ GLX 1.3 functions. }
function glXChooseFBConfig(dpy:PDisplay; screen:longint; attrib_list:Plongint; nelements:Plongint):PGLXFBConfig;cdecl;external;
function glXCreateNewContext(dpy:PDisplay; config:TGLXFBConfig; render_type:longint; share_list:TGLXContext; direct:TBool):TGLXContext;cdecl;external;
function glXCreatePbuffer(dpy:PDisplay; config:TGLXFBConfig; attrib_list:Plongint):GLXPbuffer;cdecl;external;
function glXCreatePixmap(dpy:PDisplay; config:TGLXFBConfig; pixmap:TPixmap; attrib_list:Plongint):GLXPixmap;cdecl;external;
function glXCreateWindow(dpy:PDisplay; config:TGLXFBConfig; win:TWindow; attrib_list:Plongint):GLXWindow;cdecl;external;
procedure glXDestroyPbuffer(dpy:PDisplay; pbuf:GLXPbuffer);cdecl;external;
procedure glXDestroyPixmap(dpy:PDisplay; pixmap:GLXPixmap);cdecl;external;
procedure glXDestroyWindow(dpy:PDisplay; win:GLXWindow);cdecl;external;
function glXGetCurrentReadDrawable:GLXDrawable;cdecl;external;
function glXGetFBConfigAttrib(dpy:PDisplay; config:TGLXFBConfig; attribute:longint; value:Plongint):longint;cdecl;external;
function glXGetFBConfigs(dpy:PDisplay; screen:longint; nelements:Plongint):PGLXFBConfig;cdecl;external;
procedure glXGetSelectedEvent(dpy:PDisplay; draw:GLXDrawable; event_mask:Pcardinal);cdecl;external;
function glXGetVisualFromFBConfig(dpy:PDisplay; config:TGLXFBConfig):PXVisualInfo;cdecl;external;
function glXMakeContextCurrent(display:PDisplay; draw:GLXDrawable; read:GLXDrawable; ctx:TGLXContext):TBool;cdecl;external;
function glXQueryContext(dpy:PDisplay; ctx:TGLXContext; attribute:longint; value:Plongint):longint;cdecl;external;
procedure glXQueryDrawable(dpy:PDisplay; draw:GLXDrawable; attribute:longint; value:Pcardinal);cdecl;external;
procedure glXSelectEvent(dpy:PDisplay; draw:GLXDrawable; event_mask:cardinal);cdecl;external;
{ ARB_get_proc_address }
function glXGetProcAddressARB(procName:PGLubyte):Tprocedure ;cdecl;external;
{ EXT_import_context }
procedure glXFreeContextEXT(dpy:PDisplay; ctx:TGLXContext);cdecl;external;
function glXGetContextIDEXT(ctx:TGLXContext):GLXContextID;cdecl;external;
function glXGetCurrentDrawableEXT:GLXDrawable;cdecl;external;
function glXImportContextEXT(dpy:PDisplay; contextID:GLXContextID):TGLXContext;cdecl;external;
function glXQueryContextInfoEXT(dpy:PDisplay; ctx:TGLXContext; attribute:longint; value:Plongint):longint;cdecl;external;
{ NV_vertex_array_range }
function glXAllocateMemoryNV(size:GLsizei; readfreq:GLfloat; writefreq:GLfloat; priority:GLfloat):pointer;cdecl;external;
procedure glXFreeMemoryNV(pointer:GLvoid);cdecl;external;
{ SGI_video_sync }
function glXGetVideoSyncSGI(count:Pcardinal):longint;cdecl;external;
function glXWaitVideoSyncSGI(divisor:longint; remainder:longint; count:Pcardinal):longint;cdecl;external;
function glXGetRefreshRateSGI(rate:Pcardinal):longint;cdecl;external;
{ SGIX_swap_group }
procedure glXJoinSwapGroupSGIX(dpy:PDisplay; drawable:GLXDrawable; member:GLXDrawable);cdecl;external;
{ SGIX_swap_barrier }
procedure glXBindSwapBarrierSGIX(dpy:PDisplay; drawable:GLXDrawable; barrier:longint);cdecl;external;
function glXQueryMaxSwapBarriersSGIX(dpy:PDisplay; screen:longint; max:Plongint):TBool;cdecl;external;
{ SGIX_fbconfig }
function glXGetFBConfigAttribSGIX(dpy:PDisplay; config:TGLXFBConfigSGIX; attribute:longint; value_return:Plongint):longint;cdecl;external;
function glXChooseFBConfigSGIX(dpy:PDisplay; screen:longint; attrib_list:Plongint; nelements:Plongint):PGLXFBConfigSGIX;cdecl;external;
function glXCreateGLXPixmapWithConfigSGIX(dpy:PDisplay; config:TGLXFBConfigSGIX; pixmap:TPixmap):GLXPixmap;cdecl;external;
function glXCreateContextWithConfigSGIX(dpy:PDisplay; config:TGLXFBConfigSGIX; render_type:longint; share_list:TGLXContext; direct:TBool):TGLXContext;cdecl;external;
function glXGetVisualFromFBConfigSGIX(dpy:PDisplay; config:TGLXFBConfigSGIX):PXVisualInfo;cdecl;external;
function glXGetFBConfigFromVisualSGIX(dpy:PDisplay; vis:PXVisualInfo):TGLXFBConfigSGIX;cdecl;external;
{ SGIX_pbuffer }
function glXCreateGLXPbufferSGIX(dpy:PDisplay; config:TGLXFBConfig; width:cardinal; height:cardinal; attrib_list:Plongint):GLXPbuffer;cdecl;external;
procedure glXDestroyGLXPbufferSGIX(dpy:PDisplay; pbuf:GLXPbuffer);cdecl;external;
procedure glXQueryGLXPbufferSGIX(dpy:PDisplay; pbuf:GLXPbuffer; attribute:longint; value:Pcardinal);cdecl;external;
procedure glXSelectEventSGIX(dpy:PDisplay; drawable:GLXDrawable; mask:cardinal);cdecl;external;
procedure glXGetSelectedEventSGIX(dpy:PDisplay; drawable:GLXDrawable; mask:Pcardinal);cdecl;external;
{ Should these go here, or in another header? }
{ GLX Events }
type
PGLXPbufferClobberEvent = ^GLXPbufferClobberEvent;
GLXPbufferClobberEvent = record
event_type : longint; { GLX_DAMAGED or GLX_SAVED }
draw_type : longint; { GLX_WINDOW or GLX_PBUFFER }
serial : cardinal; { # of last request processed by server }
send_event : TBool; { true if this came for SendEvent request }
display : PDisplay; { display the event was read from }
drawable : GLXDrawable; { XID of Drawable }
buffer_mask : cardinal; { mask indicating which buffers are affected }
aux_buffer : cardinal; { which aux buffer was affected }
x : longint;
y : longint;
width : longint;
height : longint;
count : longint; { if nonzero, at least this many more }
end;
P__GLXEvent = ^T__GLXEvent;
T__GLXEvent = record
case longint of
0 : ( glxpbufferclobber : GLXPbufferClobberEvent );
1 : ( pad : array[0..23] of longint );
end;
TGLXEvent = T__GLXEvent;
PGLXEvent = ^TGLXEvent;
implementation
end.

View File

@ -1,531 +0,0 @@
{
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL, included in this distribution, *
* for details about the copyright. *
* *
* This program 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. *
* *
*****************************************************************************
Author: Mattias Gaertner
Abstract:
Provides methods and types to create gtkwidget with an opengl context.
Works very similar to gtkglarea, but completely in FreePascal, so no libs
needed.
}
unit OpenGLGtkWidget;
{$mode objfpc}{$H+}
interface
uses SysUtils, X, XUtil, XLib, glib, gdk, gtk, gl, nvGLX;
// gdkgl
const
// enum _GDK_GL_CONFIGS
GDK_GL_NONE = 0;
GDK_GL_USE_GL = 1;
GDK_GL_BUFFER_SIZE = 2;
GDK_GL_LEVEL = 3;
GDK_GL_RGBA = 4;
GDK_GL_DOUBLEBUFFER = 5;
GDK_GL_STEREO = 6;
GDK_GL_AUX_BUFFERS = 7;
GDK_GL_RED_SIZE = 8;
GDK_GL_GREEN_SIZE = 9;
GDK_GL_BLUE_SIZE = 10;
GDK_GL_ALPHA_SIZE = 11;
GDK_GL_DEPTH_SIZE = 12;
GDK_GL_STENCIL_SIZE = 13;
GDK_GL_ACCUM_RED_SIZE = 14;
GDK_GL_ACCUM_GREEN_SIZE = 15;
GDK_GL_ACCUM_BLUE_SIZE = 16;
GDK_GL_ACCUM_ALPHA_SIZE = 17;
// GLX_EXT_visual_info extension
GDK_GL_X_VISUAL_TYPE_EXT = $22;
GDK_GL_TRANSPARENT_TYPE_EXT = $23;
GDK_GL_TRANSPARENT_INDEX_VALUE_EXT = $24;
GDK_GL_TRANSPARENT_RED_VALUE_EXT = $25;
GDK_GL_TRANSPARENT_GREEN_VALUE_EXT = $26;
GDK_GL_TRANSPARENT_BLUE_VALUE_EXT = $27;
GDK_GL_TRANSPARENT_ALPHA_VALUE_EXT = $28;
type
TGdkGLContext = record end;
PGdkGLContext = ^TGdkGLContext;
// GLX_EXT_visual_info extension
function gdk_gl_query: boolean; cdecl;
function gdk_gl_get_info: string; cdecl;
function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual; cdecl;
function gdk_gl_get_config(visual: PGdkVisual; attrib: longint):longint; cdecl;
function gdk_gl_context_new(visual: PGdkVisual): PGdkGLContext; cdecl;
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
direct: Integer): PGdkGLContext; cdecl;
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
sharelist: PGdkGLContext; direct: Integer): PGdkGLContext; cdecl;
function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext; cdecl;
procedure gdk_gl_context_unref(context:PGdkGLContext); cdecl;
function gdk_gl_make_current(drawable: PGdkDrawable;
context: PGdkGLContext): boolean; cdecl;
procedure gdk_gl_swap_buffers(drawable: PGdkDrawable); cdecl;
procedure gdk_gl_wait_gdk; cdecl;
procedure gdk_gl_wait_gl; cdecl;
{ glpixmap stuff }
type
TGdkGLPixmap = record end;
PGdkGLPixmap = ^TGdkGLPixmap;
//function gdk_gl_pixmap_new(visual:PGdkVisual; pixmap:PGdkPixmap):PGdkGLPixmap; cdecl;external;
//function gdk_gl_pixmap_ref(glpixmap:PGdkGLPixmap):PGdkGLPixmap; cdecl;external;
//procedure gdk_gl_pixmap_unref(glpixmap:PGdkGLPixmap); cdecl;external;
//function gdk_gl_pixmap_make_current(glpixmap:PGdkGLPixmap; context:PGdkGLContext):Integer; cdecl;external;
{ fonts }
//procedure gdk_gl_use_gdk_font(font:PGdkFont; first:longint; count:longint; list_base:longint); cdecl;external;
// gtkglarea
type
TGtkGlAreaMakeCurrentType = boolean;
PGtkGLArea = ^TGtkGLArea;
TGtkGLArea = record
darea: TGtkDrawingArea;
glcontext: PGdkGLContext;
end;
PGtkGLAreaClass = ^TGtkGLAreaClass;
TGtkGLAreaClass = record
parent_class: TGtkDrawingAreaClass;
end;
function GTK_TYPE_GL_AREA: TGtkType; cdecl;
function GTK_GL_AREA(obj: Pointer): PGtkGLArea; cdecl;
function GTK_GL_AREA_CLASS(klass: Pointer): PGtkGLAreaClass; cdecl;
function GTK_IS_GL_AREA(obj: Pointer): Boolean;
function GTK_IS_GL_AREA_CLASS(klass: Pointer): Boolean;
function gtk_gl_area_get_type: TGtkType; cdecl;
function gtk_gl_area_new(attrList: Plongint): PGtkWidget; cdecl;
function gtk_gl_area_share_new(attrList: Plongint; share: PGtkGLArea): PGtkWidget; cdecl;
//function gtk_gl_area_new_vargs(share:PGtkGLArea; args:array of const):PGtkWidget; cdecl;external;
//function gtk_gl_area_new_vargs(share:PGtkGLArea):PGtkWidget; cdecl;external;
function gtk_gl_area_make_current(glarea: PGtkGLArea): boolean; cdecl;
function gtk_gl_area_begingl(glarea: PGtkGLArea): boolean; cdecl;
procedure gtk_gl_area_swap_buffers(gl_area: PGtkGLArea);
implementation
var
gl_area_type: TGtkType = 0;
parent_class: Pointer = nil;
SharedArea: PGtkGLArea = nil;
type
TGdkGLContextPrivate = record
xdisplay: PDisplay;
glxcontext: TGLXContext;
ref_count: guint;
end;
PGdkGLContextPrivate = ^TGdkGLContextPrivate;
procedure g_return_if_fail(b: boolean; const Msg: string);
begin
if not b then raise Exception.Create(Msg);
end;
procedure g_return_if_fail(b: boolean);
begin
g_return_if_fail(b,'');
end;
function DefaultScreen(ADisplay: PDisplay): longint;
begin
if ADisplay=nil then ;
Result:=gdk_screen;
end;
function g_new(BaseSize, Count: integer): Pointer;
begin
Result:=g_malloc(BaseSize*Count);
end;
function get_xvisualinfo(visual: PGdkVisualPrivate): PXVisualInfo;
// IMPORTANT: remember to XFree returned XVisualInfo !!!
var
vinfo_template: TXVisualInfo;
dpy: PDisplay;
nitems_return: integer;
vi: PXVisualInfo;
begin
dpy := GDK_DISPLAY;
// 'GLX uses VisualInfo records because they uniquely identify
// a (VisualID,screen,depth) tuple.'
vinfo_template.visual := GDK_VISUAL_XVISUAL(visual);
vinfo_template.visualid := XVisualIDFromVisual(vinfo_template.visual);
vinfo_template.depth := visual^.visual.depth;
vinfo_template.screen := DefaultScreen(dpy);
vi := XGetVisualInfo(dpy, VisualIDMask or VisualDepthMask or VisualScreenMask,
@vinfo_template, @nitems_return);
// visualinfo needs to be unique
if (vi=nil) then raise Exception.Create('');
if (nitems_return<>1) then raise Exception.Create('');
Result:=vi;
end;
procedure gtk_gl_area_destroy(obj: PGtkObject); cdecl;
var
gl_area: PGtkGLArea;
begin
g_return_if_fail (obj <>nil,'');
g_return_if_fail (GTK_IS_GL_AREA(obj),'');
gl_area := GTK_GL_AREA(obj);
gdk_gl_context_unref(gl_area^.glcontext);
if Assigned(GTK_OBJECT_CLASS(parent_class)^.destroy) then
GTK_OBJECT_CLASS(parent_class)^.destroy(obj);
end;
procedure gtk_gl_area_class_init(klass: Pointer); cdecl;
var
object_class: PGtkObjectClass;
begin
parent_class := gtk_type_class(gtk_drawing_area_get_type());
g_return_if_fail(parent_class<>nil,'gtk_gl_area_class_init parent_class=nil');
object_class := PGtkObjectClass(klass);
g_return_if_fail(object_class<>nil,'gtk_gl_area_class_init object_class=nil');
object_class^.destroy := @gtk_gl_area_destroy;
end;
function gdk_gl_query: boolean; cdecl;
begin
Result:=boolean(glXQueryExtension(GDK_DISPLAY,nil,nil)=true);
end;
function gdk_gl_get_info: string; cdecl;
begin
Result:='Vendor: '+glXGetClientString(GDK_DISPLAY, GLX_VENDOR)+LineEnding
+'Version: '+glXGetClientString(GDK_DISPLAY, GLX_VERSION)+LineEnding
+'Extensions: '+glXGetClientString(GDK_DISPLAY, GLX_EXTENSIONS)+LineEnding;
end;
function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual; cdecl;
var
dpy: PDisplay;
vi: PXVisualInfo;
visual: PGdkVisual;
begin
//writeln('gdk_gl_choose_visual A ');
if attrList=nil then begin
Result:=nil;
exit;
end;
//writeln('gdk_gl_choose_visual B ');
dpy := GDK_DISPLAY;
vi := glXChooseVisual(dpy,DefaultScreen(dpy), attrlist);
if (vi=nil) then begin
Result:=nil;
exit;
end;
//writeln('gdk_gl_choose_visual C ');
visual := gdkx_visual_get(vi^.visualid);
XFree(vi);
Result:=visual;
end;
function gdk_gl_get_config(visual: PGdkVisual; attrib: longint): longint; cdecl;
var
dpy: PDisplay;
vi: PXVisualInfo;
value: integer;
begin
Result:=-1;
if visual=nil then exit;
dpy := GDK_DISPLAY;
vi := get_xvisualinfo(PGdkVisualPrivate(visual));
if (glXGetConfig(dpy, vi, attrib, @value) = 0) then begin
XFree(vi);
Result:=value;
end else
XFree(vi);
end;
function gdk_gl_context_new(visual: PGdkVisual): PGdkGLContext; cdecl;
begin
Result:=gdk_gl_context_share_new(visual,nil,gtk_FALSE);
end;
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
direct: integer): PGdkGLContext; cdecl;
var
dpy: PDisplay;
vi: PXVisualInfo;
PrivateShareList: PGdkGLContextPrivate;
PrivateContext: PGdkGLContextPrivate;
glxcontext: TGLXContext;
begin
Result:=nil;
if visual=nil then exit;
dpy := GDK_DISPLAY;
vi := get_xvisualinfo(PGdkVisualPrivate(visual));
PrivateShareList:=PGdkGLContextPrivate(sharelist);
if (sharelist<>nil) then
glxcontext := glXCreateContext(dpy, vi, PrivateShareList^.glxcontext,
direct=gtk_True)
else
glxcontext := glXCreateContext(dpy, vi, nil, direct=gtk_True);
XFree(vi);
if (glxcontext = nil) then exit;
PrivateContext := g_new(SizeOf(TGdkGLContextPrivate), 1);
PrivateContext^.xdisplay := dpy;
PrivateContext^.glxcontext := glxcontext;
PrivateContext^.ref_count := 1;
Result := PGdkGLContext(PrivateContext);
end;
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
sharelist: PGdkGLContext; direct: Integer): PGdkGLContext; cdecl;
var
visual: PGdkVisual;
begin
visual := gdk_gl_choose_visual(attrlist);
if (visual<>nil) then
Result:=gdk_gl_context_share_new(visual, sharelist, direct)
else
Result:=nil;
end;
function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext; cdecl;
var
PrivateContext: PGdkGLContextPrivate;
begin
Result:=nil;
if context=nil then exit;
PrivateContext := PGdkGLContextPrivate(context);
inc(PrivateContext^.ref_count);
Result:=context;
end;
procedure gdk_gl_context_unref(context: PGdkGLContext); cdecl;
var
PrivateContext: PGdkGLContextPrivate;
begin
g_return_if_fail(context<>nil,'');
PrivateContext:=PGdkGLContextPrivate(context);
if (PrivateContext^.ref_count > 1) then
dec(PrivateContext^.ref_count)
else begin
if (PrivateContext^.glxcontext = glXGetCurrentContext()) then
glXMakeCurrent(PrivateContext^.xdisplay, None, nil);
glXDestroyContext(PrivateContext^.xdisplay, PrivateContext^.glxcontext);
g_free(PrivateContext);
end;
end;
function gdk_gl_make_current(drawable: PGdkDrawable;
context: PGdkGLContext): boolean; cdecl;
var
PrivateContext: PGdkGLContextPrivate;
begin
Result:=false;
if drawable=nil then exit;
if context=nil then exit;
PrivateContext := PGdkGLContextPrivate(context);
Result:=boolean(glXMakeCurrent(PrivateContext^.xdisplay,
GDK_WINDOW_XWINDOW(PGdkWindowPrivate(drawable)),
PrivateContext^.glxcontext)=true);
end;
procedure gdk_gl_swap_buffers(drawable: PGdkDrawable); cdecl;
begin
g_return_if_fail(drawable <> nil);
glXSwapBuffers(GDK_WINDOW_XDISPLAY(PGdkWindowPrivate(drawable)),
GDK_WINDOW_XWINDOW(PGdkWindowPrivate(drawable)));
end;
procedure gdk_gl_wait_gdk; cdecl;
begin
glXWaitX;
end;
procedure gdk_gl_wait_gl; cdecl;
begin
glXWaitGL;
end;
procedure gtk_gl_area_init(gl_area, theClass: Pointer); cdecl;
begin
if theClass=nil then ;
PGtkGLArea(gl_area)^.glcontext:=nil;
//#if GTK_CHECK_VERSION (1, 3, 1)
//gtk_widget_set_double_buffered(PGtkWidget(gl_area),gdkFALSE);
end;
function GTK_TYPE_GL_AREA: TGtkType; cdecl;
const
gl_area_type_name = 'GtkGLArea';
gl_area_info: TGtkTypeInfo = (
type_name: gl_area_type_name;
object_size: SizeOf(TGtkGLArea);
class_size: SizeOf(TGtkGLAreaClass);
class_init_func: @gtk_gl_area_class_init;
object_init_func: @gtk_gl_area_init;
reserved_1: nil;
reserved_2: nil;
base_class_init_func: nil;
);
begin
if (gl_area_type=0) then begin
gl_area_type:=gtk_type_unique(gtk_drawing_area_get_type(),@gl_area_info);
end;
Result:=gl_area_type;
end;
function GTK_GL_AREA(obj: Pointer): PGtkGLArea; cdecl;
begin
g_return_if_fail(GTK_IS_GL_AREA(obj),'');
Result:=PGtkGLArea(obj);
end;
function GTK_GL_AREA_CLASS(klass: Pointer): PGtkGLAreaClass; cdecl;
begin
g_return_if_fail(GTK_IS_GL_AREA_CLASS(klass),'');
Result:=PGtkGLAreaClass(klass);
end;
function GTK_IS_GL_AREA(obj: Pointer): Boolean;
begin
// GTK_IS_GL_AREA:=GTK_CHECK_TYPE(obj,GTK_TYPE_GL_AREA);
Result := Assigned(obj) and GTK_IS_GL_AREA_CLASS(PGtkTypeObject(obj)^.klass);
end;
function GTK_IS_GL_AREA_CLASS(klass: Pointer): Boolean;
begin
// GTK_IS_GL_AREA_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_GL_AREA);
Result := Assigned(klass) and (PGtkTypeClass(klass)^.thetype = GTK_TYPE_GL_AREA);
end;
function gtk_gl_area_get_type: TGtkType; cdecl;
begin
Result:=GTK_TYPE_GL_AREA;
end;
function gtk_gl_area_new(attrList: Plongint): PGtkWidget; cdecl;
var
Count: Integer;
CopyAttrList: Plongint;
Size: Integer;
begin
Count:=0;
while (attrList[Count]<>GDK_GL_NONE) do inc(Count);
inc(Count);
Size:=SizeOf(Integer)*Count;
GetMem(CopyAttrList,Size);
System.Move(attrList^,CopyAttrList^,Size);
Result:=gtk_gl_area_share_new(CopyAttrList,SharedArea);
FreeMem(CopyAttrList);
end;
function gtk_gl_area_share_new(attrList: Plongint; share: PGtkGLArea
): PGtkWidget; cdecl;
var
visual: PGdkVisual;
sharelist: PGdkGLContext;
glcontext: PGdkGLContext;
gl_area: PGtkGLArea;
begin
Result:=nil;
//writeln('gtk_gl_area_share_new A ');
if (share<>nil) and (not GTK_IS_GL_AREA(share)) then
exit;
{$IFNDEF win32}
//writeln('gtk_gl_area_share_new B ');
visual := gdk_gl_choose_visual(attrlist);
if (visual = nil) then exit;
{$ENDIF non win32}
//writeln('gtk_gl_area_share_new C ');
sharelist := nil;
if share<>nil then sharelist:=share^.glcontext;
glcontext := gdk_gl_context_share_new(visual, sharelist, gtk_TRUE);
if (glcontext = nil) then exit;
//writeln('gtk_gl_area_share_new D ');
{$IFNDEF win32}
// use colormap and visual suitable for OpenGL rendering
gtk_widget_push_colormap(gdk_colormap_new(visual,gtk_TRUE));
gtk_widget_push_visual(visual);
{$ENDIF non win32}
gl_area := gtk_type_new (gtk_gl_area_get_type);
gl_area^.glcontext := glcontext;
//writeln('gtk_gl_area_share_new E ',gl_area<>nil);
{$IFNDEF win32}
// pop back defaults
gtk_widget_pop_visual;
gtk_widget_pop_colormap;
{$ENDIF non win32}
Result:=PGtkWidget(gl_area);
end;
function gtk_gl_area_make_current(glarea: PGtkGLArea): boolean; cdecl;
begin
Result:=false;
if glarea=nil then exit;
if not GTK_IS_GL_AREA(glarea) then exit;
if not GTK_WIDGET_REALIZED(PGtkWidget(glarea)) then exit;
Result:=gdk_gl_make_current(PGtkWidget(glarea)^.window, glarea^.glcontext);
end;
function gtk_gl_area_begingl(glarea: PGtkGLArea): boolean; cdecl;
begin
Result:=gtk_gl_area_make_current(glarea);
end;
procedure gtk_gl_area_swap_buffers(gl_area: PGtkGLArea);
begin
g_return_if_fail(gl_area <> nil);
g_return_if_fail(GTK_IS_GL_AREA(gl_area));
g_return_if_fail(GTK_WIDGET_REALIZED(PGtkWidget(gl_area)));
gdk_gl_swap_buffers(GTK_WIDGET(gl_area)^.window);
end;
end.

View File

@ -1,211 +0,0 @@
/* XPM */
static char * tgtkglareacontrol_xpm[] = {
"18 21 187 2",
" c None",
". c #C2DAFE",
"+ c #BECEFE",
"@ c #B2C2FE",
"# c #B6CAFE",
"$ c #AABAFE",
"% c #A2AEFE",
"& c #96A2FE",
"* c #A2B2FE",
"= c #929EFE",
"- c #8E92FE",
"; c #868AFE",
"> c #8A82FE",
", c #62AAFE",
"' c #7EAAFA",
") c #A6BEFA",
"! c #AEBEFE",
"~ c #9AA2FE",
"{ c #9296FE",
"] c #7E86F6",
"^ c #3E66DE",
"/ c #064ABA",
"( c #66AAFE",
"_ c #5E96F6",
": c #5A92F6",
"< c #7E9AF6",
"[ c #92A2FA",
"} c #7E92FA",
"| c #4E76E6",
"1 c #1252C6",
"2 c #0246B2",
"3 c #06429E",
"4 c #66A2FA",
"5 c #5E8AEE",
"6 c #5A8EEE",
"7 c #527EE6",
"8 c #527AE6",
"9 c #2262E6",
"0 c #0252CE",
"a c #024ABA",
"b c #0642A6",
"c c #0A4296",
"d c #5286FA",
"e c #527AE2",
"f c #5276DA",
"g c #4272E2",
"h c #0A5ADE",
"i c #024EBE",
"j c #0246AA",
"k c #063A92",
"l c #06367E",
"m c #FEDADA",
"n c #FACECE",
"o c #3E76EE",
"p c #5272DA",
"q c #4E6ED6",
"r c #3A5AC6",
"s c #0A4EC2",
"t c #0646AA",
"u c #063E92",
"v c #06327A",
"w c #062E72",
"x c #FEC2C2",
"y c #F6B6B6",
"z c #3266DE",
"A c #4A66CE",
"B c #4A62CA",
"C c #0A46AE",
"D c #063686",
"E c #062E6A",
"F c #0A2656",
"G c #FEB6B6",
"H c #F6A6AA",
"I c #4662CE",
"J c #425ACA",
"K c #3E52C2",
"L c #324EB6",
"M c #0A3272",
"N c #12223E",
"O c #FE6666",
"P c #FE8686",
"Q c #FEAAAA",
"R c #FEAEB2",
"S c #FEA6A2",
"T c #E67E7E",
"U c #864666",
"V c #4A4EAA",
"W c #3E4ABA",
"X c #2E42AA",
"Y c #0A368A",
"Z c #0E2652",
"` c #223E46",
" . c #5A6E26",
".. c #FA4E4E",
"+. c #F64646",
"@. c #F64A4A",
"#. c #F66E72",
"$. c #F28A86",
"%. c #DA6E6E",
"&. c #862626",
"*. c #461206",
"=. c #3A529A",
"-. c #0A2E6E",
";. c #425A32",
">. c #5E8222",
",. c #5E9626",
"'. c #629622",
"). c #F24242",
"!. c #EE3E3E",
"~. c #EE3A3A",
"{. c #E63232",
"]. c #9E0A0A",
"^. c #6A0202",
"/. c #72DE3E",
"(. c #96EE6A",
"_. c #5ADA26",
":. c #6EB23E",
"<. c #6ABA3E",
"[. c #66BA3E",
"}. c #5EBE32",
"|. c #4AA21E",
"1. c #367A0E",
"2. c #EE4242",
"3. c #E63636",
"4. c #A60606",
"5. c #7A0206",
"6. c #3ECE02",
"7. c #3ECA0A",
"8. c #76E64A",
"9. c #8AFE62",
"0. c #76FA4E",
"a. c #62DA3A",
"b. c #329616",
"c. c #1E6E06",
"d. c #1A6206",
"e. c #E63632",
"f. c #E62E2E",
"g. c #E22626",
"h. c #960206",
"i. c #6E0206",
"j. c #3EC606",
"k. c #3AC606",
"l. c #36BA02",
"m. c #32B602",
"n. c #4EC226",
"o. c #36961E",
"p. c #1E7206",
"q. c #1A6202",
"r. c #165E02",
"s. c #1A5A06",
"t. c #EA3636",
"u. c #E22E2E",
"v. c #DE2A2A",
"w. c #D61E1E",
"x. c #820202",
"y. c #560206",
"z. c #36B606",
"A. c #32AE06",
"B. c #2EA206",
"C. c #1E6606",
"D. c #1A5E06",
"E. c #165606",
"F. c #164E06",
"G. c #420206",
"H. c #32AA06",
"I. c #2EA606",
"J. c #269606",
"K. c #124606",
"L. c #5E0206",
"M. c #2AA206",
"N. c #2A9E06",
"O. c #268E06",
"P. c #165206",
"Q. c #164A06",
"R. c #123E06",
"S. c #2AA606",
"T. c #2A9A06",
"U. c #228606",
"V. c #124E06",
"W. c #124206",
"X. c #0E3A06",
"Y. c #123606",
"Z. c #228A06",
"`. c #1A7A06",
" + c #0E3E06",
".+ c #1A6E06",
"++ c #0E3606",
" . + ",
" @ @ # $ % & ",
" @ @ @ @ @ * = - ; > ",
" , ' ) ! % ~ { ] ^ / ",
" ( _ : < [ } | 1 2 3 ",
" 4 5 6 7 8 9 0 a b c ",
" d 7 e f g h i j k l ",
" m n o f p q r s t u v w ",
" x x x y z q A B r C k D E F ",
"x x x x G H I B J K L c v M F N ",
"O P Q G R S T U V W X Y w Z ` . ",
"..+.@.#.$.%.&.*.*.*.=.-.` ;. .>.,.'.",
"@.).!.~.{.].^.*./.(._.:.:.<.[.}.|.1.",
"2.!.3.3.{.4.5.*.6.7._.8.9.0.a.b.c.d.",
"!.e.{.f.g.h.i.*.j.k.l.m.n.o.p.q.r.s.",
"t.u.v.g.w.x.y.*.l.z.z.A.B.r.C.D.E.F.",
" w.w.w.i.G.*.z.H.I.I.J.D.D.E.F.K.",
" w.L. H.I.M.N.O.E.P.Q.K.R.",
" S.T.J.O.U.Q.V.W.X.Y.",
" Z.Z.`.W. +X. ",
" .+++ "};

View File

@ -7,12 +7,11 @@
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
<AlwaysBuild Value="True"/>
</Flags>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="1"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<LazDoc Paths=""/>
<Units Count="2">
@ -25,7 +24,7 @@
<UsageCount Value="134"/>
</Unit0>
<Unit1>
<CursorPos X="23" Y="110"/>
<CursorPos X="45" Y="109"/>
<EditorIndex Value="0"/>
<Filename Value="mainunit.pas"/>
<ComponentName Value="Form1"/>

View File

@ -7,13 +7,13 @@ unit LazOpenGLContext;
interface
uses
OpenGLContext, LazarusPackageIntf;
openglcontext, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('OpenGLContext', @OpenGLContext.Register);
RegisterUnit('openglcontext', @openglcontext.Register);
end;
initialization