1. Euraylib Released!

Hello all,

After working and fixing some issues with Euraylib. It is now ready to be released. You can get it here from. Euraylib Raylib is a library for the development of games and takes big inspiration from Microsoft's XNA framework. I'd like to wrap the Physah library that comes with Raylib, but it is only a header file and no DLL and the physics functions are not included the core DLL for raylib.

Simple Example

--without warning 
 
include std/machine.e 
include std/convert.e 
include Euraylib.ew 
 
atom width = 800, height = 600 
 
InitWindow(width,height,"Basic Win") 
 
	SetTargetFPS(30) 
	 
atom b = bytes_to_int({0,0,0,0}) 
 
while not WindowShouldClose()  do 
	 
	BeginDrawing() 
	 
	ClearBackground(b) 
	 
	EndDrawing() 
 
end while 
 
CloseWindow() 

Advanced Example

without warning 
 
include std/machine.e 
include std/convert.e 
 
include flags.e 
include Euraylib.ew 
 
atom w = 800, h = 450 
 
InitWindow(w,h,"Bouncing Ball") 
 
atom ball_x = GetScreenWidth() / 2 
atom ball_y = GetScreenHeight() / 2 
atom ball_speed_x = 5.0 
atom ball_speed_y = 4.0 
 
atom ball_rad = 20 
 
integer paused = 0 
integer frameCounter = 0 
 
SetTargetFPS(60) 
 
atom b = bytes_to_int({0,0,0,0}) 
atom g = bytes_to_int({0,255,0,255}) 
atom r = bytes_to_int({255,0,0,255}) 
 
while not WindowShouldClose() do 
 
	if IsKeyPressed(KEY_SPACE) and paused = 0 then 
		paused = 1 
		elsif IsKeyPressed(KEY_SPACE) and paused = 1 then 
			paused = 0 
	end if 
	 
	if paused = 0 then 
		ball_x += ball_speed_x 
		ball_y += ball_speed_y 
		 
		if ((ball_x >= (GetScreenWidth() - ball_rad)) or (ball_x <= ball_rad)) then 
			ball_speed_x *= -1.0 
		elsif ((ball_y >= (GetScreenHeight() - ball_rad)) or (ball_y <= ball_rad)) then 
			ball_speed_y *= -1.0 
		end if 
	end if 
	frameCounter += 1 
	 
	BeginDrawing() 
	 
	ClearBackground(b) 
	 
	DrawCircleV(ball_x,ball_y,ball_rad,r) 
	 
	if paused = 1  and frameCounter / 30 then 
		DrawText("PAUSED",1,20,30,g) 
	end if 
	 
	DrawFPS(1,1) 
	 
	EndDrawing() 
	 
end while 
 
CloseWindow() 
 
new topic     » topic index » view message » categorize

2. Re: Euraylib Released!

Woo hoo! I look forward to trying it out. Can I export this to mobile platforms? smile

I get this error upon attempting to run Ex1.exw with Euphoria 4.1.

<0074>:: Errors resolving the following references: 
    'bytes_to_int' (C:\Users\ckles\Projects\Euraylib-master\Ex1.exw:12) has not been declared. 
 
atom b = bytes_to_int({0,0,0,0}) 

What am I missing?

Oh... I'm running 64-bit. Maybe that's the issue...?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Euraylib Released!

Icy_Viking said...

I'd like to wrap the Physah library that comes with Raylib, but it is only a header file and no DLL and the physics functions are not included the core DLL for raylib.

Probably not gonna happen, sorry.

https://github.com/victorfisac/Physac/blob/master/src/physac.h#L42

*   NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. 
*   NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) 

The threads might not be a problem, but it won't be easy to static link without embedding directly into the interpreter itself.

-Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: Euraylib Released!

euphoric said...

Woo hoo! I look forward to trying it out. Can I export this to mobile platforms? smile

I get this error upon attempting to run Ex1.exw with Euphoria 4.1.

<0074>:: Errors resolving the following references: 
    'bytes_to_int' (C:\Users\ckles\Projects\Euraylib-master\Ex1.exw:12) has not been declared. 
 
atom b = bytes_to_int({0,0,0,0}) 

What am I missing?

Oh... I'm running 64-bit. Maybe that's the issue...?

Oops. Forgot to include std/convert.e I've added it in and uploaded to github. Try again, please. It should work this time.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Euraylib Released!

