Skip to content

[rl_gputex] fix: decouple logging and memory allocation from Raylib #5045

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sleeptightAnsiC
Copy link
Contributor

This is quite big, so maybe lets treat it more like a DRAFT than PR. I can either split it to smaller PR's or change few things. However, have in mind it may take some time. The rl_gputex.h is pretty hard to change. Currently, almost everything in it depends on headers that come from Raylib (rtextures.c and raylib.h). This PR tries to fix and document most of those problems, but it's not everything by any means. This should at least fix all the problems mentioned in #5039 Every little change should be documented in the commit message.

commit message with full change list

  • make sure that src/external/rl_gputex.h uses it's own macros for printing warnings and allocating memory
  • add few additional macros in order to decouple rl_gputex from headers that are being included by Raylib (e.g. *_MEMSET, *_NULL and so on)
  • make sure that rl_gputex uses RL_*ALLOC, TRACELOG and RLAPI macros when (and only when) being included by src/rtextures.c
  • replace LOG() and RL_GPUTEX_SHOW_LOG_INFO macros with: RL_GPUTEX_WARN and RL_GPUTEX_SHOW_WARN_INFO (this is a breaking change, but it was broken and unusable anyway, see: [rcore] LogLevel none don't stop dds warning from appearing ! #5039 (comment) )
  • fixes issue all issues mentioned in: [rcore] LogLevel none don't stop dds warning from appearing ! #5039 (comment)
  • remove logging upon successfully saving a file; Raylib does this anyway and we want rl_gputex to only print WARNings upon failures; see: https://discord.com/channels/426912293134270465/541710686468702250/1394406734306480352
  • add additional condition when saving a file; now checks for both fwrite() and fclose() failures; before it would warn about both, but only return result based on fclose()
  • add some notes about the current state of compiling rl_gputex without depending on Raylib (spoiler: it's still broken...)
  • bump rl_gputex version to 1.1 since this is a potential breaking change (only for people attempting to use it without Raylib)

Fixes: #5039
Reference: https://discord.com/channels/426912293134270465/541710686468702250/1394403611852931255

- make sure that src/external/rl_gputex.h uses it's own macros
    for printing warnings and allocating memory
- add few additional macros in order to decouple rl_gputex from headers
    that are being included by Raylib (e.g. *_MEMSET, *_NULL and so on)
- make sure that rl_gputex uses RL_*ALLOC, TRACELOG and RLAPI macros
    when (and only when) being included by src/rtextures.c
- replace LOG() and RL_GPUTEX_SHOW_LOG_INFO macros with: RL_GPUTEX_WARN
    and RL_GPUTEX_SHOW_WARN_INFO (this is a breaking change, but it was
    broken and unusable anyway, see:
    raysan5#5039 (comment) )
- fixes issue all issues mentioned in:
    raysan5#5039 (comment)
- remove logging upon successfully saving a file; Raylib does this
    anyway and we want rl_gputex to only print WARNings upon failures;
    see: https://discord.com/channels/426912293134270465/541710686468702250/1394406734306480352
- add additional condition when saving a file; now checks for both
    fwrite() and fclose() failures; before it would warn about both,
    but only return result based on fclose()
- add some notes about the current state of compiling rl_gputex
    without depending on Raylib (spoiler: it's still broken...)
- bump rl_gputex version to 1.1 since this is a potential breaking
    change (only for people attempting to use it without Raylib)

Fixes: raysan5#5039
Reference: https://discord.com/channels/426912293134270465/541710686468702250/1394403611852931255
#define RL_GPUTEX_WARN(...) TRACELOG(LOG_WARNING, "IMAGE: " __VA_ARGS__)
#define RL_GPUTEX_SHOW_WARN_INFO

// FIXME: probably, we should NOT export public functions from rl_gputex

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: probably, we should NOT export public functions from rl_gputex
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It auto detected // FIXME: just by searching the text, right? I intentionally added this note here. I can remove the note or whole #define RLGPUTEXAPI RLAPI. I've kept it for (potential) backwards compatibility.

@raysan5
Copy link
Owner

raysan5 commented Jul 15, 2025

@sleeptightAnsiC thanks for the review, definitely there is more than I expected... I need to review it carefully

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

Successfully merging this pull request may close these issues.

[rcore] LogLevel none don't stop dds warning from appearing !
2 participants