PDA

View Full Version : DivBlitz Opengl 2D Game LIb



djoker
09-11-2006, 07:59 PM
Hi ppl this is my new lib :) with 1 simple game demo.

http://www.keepmyfile.com/download/847d801177372/DivSpacer.rar

http://www.keepmyfile.com/thumb/1163094003e88e32.gif (http://www.keepmyfile.com/image/e88e321177373) http://www.keepmyfile.com/thumb/11630940047798a8.gif (http://www.keepmyfile.com/image/7798a81177374) http://www.keepmyfile.com/thumb/116309400445bbfd.gif (http://www.keepmyfile.com/image/45bbfd1177375)

DirectInput : Mouse And KeyBoard,
DirectSound: Mp3,mod,s3m,wav,
Opengl :Blit functions;

procedure DivImage_Draw(Texture: PDivText;x,y,scaleX,ScaleY:single;angle:single;Col or:TColor4f;FBlendingMode:TBlendingMode);stdcall;e xternal 'DivBlitz.dll';

procedure DivImage_DrawRect(Texture: PDivText;Rect:Trect;x,y,scaleX,ScaleY:single;angle :single;Color:TColor4f;FBlendingMode:TBlendingMode );stdcall;external 'DivBlitz.dll';

procedure DivDraw_SubRect(Texture:
PDivText;x,y,SCallX,SCallY:single;SRect:TRECT;Colo r:TColor4f;FBlendingMode:TBlendingMode);stdcall;ex ternal 'DivBlitz.dll';

procedure DivDraw_SubRectTransform(Texture: PDivText;x,y:single;FlipV,FlipH:boolean;scaleX,Sca leY:single;CenterX, CenterY,angle:single;SRect:TRECT;Color:TColor4f;FB lendingMode:TBlendingMode);stdcall;external 'DivBlitz.dll';

procedure DivImage_DrawScroll(Texture: PDivText;R:Trect;UFactor,VFactor,ScrolXfactor,Scro lYFactor:single;x,y:single;Color:TColor4f;FBlendin gMode:TBlendingMode);stdcall;external 'DivBlitz.dll';

Particle class and Sprite Engine ...


is just 1 alpha release dont expect much...



ps:sorry 4 my bad english :oops:

djoker
09-11-2006, 07:59 PM
unit DivBlitz;

interface
uses
windows,classes,sysutils,opengl;


const
Div_PI: Single = 3.141592654;

//************************************************** ********************

type TBlendingMode = (bmOpaque, bmTransparency, bmAdditive,
bmAlphaTest50, bmAlphaTest100, bmModulate,bmInvert);



type
PDivText=^DivText;
DivText=record
texture:integer;
Width,Height : integer;
rWidth,rHeight : integer;
end;

//************************************************** ********************

Vec2d=record
x,y:single;
end;


//************************************************** ********************

type
vertices=record
x,y,z:single;
end;
TColor4f =array[0..3]of single;
TColor4=record
red,green,blue,alpha:single;
end;
TColor3=record
red,green,blue:single;
end;


const



clrTransparent : TColor4f = (0, 0, 0, 0);
clrBlack : TColor4f = (0, 0, 0, 1);
clrWhite : TColor4f = (1, 1, 1, 1);
clrDimGray : TColor4f = (0.329412, 0.329412, 0.329412, 1);
clrGray : TColor4f = (0.752941, 0.752941, 0.752941, 1);
clrLightGray : TColor4f = (0.658824, 0.658824, 0.658824, 1);
clrAquamarine : TColor4f = (0.439216, 0.858824, 0.576471, 1);
clrBlueViolet : TColor4f = (0.62352, 0.372549, 0.623529, 1);
clrBrown : TColor4f = (0.647059, 0.164706, 0.164706, 1);
clrCadetBlue : TColor4f = (0.372549, 0.623529, 0.623529, 1);
clrGold : TColor4f = (0.8, 0.498039, 0.196078, 1);
clrMaroon : TColor4f = (0.556863, 0.137255, 0.419608, 1);
clrNavy : TColor4f = (0.137255, 0.137255, 0.556863, 1);
clrPink : TColor4f = (0.737255, 0.560784, 0.560784, 1);
clrSilver : TColor4f = (0.90, 0.91, 0.98, 1);
clrGreen : TColor4f = (0, 0.5, 0, 1);
clrOlive : TColor4f = (0.5, 0.5, 1, 1);
clrPurple : TColor4f = (1, 0, 1, 1);
clrTeal : TColor4f = (0, 0.5, 0.5, 1);
clrRed : TColor4f = (1, 0, 0, 1);
clrLime : TColor4f = (0, 1, 0, 1);
clrYellow : TColor4f = (1, 1, 0, 1);
clrBlue : TColor4f = (0, 0, 1, 1);
clrFuchsia : TColor4f = (1, 0, 1, 1);
clrAqua : TColor4f = (0, 1, 1, 1);



