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

Eframe option to repeat texture #3481

Open
JumpyLionnn opened this issue Oct 17, 2023 · 2 comments
Open

Eframe option to repeat texture #3481

JumpyLionnn opened this issue Oct 17, 2023 · 2 comments

Comments

@JumpyLionnn
Copy link

Is your feature request related to a problem? Please describe.
I wanted to create a big checker board pattern and cover the screen with it, it requires a lot of rectangles. It is slow to generate and draw that many quads every frame(i already use some caches).
In addition I wanted to flip an image visually without messing with the image crate or messing with the image data, I want to be able to negate the uv coordinates and flip the image easily.

Describe the solution you'd like
The default texture wrap mode is GL_CLAMP_TO_EDGE
I suggest an option in the NativeOptions to set the repeat texture property or maybe to set the texture wrap mode:

enum TextureWrapMode{
    Repeat,
    MirroredRepeat,
    ClampToEdge,
    ClampToBorder(Color32)
}

struct NativeOptions {
    ...
    texture_wrap_mode: TextureWrapMode // defaults to ClampToEdge
    // or
    repeat_textures: bool // defaults to false
    ...
}

It can be done with calling some OpenGL functions:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

for the clamp to border, the color can be set like that:

glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);

Describe alternatives you've considered
I considered manipulating pixels to do what I want but it would be too slow to do that, and I only need it visually, I dont need to use the flipped image for something else.
I also tried generating the checkboard pattern using the mesh API with rectangles. While it works, the performance isn't good enough for me and its not a major part of the thing I am working on.

Additional context
This is what happens when I try to flip the texture with uv:

egui::Rect { min: egui::vec2(0.0, 0.0), max: egui::vec2(-1.0, -1.0) }

image

Thank you for taking the time to review my feature request :)

@CodedNil
Copy link
Contributor

CodedNil commented Feb 2, 2024

I'm having similar issues for a project I am working on rendering textured meshes with tiling textures, when the uv coords are above or below 0 it just repeats instead of wrapping, would be great if this was an option for the Mesh struct for texture_wrap_mode

@emilk
Copy link
Owner

emilk commented Feb 2, 2024

Feel free to make a PR where you add a wrap mode to TextureOptions

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

No branches or pull requests

3 participants