ArthurSonzogni / smk

SMK - Simple multimedia kit - C++ WebAssembly
MIT License
125 stars 18 forks source link

added ability to transform points to screenspace when window resizes #4

Open TheMaverickProgrammer opened 3 years ago

TheMaverickProgrammer commented 3 years ago

The window resizes but the mouse position returns values that is unusable for proper tracking. I added variables to track the initial window size and then provided a utility function to transform the input position to proper screen-space values that can be used after resizing.

I updated the framebuffer example to showcase this feature

TheMaverickProgrammer commented 3 years ago

I changed the name of the function to MapPixelToCoords

Ideally this function should go into RenderTarget and use the View to project the point into the render target's view-space. This will also allow things like rotations to be mapped correctly.

Regardless if you accept or reject this merge, I am upgrading the View class to use an internal projection matrix like SFML does in order to achieve the aforementioned upgrades. You can see my progress here: https://github.com/TheMaverickProgrammer/smk/tree/feature/UpgradedViewStruct

Unfortunately my math is wrong somewhere because the projection matrix ends up skewing the screen diagonally. (I even changed where I needed to pass in the projection matrix at the shader level but reverted it since clearly something is wrong somewhere).

ArthurSonzogni commented 3 years ago

Ideally this function should go into RenderTarget and use the View to project the point into the render target's view-space. This will also allow things like rotations to be mapped correctly.

I totally agree.

Regardless if you accept or reject this merge, I am upgrading the View class to use an internal projection matrix like SFML does in order to achieve the aforementioned upgrades. You can see my progress here: https://github.com/TheMaverickProgrammer/smk/tree/feature/UpgradedViewStruct

This sounds like a good thing to do. I don't fully remember why I didn't used a glm::mat4 internally. Maybe I wanted to provide accessors like Width() and Height().

If you are facing some problems and think you can't make any progress anymore, feel free to tell me and I will try fixing the remaining problems.

TheMaverickProgrammer commented 3 years ago

I have halted working on it to finish the coding style corrections. Feel free to pull the branch and poke around. I was close. Once I'm done with coding style fixes I'll switch to that.

TheMaverickProgrammer commented 3 years ago

The end of 2020 was not kind to me and delayed me. This is just an update that I will return to this project early this year. 👍

TheMaverickProgrammer commented 3 years ago

Update: early did not happen. But I will return because I want to port my game engine to smk: https://twitter.com/OpenNetBattle

ArthurSonzogni commented 3 years ago

Update: early did not happen. But I will return because I want to port my game engine to smk: https://twitter.com/OpenNetBattle

;-) I never doubted you would come back!

The latest video of the looks really nice! A great attention to detail.

Happy to help you if there are any missing features in SMK.