sasluca / rayfork Goto Github PK
View Code? Open in Web Editor NEWC99 Game Library. XNA-like. Platform Independent. Allocator Aware.
License: The Unlicense
C99 Game Library. XNA-like. Platform Independent. Allocator Aware.
License: The Unlicense
It would be nice to have a logo for the project, experience show me that projects with a representative logo become more popular. :)
In rf_context_init
memory is allocated for extList
using malloc
in order to load all GL extension strings in memory which are read afterward.
I think that instead of loading all of them in memory and then reading them we can just get pointers to them from OpenGL one by one and never allocate.
The OpenGL21 backend seems to have a problem with font rendering.
Everything else in the example seems to work fine with the OpenGL21 backend though.
For all asset loading function we need to provide alternatives that allow for async loading of the asset.
One example of this is rf_load_font
.
rf_load_font
loads a font on the GL thread.
rf_load_font_async
is a font loading task that can be executed on a different thread.
rf_finish_load_font_async
takes the result of rf_load_font_async
and finishes the loading on the GL thread.
Look at the design of these 3 functions and try to follow that model in providing async loading for other asset types.
Also, consider separating the file IO from the actual loading in order to give the user more flexibility.
Here is a running list of things that should be addressed in this branch:
I will update this as I have time.
Hi there,
I have some problems with frame_time
in rf_context
.
rf_get_frame_time
is not impl. (error: undefined reference to `rf_get_frame_time')I used the basic_shapes example for testing.
void on_frame(void) {
// error: undefined reference to `rf_get_frame_time'
//printf("frame time %f\n", rf_get_frame_time());
printf("frame time %f %f %f %f %f\n", rf_ctx.target_time, rf_ctx.current_time,
rf_ctx.draw_time, rf_ctx.previous_time, rf_ctx.frame_time);
printf("fps %d\n", rf_get_fps());
rf_begin_drawing();
//...
rf_draw_fps(5, 5);
rf_end_drawing();
}
Output:
frame time 0.016667 22425.000000 0.000000 22425.000000 0.000000
fps -2147483648
frame time 0.016667 22425.000000 0.000000 22425.000000 0.000000
fps -2147483648
frame time 0.016667 22426.000000 0.000000 22426.000000 1.000000
fps 1
frame time 0.016667 22426.000000 0.000000 22426.000000 0.000000
fps -2147483648
...
frame time 0.016667 22429.000000 0.000000 22429.000000 0.000000
fps -2147483648
Environment:
As the title says, the io and time functions should have a sane default implementation but the user should be allowed to override them.
I tried using this library today and I couldn't find any working examples. I looked into the tests directory and found this
int main() {
// Init glfw and opengl
glfwInit();
GLFWwindow* window = glfwCreateWindow(800, 450, "rayfork simple glfw example", NULL, NULL);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
gladLoadGL();
// Init rayfork
rf_context rf_ctx = {0};
rf_default_render_batch rf_mem = {0};
rf_init(&rf_ctx, &rf_mem, 800, 450, RF_DEFAULT_OPENGL_PROCS);
// Load a texture with the default libc allocator and io callbacks.
rf_texture2d texture = rf_load_texture_from_file_ez("bananya.png");
// Main game loop
while (!glfwWindowShouldClose(window))
{
// Render the image and clear the background to some nice shade of white
rf_begin();
rf_clear(RF_RAYWHITE);
rf_draw_rectangle(0, 0, 100, 100, RF_RED);
rf_draw_texture(texture, 0, 0, RF_WHITE);
rf_end();
glfwPollEvents();
glfwSwapBuffers(window);
}
}
But no function named rf_init
is either in rayfork.h or rayfork.c and no macro RF_DEFAULT_OPENGL_PROCS was definied. So is there an API or tutorial somewhere how to create a valid context?
We need to remove all uses of malloc/free in order to give developers full control over memory.
Right now developers can override RL_MALLOC
and RL_FREE
but that only provides basic support for custom memory management.
All functions that allocate should ask for buffers from the user in which they can write or for allocators.
Logging is used heavily in Raylib and all the TraceLog
calls were kept in Rayfork.
It might be useful to minimize their use and keep only the important logging bits.
We should also remove all instances where logging is used instead of error handling.
It would be great to have a permissive license assigned, for example MIT.
Al intentar conpilar rayfork me muestra este error.
src/egdklib/src/core.o:core.c:(.text+0x5c2cd): referencia a `rf_get_time' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c2cd): reubicación truncada para ajustar: R_X86_64_PC32 contra el símbolo `rf_get_time' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c3c3): referencia a `rf_get_time' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c3c3): reubicación truncada para ajustar: R_X86_64_PC32 contra el símbolo `rf_get_time' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c4c4): referencia a `rf_wait' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c4c4): reubicación truncada para ajustar: R_X86_64_PC32 contra el símbolo `rf_wait' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c4d3): referencia a `rf_get_time' sin definir
src/egdklib/src/core.o:core.c:(.text+0x5c4d3): reubicación truncada para ajustar: R_X86_64_PC32 contra el símbolo `rf_get_time' sin definir
collect2: error: ld devolvió el estado de salida 1
make: *** [Makefile:18: bin/EGDKEd] Error 1
`
I quite like your direction and philosophy with rayfork. I was wondering if you have any intention on supporting TCC in the future? In theory it should be possible, but I'm not as experienced with these sort of things.
Developers should have the option to not include a dependency and functions dependent on that dependency should just be #ifdef
-ed out.
This should probably something like this:
#define RF_DONT_USE_X //Disables library X
#include "rayfork_renderer.h"
When a user defines RF_DONT_USE_X
, library X
should no longer be loaded and all functions that depend on it should be removed using #ifdef
.
Since rayfork aims to not provide any platform layers it can be very useful to provide optional ones or examples that developers can use.
Particularly on platforms like iOS and Android where it can be harder to find libraries that provide platform layer support.
Currently, there is a simple CMake file used to build the examples and a batch script that invokes the cl
msvc compiler from the command line.
We need to add support for more compilers in the build scripts (eg: gcc and clang) and maybe support to build the examples with more build systems (eg: Make, premake, gradle).
rAudio is very useful and is next in line to be added to rayfork.
We should consider moving the renderer to something like sokol_gfx or sokol_gl in order to provide graphics backends for Metal and DirectX.
Particularly, providing a Metal backend is important because OpenGL is deprecated on iOS and MacOS.
This would be a big change however and add an extra dependency.
Currently, the examples don't compile on macos because objective-c reference counting needs to be enabled.
First, rayfork refuses to compile with sokol because glad is imported after sokol, which includes it's own GL, which makes glad refusing to compile, as OpenGL is already imported.
To fix it, you need to include glad before sokol in `https://github.com/SasLuca/rayfork/blob/rayfork-0.9/tests/platform-independent-tests/platform-layers/sokol/sokol-main.c#L8
Another issue is missing symbols (as required by e.g sokol).
target_link_libraries(m)
, this affect directly rayfork.h
target_link_libraries(X11 Xi Xcursor)
target_link_libraries(dl)
target_link_libraries(pthread)
target_link_libraries(m dl pthread X11 Xi Xcursor)
Currently, stdarg.h
is included just for the logging callback.
We can remove it and have the users of the logging function create a string on the stack with the data formatted inside it and pass that to rf_trace_log
.
Example:
rf_trace_log(rf_ctx, rf_log_info, "[TEX ID %i] Default font loaded successfully", rf_ctx->default_font.texture.id);
Would become this:
char log_buffer[1024]; //Or some smaller value
snprintf(log_buffer, 1024, "[TEX ID %i] Default font loaded successfully", rf_ctx->default_font.texture.id);
rf_trace_log(rf_ctx, rf_log_info, log_buffer);
We want to minimise the amount of includes, especially in the interface
region. If we can remove all includes in the interface
region that would be even better.
It can be very useful to have a dedicated C++ wrapper that can also provide some utilities using C++ features like function overloading or default parameters (eg: allocator parameters can default to the heap allocator).
This wrapper can do the following:
rf_
.constexpr
for all the constants instead of macros.rf_context
into a class with methods.What to avoid:
I'd like the idea of raylib for iOS and consoles
sad
All functions that ask for buffers from the user should also ask for the size.
This is particularly a problem with functions that take const char*
since they usually rely on strlen
to get the size.
We don't want that, so we need to check every function that has buffers as parameters and ensure it also asks for the size of the buffer.
Currently, we have the same math functions from Raylib.
This, however, adds bloat to the API and the functions do not support SIMD (SEE and NEON).
Maybe it would be a good idea to move to another math library like Handmade Math since it is well maintained and has SEE support (though no NEON support apparently).
If anyone has better suggestions or ideas regarding this please mention them.
We could also just add SEE and NEON support to the math functions.
The OpenGL1 backend doesn't seem to work at all, the program doesn't crash, but nothing renders.
Functions that do IO can be kept for convenience, but we should always have versions that ask for buffers loaded by the user instead.
This might be particularly hard in certain functions that read multiple files or parse the filepath and then look for other files.
There are a lot of examples for Raylib that can be ported to Rayfork.
This can also help with testing the library for bugs so working on this is very important.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.