gl4es icon indicating copy to clipboard operation
gl4es copied to clipboard

Raylib clashes

Open afxgroup opened this issue 2 years ago • 9 comments

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?

afxgroup avatar Aug 19 '23 09:08 afxgroup

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.

ptitSeb avatar Aug 19 '23 10:08 ptitSeb

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

afxgroup avatar Aug 19 '23 18:08 afxgroup

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

ptitSeb avatar Aug 19 '23 18:08 ptitSeb

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

afxgroup avatar Aug 23 '23 14:08 afxgroup

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

ptitSeb avatar Aug 23 '23 14:08 ptitSeb

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?

afxgroup avatar Apr 02 '24 17:04 afxgroup

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

ptitSeb avatar Apr 02 '24 17:04 ptitSeb

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 avatar Apr 02 '24 17:04 afxgroup

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

afxgroup avatar Apr 02 '24 18:04 afxgroup