ghaberek said...
Icy_Viking said...

I'd like to wrap the Physah library that comes with Raylib, but it is only a header file and no DLL and the physics functions are not included the core DLL for raylib.

Probably not gonna happen, sorry.

https://github.com/victorfisac/Physac/blob/master/src/physac.h#L42

*   NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. 
*   NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) 

The threads might not be a problem, but it won't be easy to static link without embedding directly into the interpreter itself.

-Greg

Dang, that's too bad. Looks like it would be fairly easy to wrap besides those things.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Euraylib Released!

Awesome work! Raylib is a great library and I have enjoyed playing around with it immensely in other languages. Unfortunately I am running into a few issues.

Examples using DrawCircleV appear to be behaving strangely. For example Ex4.exw appeared to be drawing the Y coordinate to 0 and passing ball_y as the radius. I was suspicious of something weird going on since it appeared to be shifting arguments over. This made absolutely no sense, but I guessed at the following and it appeared to fix my issue and this is working properly.

The function signature in C is:

void DrawCircleV(Vector2 center, float radius, Color color) 
Current Oe wrapper is:
xDrawCircleV = define_c_proc(ray,"+DrawCircleV",{C_FLOAT,C_FLOAT,C_FLOAT,C_UINT}) 
... 
public procedure DrawCircleV(atom x,atom y,atom rad,atom col) 
 
 c_proc(xDrawCircleV,{x,y,rad,col}) 
	 
end procedure 
My janky fix(?):
xDrawCircleV = define_c_proc(ray,"+DrawCircleV",{C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_UINT}) 
... 
public procedure DrawCircleV(atom x,atom y,atom rad,atom col) 
 
 c_proc(xDrawCircleV,{x,0,y,0,rad,col}) 
	 
end procedure 
 

Why does my "fix" work?

In general it looks like I cannot get functions working properly that utilize a struct. I'm on linux using libraylib.so.2.5.0 from https://github.com/raysan5/raylib/releases.

Should there be something wrapping the Vector2 struct?

Another example is DrawTriangle:

void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) 
... 
xDrawCircleV = define_c_proc(ray,"+DrawCircleV",{C_FLOAT,C_FLOAT,C_FLOAT,C_UINT}), 
 
Oe Wrapper:
xDrawTriangle = define_c_proc(ray,"+DrawTriangle",{C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_UINT}) 
... 
public procedure DrawTriangle(atom x,atom y,atom x2,atom y2,atom x3,atom y3,atom col) 
 
 c_proc(xDrawTriangle,{x,y,x2,y2,x3,y3,col}) 
	 
end procedure 

new topic     » goto parent     » topic index » view message » categorize

7. Re: Euraylib Released!

David, you are correct. This is similar to the issue I explained here: https://openeuphoria.org/forum/134018.wc#134018

Basically, when we see a structure being passed by value, we have to expand its values as separate parameters. Since Vector2 is two floats, and floats are 32-bit values, it expands to {C_FLOAT,C_FLOAT}. This should work fine for passing structures by value, and is pretty straight-forward when the values are all 32-bit or greater. But as I pointed out in that thread, sometimes the structure members have to be packed into a larger value, which complicates things a bit (e.g. four unsigned chars becomes one unsigned int).

The bad news is that, at least until someone can go fix it in the backend, you cannot receive structures by value from an external function. I know Allegro does this. Not sure if Raylib is the same. This should be as simple as changing the return_type in define_c_func from atom to object and then we just pull more values off the stack after the function returns and return a matching result (e.g. C_UINT returns an atom, {C_UINT,C_UINT} returns {atom,atom}).

-Greg

new topic     » goto parent     » topic index » view message » categorize

8. Re: Euraylib Released!

Unfortunately the supplied raylib.dll is of no use to me (on Windows 10); running with that:

C:\Program Files (x86)\Phix>p demo\misc\Euraylib\Ex1.exw 
INFO: Initializing raylib 2.5 
WARNING: [GLFW3 Error] Code: 65543 Decription: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable 
WARNING: GLFW Failed to initialize Window 
INFO: Target time per frame: 33.333 milliseconds 

So none of the demos worked. No luck updating my graphics drivers either, btw. Same deal with both raylib-2.5.0-Win32-mingw.zip and raylib-2.5.0-Win32-msvc15.zip from https://github.com/raysan5/raylib/releases and similar or worse with raylib-2.0.0-Win32-mingw.zip and raylib-2.0.0-Win32-msvc15.zip...

Hopwever, running with C:\Program Files (x86)\Python37-32\Lib\site-packages\raylibpy\libraylib_shared.dll which I found after running pip install raylib-py, and then copying into the Euraylib folder and changing ray = open_dll("raylib.dll") in Euraylib.ew to ray = open_dll("libraylib_shared.dll"):

INFO: Initializing raylib 2.0 
INFO: Display device initialized successfully 
INFO: Display size: 1920 x 1080 
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 2.1 profile supported 
INFO: GPU: Vendor:   Intel 
INFO: GPU: Renderer: Intel(R) HD Graphics 2000 
INFO: GPU: Version:  3.1.0 - Build 9.17.10.4459 
INFO: GPU: GLSL:     1.40 - Intel Build 9.17.10.4459 
INFO: Number of supported extensions: 129 
INFO: [EXTENSION] DXT compressed textures supported 
INFO: [EXTENSION] Anisotropic textures filtering supported (max: 16X) 
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: [CPU] Default buffers initialized successfully (lines, triangles, quads) 
INFO: [VAO ID 1] Default buffers VAO initialized successfully (lines) 
INFO: [VAO ID 2] Default buffers VAO initialized successfully (triangles) 
INFO: [VAO ID 3] Default buffers VAO initialized successfully (quads) 
INFO: GL_SCISSOR_TEST enabled. 
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: Target time per frame: 16.667 milliseconds 
INFO: [TEX ID 2] Unloaded texture data from VRAM (GPU) 
INFO: [TEX ID 1] Unloaded texture data (base white texture) from VRAM 
INFO: Window closed successfully 

All five demos then worked fine. I could upload that dll to PCAN if you want, though I am pretty sure it will be binary identical to the one you can get direct from https://github.com/overdev/raylib-py anyway. Sadly I was unable to find any suitable pre-built 64-bit dlls.

In other news, phix would much prefer

--/* 
include std/machine.e 
include std/convert.e 
--*/ 

in the demos (Ex1..5.exw) and

--/* 
include std/dll.e 
--include std/convert.e 
include std/machine.e 
include std/os.e 
--*/ 

in Euraylib.ew (so that OE will open them but phix will ignore them).

PPS. Can't wait to see https://github.com/raysan5/challenges/tree/master/03_challenge_maze3d on a webpage and on Android. No rush, I can wait a couple of hours. smile

new topic     » goto parent     » topic index » view message » categorize

9. Re: Euraylib Released!

Thanks for the feedback guys. I had to make the DLL using Cmake. I had trouble getting a DLL using the Visual Studio build, so I resorted to cmake to build it. Finally I had a DLL I was able to use. I'm on Windows 7 Ultimate 64-bit. I think the DLL is 32-bit by default. As for the issue with structs, I simply made a C_FLOAT varialbe for structs like Vector2 and Vector3.

For instance if you see something where in the C code, there is a Vector2, I add C_FLOAT,C_FLOAT for the x and y vars. Same for Vector3, however, it becomes C_FLOAT, C_FLOAT, C_FLOAT for x, y and z. And so forth. These are very similar to workarounds I did when I wrote the SFML wrapper. All this struct talk, another reason to add some sort of struct to Euphoria for the next release, huh? XD!

Raylib is written in pure C according to the documentation, so it was fairly straightforward to port, minus the noted issues. The wrapper and all examples currently work on my machine. I do test them before I release them. I will try to fix any bugs or issues that may appear. Just let me know.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Euraylib Released!

I've just try it on 32-bit PeppermintOS based on Ubuntu 18.04 LTS and it works without problems. And it's exactly what I need. Thanx a lot Icy_Viking! :)

new topic     » goto parent     » topic index » view message » categorize

11. Re: Euraylib Released!

Pirx said...

I've just try it on 32-bit PeppermintOS based on Ubuntu 18.04 LTS and it works without problems. And it's exactly what I need. Thanx a lot Icy_Viking! :)

Thanks Pirx! I probably should have charged for this. Well donations are kindly accepted, just saying. Glad this library proves useful, it might also attract newcomers to Euphoria!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu