Skip to main content
corrected spelling
Link

How can I render a texture in a specific x/y position inon the screen? (OpenGL - glium)

Source Link

How can I render a texture in a specific x/y position in the screen? (OpenGL - glium)

I am in the process of writing a 2D game in Rust, and decided to use glium for the graphics part. So far I'm doing fine, able to render textures and shapes perfectly.

Now comes the most important part where I get the mouse coordinates, and then whenever I click, a texture will be placed under the mouse cursor. I've implemented the first two parts of listening on mouse movement and mouse down events, so now I have to load the texture and pass it's position on the vertex buffer.

From my understanding, I have to convert my mouse's X and Y from window coordinates to OpenGL coordinates (-1, 1), then pass those to the vertex buffer. This still doesn't make any sense on my head though.

(You can reply even if you do not know about glium; I know how to implement raw OpenGL calls to glium calls).