canvas - c++ SDL - Render inside a window's particular area -
i want align game components html game.
my sdl_window
will have sdl_renderer
rendering of components. these components buttons, images , rectangle area like html canvas.
i want game rendered inside canvas, because implement "world" , "camera" affect "canvas", while gui around "canvas" rendered independently of camera.
how have renderer rendering particular area inside of window?
i can't mathematics, because want every texture rendered inside canvas, far point of view, hidden.
part of code:
sdl_window* gwindow = sdl_createwindow("title", sdl_windowpos_undefined, sdl_windowpos_undefined, 800, 600, sdl_window_shown); sdl_renderer* grenderer = sdl_createrenderer(gwindow, -1, sdl_renderer_accelerated); while (true) { sdl_renderclear(grenderer); render_gui(); // can part render_game_inside_canvas(); // ? sdl_renderpresent(grenderer); }
you can glviewport() call this:
point2d pos = get_pos(); vector2d sz = get_size(); glviewport(pos.x, screen_height-pos.y-sz.dy, sz.dx, sz.dy); obj.render(); glviewport(0,0,screen_width, screen_height);
it kinda requires know dimensions of whole screen... (the odd calculation required because glviewport keeps screen upsidedown :-)
Comments
Post a Comment