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

Implement OpenGL default texture #526

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

Conversation

Fox2Code
Copy link

Also I cannot initialize the defaultTexture field in the static initializer because it crashes due to cycling dependencies.

This is required to properly support Not-Enough-Crashes

@xCollateral
Copy link
Owner

As stated by OpenGL spec:

Texture names are unsigned integers. The value zero is reserved to represent the default texture for each texture target..

Your current implementation is not following that as there's only one global default texture.
At the current state it can only be used as a temporary workaround to prevent crashes in cases where the 0 value is bound.

public static void bindTexture(int id) {
boundTextureId = id;
boundTexture = map.get(id);
if (id == 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why not adding it directly to the map instead of doing that check?

Copy link
Author

Choose a reason for hiding this comment

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

I can do that, but I would have to add a direct if () statement for glDeleteTextures, as the documentations says for ID deleting texture should be a noop.

Also, I cannot move image initialization to the static initializer as VulkanImage need the static initialize of GlTexture for some reason.

Copy link
Author

Choose a reason for hiding this comment

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

@Fox2Code
Copy link
Author

Fox2Code commented Nov 3, 2024

As stated by OpenGL spec:

Texture names are unsigned integers. The value zero is reserved to represent the default texture for each texture target..

Your current implementation is not following that as there's only one global default texture.
At the current state it can only be used as a temporary workaround to prevent crashes in cases where the 0 value is bound.

Well, I implemented as close to my understanding as possible, if I'm that far from the OpenGL spec, this means I for sure don't understand what the OpenGL spec want to say by using thoses words.

I used this exact statement to guide the implementation included in this PR.

@Fox2Code
Copy link
Author

Note: @xCollateral want to do the commit himself, I keep this PR as a reminder for him.

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.

2 participants