Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raylib clashes #437

Open
afxgroup opened this issue Aug 19, 2023 · 9 comments
Open

Raylib clashes #437

afxgroup opened this issue Aug 19, 2023 · 9 comments

Comments

@afxgroup
Copy link

In RayLib all functions starts with rl. And in lists.h there are some functions that has the same name. Would be possible to rename them to something different?

@ptitSeb
Copy link
Owner

ptitSeb commented Aug 19, 2023

I don't think renaming anything is the solution here. I think I build some stuff with RayLib before with gl4es (ManiaDrive use RayLib IIRC) on the Pandora and it worked fine.

@afxgroup
Copy link
Author

That's strange. There are rlColor4f, rlNormal3f and rlEnd that are in both libraries.

@ptitSeb
Copy link
Owner

ptitSeb commented Aug 19, 2023

Ah ok, I see. You can try renaming those one if you want then. Are you building a static version of gl4es?

@afxgroup
Copy link
Author

Yes. It is the static version of gl4es. What about something like rl -> gl4es

@ptitSeb
Copy link
Owner

ptitSeb commented Aug 23, 2023

there are already many gl4es_ functions,, so you might create more name colision. Try rl4es_ instead ;)

@afxgroup
Copy link
Author

afxgroup commented Apr 2, 2024

Another question regard Raylib5. When I try the shaders examples (version 100). I get the following error:

Compile error: ERROR: 57:1: 'gl4es_transpose' : function already has a body

What does it means? That it is included in both vertex and fragment shader?

@ptitSeb
Copy link
Owner

ptitSeb commented Apr 2, 2024

That's a bug in the shader transformation (from opengl to gles2). I need to have a look at that (but not sure when I'll do that).

@afxgroup
Copy link
Author

afxgroup commented Apr 2, 2024

Well, Raylib is your friend and it is really easy to compile and test.
However this happens when there is already a transpose function (f.e. https://github.com/raysan5/raylib/blob/master/examples/shaders/resources/shaders/glsl100/lighting.vs)
So this code:

    if(strstr(Tmp, "transpose(") || strstr(Tmp, "transpose ") || strstr(Tmp, "transpose\t")) {
      Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_transpose, Tmp, &tmpsize);
      gl4es_inplace_replace(Tmp, &tmpsize, "transpose", "gl4es_transpose");
      // don't increment headline count, as all variying and attributes should be created before
    }

Will insert the gl4es_transpose functions on top and rename the existent one

@afxgroup
Copy link
Author

afxgroup commented Apr 2, 2024

A possible workaround could be something like this:
Change gl4es_transpose to:

static const char* gl4es_transpose2 =
"mat2 gl4es_transpose(mat2 m) {\n"
" return mat2(m[0][0], m[1][0],\n"
"             m[0][1], m[1][1]);\n"
"}\n";

static const char* gl4es_transpose3 =
"mat3 gl4es_transpose(mat3 m) {\n"
" return mat3(m[0][0], m[1][0], m[2][0],\n"
"             m[0][1], m[1][1], m[2][1],\n"
"             m[0][2], m[1][2], m[2][2]);\n"
"}\n";

static const char* gl4es_transpose4 =
"mat4 gl4es_transpose(mat4 m) {\n"
" return mat4(m[0][0], m[1][0], m[2][0], m[3][0],\n"
"             m[0][1], m[1][1], m[2][1], m[3][1],\n"
"             m[0][2], m[1][2], m[2][2], m[3][2],\n"
"             m[0][3], m[1][3], m[2][3], m[3][3]);\n"
"}\n";

And the replace function with:

    if(strstr(Tmp, "transpose(") || strstr(Tmp, "transpose ") || strstr(Tmp, "transpose\t")) {
      if (gl4es_find_string(Tmp, "mat2 transpose") == NULL)
        Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_transpose2, Tmp, &tmpsize);
      if (gl4es_find_string(Tmp, "mat3 transpose") == NULL)
        Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_transpose3, Tmp, &tmpsize);
      if (gl4es_find_string(Tmp, "mat4 transpose") == NULL)
        Tmp = gl4es_inplace_insert(gl4es_getline(Tmp, headline), gl4es_transpose4, Tmp, &tmpsize);
      gl4es_inplace_replace(Tmp, &tmpsize, "transpose", "gl4es_transpose");
      // don't increment headline count, as all variying and attributes should be created before
    }

However this will work only if the functions are defined like mat2 transpose( (and so on) otherwise ith will not work.
A possible other solution could be:
Create a Tmp1 string and replace all \n, \t and spaces. Check for mat2transpose( and do the previous replace code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants