Open Destructor17 opened 4 weeks ago
@Destructor17 It is implemented this way because none of the rshapes
shapes drawing funtions using RL_TRIANGLES
or RL_LINES
define texture coordinates, so they require to use the default texture. Changing this behaviour would imply adding a rlSetTexture(rlGetTextureDefault().id)
to all shapes drawing functions.
It means that fixing this bug in rlBegin will uncover a lot of other bugs in rshapes (this is one of reasons why I closed my PR).
Yeah, exactly that situation.
Is it possible to call rlSetTexture()
after rlBegin()
? I haven't looked into detail this situation so maybe that's not possible...
@raysan5 If this behaviour is expected and texture must be default if not specified, then rlEnd
should reset it, not rlBegin
. Here is a PR https://github.com/raysan5/raylib/pull/4364
Issue description
When using GL version other then 1.1 and rlBegin is called with mode which differs from previous one, it sets textuteID to RLGL.State.defaultTextureId. It is a problem because texture is set using rlSetTexture function BEFORE rlBegin is called. Possible solution is to preserve textureID whet drawing mode switches, as it is done in https://github.com/raysan5/raylib/pull/4296. Surprisingly, many functions in rshapes, such as DrawEllipse(and maybe in other modules) depends on this wrong behavior: they don't set texture while hoping it is already set to default one(ID 1). It means that fixing this bug in rlBegin will uncover a lot of other bugs in rshapes (this is one of reasons why I closed my PR).
The brightest example is textures_polygon. The current implementation works but has the following comment:
and uses quads QUADS where two last vertices are same instead of triangles.
Environment
GLFW, Linux, OpenGL ES 3.2 I guess this bug may be reproduced at any OpenGL version other than 1.1
Issue Screenshot
See code example. This is without preserving textureID (polygon is white)
And this is with preserving (ellipse is missing)
Code Example
Code of modified DrawTexturePoly. Note DrawEllipse and RL_TRIANGLES
Code(two lines at rlBegin) used to preserve texture on second screenshot can be found in https://github.com/raysan5/raylib/pull/4296