Giter Site home page Giter Site logo

sasluca / rayfork Goto Github PK

View Code? Open in Web Editor NEW
328.0 15.0 19.0 65.93 MB

C99 Game Library. XNA-like. Platform Independent. Allocator Aware.

License: The Unlicense

CMake 0.68% C 74.27% Batchfile 0.01% C++ 18.66% GLSL 0.16% Kotlin 0.02% Objective-C 2.93% Makefile 0.11% HTML 0.02% Shell 1.23% M4 0.87% Java 0.68% PowerShell 0.05% Roff 0.02% Perl 0.08% Python 0.01% Metal 0.01% Assembly 0.12% JavaScript 0.07%
raylib games-library game-engine c platform-independent cross-platform

rayfork's People

Contributors

bicycleghost avatar blueghostalt avatar oskarnp avatar sasluca 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

rayfork's Issues

Project logo?

It would be nice to have a logo for the project, experience show me that projects with a representative logo become more popular. :)

Remove allocations for extList in rf_context_init

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.

Fix OpenGL21 backend.

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.

Provie async loading for all asset types

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.

better-org branch cleanup

Here is a running list of things that should be addressed in this branch:

  • reorg roadmap : maybe a doc outlining what tasks are on the road to better-org
  • missing #include "sal.h" ... presumably this is a personal local file or something generated
  • outdated dependencies in third party
  • recommendations on top development tools (VSCode in particular, CLion optionally), any configuration needed in .vscode for include paths, plugins required or recommended for vscode
  • misc posix porting preprocessor directives needed to fix includes in some cases
  • rf_utf8_stats undefined ... appears an entire chunk of utf8.h and chars.c needs to get pulled together

I will update this as I have time.

frame_time is zero

Hi there,
I have some problems with frame_time in rf_context.

  1. rf_get_frame_time is not impl. (error: undefined reference to `rf_get_frame_time')
  2. rf_ctx.frame_time is zero

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
  1. rf_draw_fps is also wrong
    image

Environment:

  • branch: master
  • Arch Linux (64-Bit) (4.19 kernel)
  • AMD CPU, GeForce GTX 970 Graphic
  • compiled with cmake 3.16, gcc 9.2.0

Example script

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?

Remove all uses of malloc/free

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.

Minimize the use of logging

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.

referencia a `rf_get_time' sin definir ????

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

`

TCC (Tiny C Compiler) support?

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.

Allow the developers to choose their dependencies

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.

Add optional platform layers.

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.

Add build scripts for Linux

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).

Fork rAudio

rAudio is very useful and is next in line to be added to rayfork.

Add a sokol-gfx backend

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.

Add build scripts for macos

Currently, the examples don't compile on macos because objective-c reference counting needs to be enabled.

Build issues on Linux

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).

  • math stuff is missing (you mostly want it, doesn't affect musl targets) : libm needs to be imported target_link_libraries(m), this affect directly rayfork.h
  • Xorg stuff (only with X11 target) : target_link_libraries(X11 Xi Xcursor)
  • dlopen/dlclose/... : target_link_libraries(dl)
  • pthread (or crash at launch) : target_link_libraries(pthread)
    All of them gives target_link_libraries(m dl pthread X11 Xi Xcursor)

Remove stdarg.h

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);

Rationale

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.

Create C++ wrapper

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:

  • Use namespaces for all the names instead of rf_.
  • Use constexpr for all the constants instead of macros.
  • Make rf_context into a class with methods.

What to avoid:

  • RAII (aka destructors)
  • Exceptions
  • RTII
  • Virtual Dispatch

Add size parameters for all buffer parameters.

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.

Maybe use another library for math instead of the Raylib math functions?

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.

Fix OpenGL1 backend

The OpenGL1 backend doesn't seem to work at all, the program doesn't crash, but nothing renders.

Make all IO optional

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.

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.