type



TPFadeFac=(lNone,lDec,lInc);
TPFader=record
colidePlane:boolean;
planeColide:single;

LiveFade:boolean;
ScaleFade:TPFadeFac;
AlphaFade:TPFadeFac;
ColorFade:TPFadeFac;
LiveFactor,Scalefactor,AlphaFactor,ColorFactor:sin gle;

end;

ParticleSt=procedure(var Position,Velocity,Acceleration,Wind,Gravity:Vec2d; var Age:single;var Size:single;var Colors:TColor3;var Alpha:single;VAR Blendeffect:TBlendingMode;var Fader:TPFader);stdcall;



//************************************************** ********************
TDiv_WindowRender=procedure (timeDelta:single);




//************************************************** *****************
//*******************Window************************* *****************
//************************************************** *****************
function GetKey(key:integer):boolean;stdcall;external 'DivBlitz.dll';
function Div_WindowCreate(TITLE:pchar;x,y,Width, Height,PixelDepth : Integer; Fullscreen : Boolean):HWND; stdcall;external 'DivBlitz.dll';
procedure Div_WindowClose;stdcall;external 'DivBlitz.dll';
function Div_WindowGetEvents:integer;stdcall;external 'DivBlitz.dll';
Function Div_WindowSetCaption( lpString: PChar): BOOL; stdcall;external 'DivBlitz.dll';
procedure Div_WindowOnRender(evento:TDiv_WindowRender);stdca ll;external 'DivBlitz.dll';
function Div_WindowLoop:integer;stdcall;external 'DivBlitz.dll';
Function Div_WindowGetHDC:HDC;stdcall;external 'DivBlitz.dll';
procedure Div_WindowSetHDC(value: HDC);stdcall;external 'DivBlitz.dll';
function Div_WindowProcess:integer;stdcall;external 'DivBlitz.dll';
Function Div_WindowGetHandle: HWND;stdcall;external 'DivBlitz.dll';
function Div_WindowMouseX:integer;stdcall;external 'DivBlitz.dll';
function Div_WindowMouseY:integer;stdcall;external 'DivBlitz.dll';
//************************************************** *****************
//*******************RENDER************************* *****************
//************************************************** *****************
function DivRender_Init(VSync:Boolean;Bpp:integer;handle:HW ND):boolean;stdcall; external 'DivBlitz.dll';
procedure DivRender_Free;stdcall;external 'DivBlitz.dll';
procedure DivRender_Flip;stdcall;external 'DivBlitz.dll';
procedure DivRender_Clear(r,g,b:single);stdcall;external 'DivBlitz.dll';
function DivRender_GetFPS:integer;stdcall;external 'DivBlitz.dll';
function DivRender_GetTicks:single;stdcall;external 'DivBlitz.dll';
function DivRender_PrintScreen(Folder : pchar ) : integer; stdcall;external 'DivBlitz.dll';
//************************************************** *****************
//************************************************** *****************
//************************************************** *****************

procedure DivDraw_SplashScreen(x,y:single;R:trect;TextureFil e : PChar); stdcall;external 'DivBlitz.dll';

//************************************************** *****************
//*****************TEXT***************************** *****************
//************************************************** *****************

function Div_Font_Init(name:pchar;size:integer;Bold:boolean ):integer;stdcall;external 'DivBlitz.dll';
procedure Div_Font_Print(Index:integer;pX,pY : single; pText : pchar);stdcall; external 'DivBlitz.dll';
procedure Div_Font_PrintGUI(Index:integer;pX,pY : single; pText : pchar);stdcall;external 'DivBlitz.dll';
procedure Div_Font_PrintCenter(Index:integer;pX,pY : Integer; pText : pchar);stdcall;external 'DivBlitz.dll';
procedure Div_Font_Color(Index:integer;r,g,b,a:single);stdca ll;external 'DivBlitz.dll';

function Div_FontText_Init(texture:string):integer;stdcall; external 'DivBlitz.dll';
procedure Div_FontText_Print(Index:integer;x, y: single; text: pchar);stdcall;external 'DivBlitz.dll';
//procedure Div_FontText_free;stdcall;external 'DivBlitz.dll';
procedure Div_FontText_CenterPrint(x, y, z: integer; UPCasse:boolean; text: pchar);stdcall;external 'DivBlitz.dll';

//************************************************** *****************
//**********************DIVPACK********************* *****************
//************************************************** *****************


