Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement OpenGL default texture#526

Open
Fox2Code wants to merge 1 commit intoxCollateral:dev from
Fox2Code:default_texture
Open

Implement OpenGL default texture #526
Fox2Code wants to merge 1 commit intoxCollateral:dev from
Fox2Code:default_texture

Conversation

@Fox2Code
Copy link
Contributor

@Fox2Code Fox2Code commented Oct 14, 2024

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

thr3343 reacted with thumbs up emoji thr3343 reacted with rocket emoji
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.

thr3343 reacted with thumbs up emoji

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

@xCollateral xCollateral Nov 3, 2024

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
Contributor Author

@Fox2Code Fox2Code Nov 3, 2024

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
Contributor Author

@Fox2Code Fox2Code Nov 3, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor 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.

Copy link
Contributor Author

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

thr3343 and ThatMG393 reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@xCollateral xCollateral xCollateral left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /