Skip to content

Fix SlicedTexture drawing logic to resolve GL1280 errors#194

Open
NealDeal34 wants to merge 7 commits into
GTNewHorizons:masterfrom
NealDeal34:patch-2
Open

Fix SlicedTexture drawing logic to resolve GL1280 errors#194
NealDeal34 wants to merge 7 commits into
GTNewHorizons:masterfrom
NealDeal34:patch-2

Conversation

@NealDeal34

Copy link
Copy Markdown

Fixes frequent GL1280 OpenGL errors when BetterQuesting's animated quest boxes are rendered with the Angelica mod. The issue occurred because SlicedTexture modified global OpenGL state without restoring it, used a 4-parameter blend function incompatible with some LWJGL 2 environments, and passed invalid color values from dynamic alpha calculations. This state leakage polluted subsequent render calls, triggering Angelica's strict state validation during post-render checks.
The fix replaces the 4-parameter blend function with the universally compatible 2-parameter version and sanitizes color values to prevent illegal parameters.
This fix was developed with AI assistance due to my limited OpenGL expertise, but it seems to work well.

Reference Error Log:
[Client thread/ERROR]: ########## GL ERROR ##########
[Client thread/ERROR]: @ Post render
[Client thread/ERROR]: 1280: Invalid enum
Test Environment:
GPU: NVIDIA GTX 1650 (Driver 595.79)
Java: 25
Angelica: 2.1.14
NotEnoughItems: 2.8.84-GTNH
lwjgl3ify: 3.0.15
Draconic Evolution: 1.5.19-GTNH

@NealDeal34 NealDeal34 changed the title Refactor SlicedTexture drawing logic to improve compatibility Fix SlicedTexture drawing logic to resolve GL1280 errors Apr 1, 2026

@UltraProdigy UltraProdigy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, two minor things

@NealDeal34

Copy link
Copy Markdown
Author

I tried adding a single GL11.glGetError() at method entry to defensively discard potential upstream pollution (not a loop, so genuine errors in this class remain visible).

I tried to figure out the root cause of the GL_INVALID_ENUM under Angelica's strict validation, but this minimal defensive approach resolves the issue while keeping the rendering logic intact. Logs show quest boxes render correctly without GL errors.

@NealDeal34 NealDeal34 requested a review from UltraProdigy April 29, 2026 07:42

@UltraProdigy UltraProdigy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In addition to my comments, I'm curious why you removed a bunch of the commented out lines? You say you used AI for assistance did you just tell it to remove all comments and it got these by mistake?

public void drawTexture(int x, int y, int width, int height, float zLevel, float partialTick, IGuiColor color) {
if (width <= 0 || height <= 0) return;

GL11.glGetError();

@UltraProdigy UltraProdigy May 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we have this line in here? It's basically functioning as an error eraser right now which I don't see as beneficial.


GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the purpose of doing this? You stated in your description that you wanted to change this to a universal 2 parameter function but you've kept it as a 4 parameter function and just replaced pre-defined constants with their magic number variants?


GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question

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.

3 participants