function Div_UnZip_Load(filename,Password:string):integer;s tdcall;external 'DivBlitz.dll';
procedure Div_UnZip_AddFile(PackIndex:integer;Dir,Files:stri ng);stdcall;external 'DivBlitz.dll';
procedure Div_UnZip_Close(packindex:integer);stdcall;externa l 'DivBlitz.dll';
procedure Div_UnZip_ExtractFiles(packindex:integer;ToDir:str ing);stdcall;external 'DivBlitz.dll';
procedure Div_UnZip_ExtractFile(packindex:integer;FileName,T oDir:string);stdcall;external 'DivBlitz.dll';

//************************************************** *****************

function Div_Math_RandomS( lo, hi : Single ) : Single;stdcall;external 'DivBlitz.dll';
function Div_Math_RandomI( lo, hi : integer ) : integer;stdcall;external 'DivBlitz.dll';


//************************************************** *****************
//*****************TEXTURES************************* *****************
//************************************************** *****************
procedure DivTextures_Bind(Texture:PDivText);stdcall;externa l 'DivBlitz.dll';
function DivTextures_LoadFromFile(FileName: String; TransparentColor : integer=0):PDivText;stdcall;external 'DivBlitz.dll';
function DivTextures_LoadFromPack(PackIndex:integer;FileNam e: String; TransparentColor : integer=0):PDivText;STDCALL;external 'DivBlitz.dll';
function DivTextures_FreeImage_LoadFromFile(FileName: String; TransparentColor :integer): PDivText;STDCALL;external 'DivBlitz.dll';
procedure DivTexture_Free(Texture:PDivText);stdcall;external 'DivBlitz.dll';
//************************************************** *****************
//*************************IMAGES******************* *****************
//************************************************** *****************
procedure DivImage_Draw(Texture: PDivText;x,y,scaleX,ScaleY:single;angle:single;Col or: TColor4f; FBlendingMode: TBlendingMode); stdcall; external 'DivBlitz.dll';
procedure DivImage_DrawRect(Texture: PDivText; Rect:Trect; x, y, scaleX, ScaleY: single; angle: single; Color: TColor4f; FBlendingMode: TBlendingMode); stdcall; external 'DivBlitz.dll';
procedure DivDraw_SubRect(Texture: PDivText;x,y,SCallX,SCallY:single; SRect: TRECT; Color: TColor4f; FBlendingMode: TBlendingMode); stdcall; external 'DivBlitz.dll';
procedure DivDraw_SubRectTransform(Texture: PDivText;x,y:single;FlipV,FlipH:boolean;scaleX,Sca leY:single;CenterX, CenterY,angle:single;SRect:TRECT;Color:TColor4f; FBlendingMode: TBlendingMode); stdcall; external 'DivBlitz.dll';
procedure DivImage_DrawScroll(Texture: PDivText; R: Trect; UFactor, VFactor, ScrolXfactor, ScrolYFactor: single; x, y: single; Color: TColor4f; FBlendingMode: TBlendingMode); stdcall; external 'DivBlitz.dll';
procedure DivImage_DrawTrasform(
Texture: PDivText;
X, Y, FrameWidth, FrameHeight : integer;
Color:TColor4f;
FBlendingMode:TBlendingMode;
Angle : integer;
Frame : byte = 1;
FrameCountX : byte = 1;
FrameCountY : byte = 1;
ScaleX : single = 1.0;
ScaleY : single = 1.0;
FlipX : boolean = false;
FlipY : boolean = false); stdcall;external 'DivBlitz.dll';


//************************************************** ***********
//************************************************** ***********
//***************************PARTICLEENGINE********* ***********
//************************************************** ***********
//************************************************** ***********

procedure DivPARE_Update(index:integer;time:single;ResetEven t:ParticleSt);stdcall;external 'DivBlitz.dll';
Function DivPARE_Setup (Image:PDivText;count:integer;SetEvent:ParticleSt) :integer;stdcall;external 'DivBlitz.dll';
//************************************************** ***********
//************************************************** ***********
//************************************************** ***********
//************************************************** ***********

function DivFader_FadeEnded:boolean;stdcall;external 'DivBlitz.dll';
procedure DivFader_SotpFade;stdcall;external 'DivBlitz.dll';
procedure DivFader_SetLoop(Value:boolean);stdcall;external 'DivBlitz.dll';
procedure DivFader_SetInOut(Value:boolean);stdcall;external 'DivBlitz.dll';
procedure DivFader_FadeOut(r,g,b:byte;Speed:single);stdcall; external 'DivBlitz.dll';
procedure DivFader_FadeIn(r,g,b:byte;Speed:single);stdcall;e xternal 'DivBlitz.dll';
procedure DivFader_Draw;stdcall;external 'DivBlitz.dll';
procedure DivFader_DrawinRect(rect:trect);stdcall;external 'DivBlitz.dll';

//************************************************** ***********
//************************************************** ***********
//************************************************** ***********
//************************************************** ***********


