Alternatives to tapdancer c643/13/2023 ![]() GlViewport (viewport_x, viewport_y, viewport_width, viewport_height) Viewport_y = (height - viewport_height) / 2 Viewport_x = (width - viewport_width) / 2 ![]() SDL_GL_GetDrawableSize(window, &width, &height) We can compute the viewport we wish to draw in a manner similar to what we did with Cairo: ![]() OpenGL is very convenient about letting us only render to part of the screen-the glViewport function lets us pick any fraction of the window’s rectangle to be the part we render to.Īctually getting the window size is OS-specific, but if you’re using SDL or SDL2 to manage your OpenGL context, it will manage it for you. This technique is only really interesting if you’re only rendering a smallish region that can’t be meaningfully expanded, and thus need to maintain a 4:3 or 16:9 aspect ratio irrespective of the actual display size. Instead you should let the end user specify an FOV angle and then render to the aspect ratio that your drawing area has the user will just get to see more or less of your 3D world, as needed. An Initial Caveatįor most 3D applications, you really don’t want to do an aspect-corrected scaling system like this. So lets do it in 3D today instead, for a change of pace. ![]() I’ve done three posts now on freely-scaled aspect-corrected 2D images. Let’s go play with something else for a bit.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |