Git Product home page Git Product logo

tazdij / raylib-pas Goto Github PK

View Code? Open in Web Editor NEW
27.0 9.0 5.0 51.68 MB

A complete header translation (binding) of the raylib 2.6.0-dev to Pascal. Without any funky helper functions for memory alignment issues. Inspired and partially based on the drezgames/raylib-pascal binding, however a little cleaner and more recent, with FPC 3.0.4 support.

GLSL 42.99% Batchfile 0.41% Pascal 55.67% Makefile 0.27% Shell 0.66%

raylib-pas's Introduction

raylib-pas A Pascal Binding for Raylib 3.0.0 (master)

raylib-pas is a header translation of the Raylib Game Development Library for the FreePascal Project.

Build

You can execute make on GNU+Linux, macOS and Windows.

Shared or Static Library

You will need to source raylib for your platform.

We assume you linked or copied the raylib shared(*.so,*.dylib,*.dll) or static(*.a) library for your platform into ./bin.

If you want to use the static library use make as follow:

make RAYLIB_LIBTYPE=STATIC

Or to build binaries you can debug:

make DEBUG=TRUE

GNU+Linux

If you use the shared library you must specify where to source the libraylib.so file.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. # adjust the export to search for the .so in the local path

If you want to link to the static library you must copy libglfw3.a and libraylib.a into ./bin.

Windows

To use make it must be in your %PATH%. fpc includes make.exe in the bin directory.

set PATH=%PATH%;C:\fpc\3.0.4\bin\x86_64-win64

Examples

Try some of the ported c to fpc examples in examples/core, examples/models, examples/audio etc.

Thanks to drezgames/raylib-pascal for the examples. Originally delphi, now fpc.

TODO

  • Eventually we will be doing some work to compile the project with static linking. Hopefully this will allow for more cross-platform compilation of raylib-pas. Mainly for Android and eventually iOS when raylib supports that.
  • Add Android and WebAssembly support.
  • Port/Create more examples and games.
  • Include Binary Distribution of "Supported" Raylib Shared Libraries with this binding.

raylib-pas's People

Contributors

guvacode avatar ludoza avatar tazdij avatar zaher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raylib-pas's Issues

macOS fpc build working but Access violation in animation_test at SetMaterialTexture

Hi,

For fun trying to build and run animation_test.pas on my macos 10.14.6.

I can compile it if I include unit math and add this snippet:

{$IFDEF DARWIN}         SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow,exZeroDivide]);
{$IFEND}  

But it seems to raise a access violation at line 31:

SetMaterialTexture(@model.materials[0], MAP_DIFFUSE, texture);

As seen below:

$ ./animation_test
INFO: Initializing raylib 2.5
INFO: Display device initialized successfully
INFO: Display size: 1440 x 900
INFO: Render size: 800 x 450
INFO: Screen size: 800 x 450
INFO: Viewport offsets: 0, 0
INFO: GPU: Vendor:   Intel Inc.
INFO: GPU: Renderer: Intel(R) HD Graphics 6000
INFO: GPU: Version:  4.1 INTEL-12.10.12
INFO: GPU: GLSL:     4.10
INFO: Number of supported extensions: 45
INFO: [EXTENSION] DXT compressed textures supported
INFO: [EXTENSION] Anisotropic textures filtering supported (max: 16X)
INFO: [EXTENSION] Debug Marker supported
INFO: [TEX ID 1] Texture created successfully (1x1 - 1 mipmaps)
INFO: [TEX ID 1] Base white texture loaded successfully
INFO: [SHDR ID 1] Shader compiled successfully
INFO: [SHDR ID 2] Shader compiled successfully
INFO: [SHDR ID 3] Shader program loaded successfully
INFO: [SHDR ID 3] Default shader loaded successfully
INFO: Internal buffers initialized successfully (CPU)
INFO: Internal buffers uploaded successfully (GPU)
INFO: OpenGL default states initialized successfully
INFO: [TEX ID 2] Texture created successfully (128x128 - 1 mipmaps)
INFO: [TEX ID 2] Default font loaded successfully
WARNING: [res/guy/guy.iqm] No meshes can be loaded, default to cube mesh
INFO: [VAO ID 2] Mesh uploaded successfully to VRAM (GPU)
WARNING: [res/guy/guy.iqm] No materials can be loaded, default to white material
INFO: [res/guy/guytex.png] Image loaded successfully (1024x1024)
INFO: [TEX ID 3] Texture created successfully (1024x1024 - 1 mipmaps)
An unhandled exception occurred at $00000001000E5587:
EAccessViolation: Access violation
  $00000001000E5587

Any suggestion?

Problem In 3d Examle

hi. problem with 3D examples. my system is linux Mint 20.
Examples swear on SetMaterialTexture.
Moreover, all examples in C++ are compiled and run without problems.

the console output:

'/home/vadim/Компоненты/raylib-pas-master/bin/models_first_person_maze'
INFO: Initializing raylib 2.6-dev
INFO: Display device initialized successfully
INFO: Display size: 1280 x 1024
INFO: Render size: 800 x 450
INFO: Screen size: 800 x 450
INFO: Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: OpenGL 3.3 Core profile supported
INFO: GPU: Vendor: NVIDIA Corporation
INFO: GPU: Renderer: GeForce GTX 750/PCIe/SSE2
INFO: GPU: Version: 3.3.0 NVIDIA 390.138
INFO: GPU: GLSL: 3.30 NVIDIA via Cg compiler
INFO: Number of supported extensions: 342
INFO: [EXTENSION] DXT compressed textures supported
INFO: [EXTENSION] ETC2/EAC compressed textures supported
INFO: [EXTENSION] Anisotropic textures filtering supported (max: 16X)
INFO: [EXTENSION] Mirror clamp wrap texture mode supported
INFO: [TEX ID 1] Texture created successfully (1x1 - 1 mipmaps)
INFO: [TEX ID 1] Base white texture loaded successfully
INFO: [SHDR ID 1] Shader compiled successfully
INFO: [SHDR ID 2] Shader compiled successfully
INFO: [SHDR ID 3] Shader program loaded successfully
INFO: [SHDR ID 3] Default shader loaded successfully
INFO: Internal buffers initialized successfully (CPU)
INFO: Internal buffers uploaded successfully (GPU)
INFO: OpenGL default states initialized successfully
INFO: [TEX ID 2] Texture created successfully (128x128 - 1 mipmaps)
INFO: [TEX ID 2] Default font loaded successfully
INFO: [res/textures/cubicmap.png] Image loaded successfully (32x16)
INFO: [TEX ID 3] Texture created successfully (32x16 - 1 mipmaps)
INFO: [VAO ID 2] Mesh uploaded successfully to VRAM (GPU)
INFO: [res/textures/cubicmap_atlas.png] Image loaded successfully (256x256)
INFO: [TEX ID 4] Texture created successfully (256x256 - 1 mipmaps)
An unhandled exception occurred at $00007F1E13F0EBD9:
EAccessViolation: Access violation
$00007F1E13F0EBD9 line 885 of /home/travis/build/raysan5/raylib/src/models.c
$0000000000402712 main, line 45 of ../models/models_first_person_maze.pas

An unhandled exception occurred at $000000000041AE97:
EAccessViolation:
An unhandled exception occurred at $000000000041AE97:
EAccessViolation:
$000000000041AE97
$0000000000412B53
$000000000042615A
$00000000004180EC
$0000000000402712

Prebuilt Binary of Raylib

I want to include a Prebuilt Binary of Raylib at the exact Commit which raylib-pas targets. This could alleviate issues with users downloading a newer "Master" than we are currently targeting and running into breaking API or Memory Layout changes in raylib. Plus this should make it simpler for Delphi/FreePascal Developers who may not have a lot of experience compiling C libraries or using CMake.

I will do my best to include the latest targeted binaries, however, I do not readily have a MacOS computer which I can use to build the raylib .dylib and .a files on. I can provide the Linux and Windows binaries.

Anyone want to help with the MacOS ones?

PlayAudioBuffer() : No audio buffer

when using TSound, the program just crashes ...

When loading, for some reason, the data is immediately unloaded.
error

my example

program sprite_explosion;

{$mode objfpc}

uses cmem, raylib, math;

const
screenWidth = 800;
screenHeight = 450;

NUM_FRAMES_PER_LINE = 5;
NUM_LINES = 5;

var
fxBoom:TSound;
explosion:TTexture2D;
position:TVector2;
frameRec: TRectangle;
frameWidth,frameHeight,currentFrame,currentLine : integer;
framesCounter:integer;
active:boolean;
begin
InitWindow(screenWidth, screenHeight, 'raylib [textures] example - Sprite explosion');
InitAudioDevice();
fxBoom := LoadSound('res/boom.wav');
explosion := LoadTexture('res/explosion.png');
frameWidth := explosion.width div NUM_FRAMES_PER_LINE; // Sprite one frame rectangle width
frameHeight := explosion.height div NUM_LINES; // Sprite one frame rectangle height
currentFrame := 0;
currentLine := 0;
frameRec.x:=0;
frameRec.y:=0;
frameRec.height:=frameHeight;
frameRec.width:=frameWidth;

position.y:=0.0;
position.x:=0.0;
active := false;
framesCounter := 0;
SetTargetFPS(120);

// Main game loop
while not WindowShouldClose() do
begin
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) and (not active) then
begin
position := GetMousePosition();
active := true;
position.x := position.x- frameWidth/2;
position.y := position.y - frameHeight/2;
PlaySound(fxBoom);
end;
// Compute explosion animation frames
if (active) then
begin
inc(framesCounter);// framesCounter++;
if (framesCounter > 2) then
begin
inc(currentFrame);// currentFrame++;
if (currentFrame >= NUM_FRAMES_PER_LINE) then
begin
currentFrame := 0;
inc(currentLine);//++;
if (currentLine >= NUM_LINES) then
begin
currentLine := 0;
active := false;
end;
end;
framesCounter := 0;
end;
end;

frameRec.x := frameWidthcurrentFrame;
frameRec.y := frameHeight
currentLine;

BeginDrawing();
ClearBackground(RAYWHITE);

if (active) then DrawTextureRec(explosion, frameRec, position, WHITE);
EndDrawing();
end;
UnloadTexture(explosion); // Unload texture
UnloadSound(fxBoom); // Unload sound
CloseAudioDevice();
CloseWindow(); // Close window and OpenGL context
end.

Windows not run game

i'm a mac and linux user, i borrowed a computer to compile the game and i couldn't run on windows

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.