procedure DivInput_Init(Handle:integer;EnableMouse,EnableKey board:boolean);stdcall;external 'DivBlitz.dll';
procedure DivInput_Free;stdcall;external 'DivBlitz.dll';
procedure DivInput_Update;stdcall;external 'DivBlitz.dll';
function DivInput_MouseAbsX:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseAbsY:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseAbsZ:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseX:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseY:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseZ:Integer;stdcall;external 'DivBlitz.dll';
function DivInput_MouseDown(Button: Integer):Boolean;stdcall;external 'DivBlitz.dll';
function DivInput_MouseUp(Button: Integer):Boolean;stdcall;external 'DivBlitz.dll';
function DivInput_KeyDown(key:integer):boolean;stdcall;exte rnal 'DivBlitz.dll';
function DivInput_KeyUp(key:integer):boolean;stdcall;extern al 'DivBlitz.dll';
function DivInput_KeyName(key:integer):Pchar;stdcall;extern al 'DivBlitz.dll';
function DivInput_KeyPressed:boolean;stdcall;external 'DivBlitz.dll';


//************************************************** ***********
//************************************************** ***********
//************************************************** ***********
//************************************************** ***********

function DivSound_Init:boolean;stdcall;external 'DivBlitz.dll';
procedure DivSound_Free;stdcall;external 'DivBlitz.dll';
function DivSound_Load(Filename:pchar;Is3d:boolean):integer ;stdcall;external 'DivBlitz.dll';
function DivSound_Play(SoundIndex:integer;Loop:boolean):Boo lean;stdcall;external 'DivBlitz.dll';
function DivSound_Stop(SoundIndex:integer):Boolean;stdcall; external 'DivBlitz.dll';
function DivSound_SetPosition(SoundIndex:integer;x,y,z:sing le):Boolean;stdcall;external 'DivBlitz.dll';
function DivSound_SetListnerPosition(SoundIndex:integer;x,y ,z:single):Boolean;stdcall;external 'DivBlitz.dll';

//************************************************** ***********
//************************************************** ***********

procedure DivMusic_Free(MusicIndex:integer);stdcall;external 'DivBlitz.dll';
function DivMusic_Load(Filename:pchar):integer;stdcall;exte rnal 'DivBlitz.dll';
function DivMusic_SetPan(MusicIndex:integer;Value:Integer): boolean;stdcall;external 'DivBlitz.dll';
function DivMusic_SetVolume(MusicIndex:integer;Value:Intege r):boolean;stdcall;external 'DivBlitz.dll';
function DivMusic_SetPosition(MusicIndex:integer;Value:Doub le):boolean;stdcall;external 'DivBlitz.dll';
function DivMusic_GetPosition(MusicIndex:integer):Double;st dcall;external 'DivBlitz.dll';
function DivMusic_GetDuration(MusicIndex:integer):Double;st dcall;external 'DivBlitz.dll';
function DivMusic_Play(MusicIndex:integer):boolean;stdcall; external 'DivBlitz.dll';
function DivMusic_Stop(MusicIndex:integer):boolean;stdcall; external 'DivBlitz.dll';
function DivMusic_Pause(MusicIndex:integer):boolean;stdcall ;external 'DivBlitz.dll';
function DivMusic_IsPlaying(MusicIndex:integer):boolean;std call;external 'DivBlitz.dll';
procedure DivMusic_LoopIt(MusicIndex:integer);stdcall;extern al 'DivBlitz.dll';

Lowercase
09-11-2006, 08:22 PM
Can you try reupload the file, please, it seems that your file has been deleted or something...

WILL
09-11-2006, 11:34 PM
I think I just fixed the link. Should work now. Was a simple matter of a wrong character.

Your engine's specs look promising and the screenshots look good too. Any future game projects in the near future with your engine? There has to be something in the works. :)


Just a few tips with posting code on PGD. If you are going to post code, please, please, please, use either the 'pascal' tags or the 'code' tags. It'll make your code snips stand out and are much easier to see and read.

Also, when posting code, especially INSIDE the code or pascal tags, don't put in space-less lines or it will make the page way too wide and hard for people to see and navigate. They'll focus more on the new size of their browser and not your message or code. :?

These small things will help make your posts more enjoyable for others. And less distracting. :)

bigsofty
10-11-2006, 01:35 AM
The included example crashes for me.

EInvalidOp floating point exception, as soon as 1st wave of aliens come in form the left hand side.

JC_
23-01-2007, 06:08 PM
For me works example OK.

But after compille this example in FPC 2.0.4 game crash after load screen -> something bad in procedure objectsEngine.Draw; (Procedure Update_Objects(time:single); )

Exist some new version of this lib ? Or smaller example with basic code (only one object..). Thanks.

btw. this units are missed - dxgutils,divvects,divgeo