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

draw_image_quad is distorted, with two corners offset from their position #2121

Open
v-ein opened this issue Jun 27, 2023 · 0 comments · May be fixed by #2290
Open

draw_image_quad is distorted, with two corners offset from their position #2121

v-ein opened this issue Jun 27, 2023 · 0 comments · May be fixed by #2290
Labels
state: pending not addressed yet type: bug bug

Comments

@v-ein
Copy link
Contributor

v-ein commented Jun 27, 2023

Version of Dear PyGui

Version: 1.9.1
Operating System: Windows 10

My Issue/Question

Image quads rendered by draw_image_quad get distorted, with two vertices offset from what positions are specified for them. For example, if one attempts to render a square, DPG shows a parallelogram instead (see the screenshot).

To Reproduce

Steps to reproduce the behavior:

  1. Create a draw list, positioned somewhere in the middle of the window (the farther from its top left corner, the better).
  2. Add an image quad to it, specifying such vertices that you can for sure tell what shape it should have.
  3. See how some vertices end up in completely different places on the screen.

Alternatively, use the example below:

  1. Create a test image named "test.png" and put it alongside the example script.
  2. Run the script.
  3. In a correctly working version, the image must be square and its boundaries must match those of the green translucent square in front of it. If any boundaries do not match, it's a bug (see the screenshot).

Expected behavior

No unexpected shape distortion in draw_image_quad.

Screenshots/Video

image

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(width=600, height=600)
dpg.setup_dearpygui()

width, height, channels, data = dpg.load_image('test.png')

with dpg.texture_registry():
    dpg.add_static_texture(width, height, data, tag="image")

with dpg.window(label="Test", width=550, height=550):
    # Somehow drawlist ignores pos=(x, y), so we're using a group to place the
    # draw list into the desired position.  The larger the offset from (0, 0),
    # the more distorted image_quad will be.
    with dpg.group(pos=(200, 200)):
        with dpg.drawlist(width=300, height=300):
            with dpg.draw_layer(tag="main pass", depth_clipping=True, perspective_divide=True, cull_mode=dpg.mvCullMode_None):
                dpg.set_clip_space(dpg.last_item(), 0, 0, 300, 300, -1.0, 1.0)

                with dpg.draw_node(tag="cube"):
                    proj = dpg.create_orthographic_matrix(-20, 20, -20, 20, -50, 50)
                    dpg.apply_transform(dpg.last_item(), proj)

                    s = 5
                    dpg.draw_image_quad("image", (-s, -s), (s, -s), (s, s), (-s, s))

                    z = 0.1
                    # Triangles seem to be transformed properly, so we're using
                    # two triangles to simulate a square.
                    dpg.draw_triangle((-s, -s, -z), (s, s, -z), (s, -s, -z), color=(0, 0, 0, 0),  fill=(0, 255, 0, 128))
                    dpg.draw_triangle((-s, -s, -z), (-s, s, -z), (s, s, -z), color=(0, 0, 0, 0),  fill=(0, 255, 0, 128))

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant