mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
sdl zoom
This commit is contained in:
parent
0b012b4789
commit
01a068a222
@ -132,6 +132,11 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void TinySDLGraphicsWindow::
|
void TinySDLGraphicsWindow::
|
||||||
begin_flip() {
|
begin_flip() {
|
||||||
|
int fb_xsize = get_fb_x_size();
|
||||||
|
int fb_ysize = get_fb_y_size();
|
||||||
|
|
||||||
|
if (fb_xsize == _frame_buffer->xsize) {
|
||||||
|
// No zooming is necessary--copy directly to the screen.
|
||||||
if (SDL_MUSTLOCK(_screen)) {
|
if (SDL_MUSTLOCK(_screen)) {
|
||||||
if (SDL_LockSurface(_screen) < 0) {
|
if (SDL_LockSurface(_screen) < 0) {
|
||||||
tinydisplay_cat.error()
|
tinydisplay_cat.error()
|
||||||
@ -144,6 +149,16 @@ begin_flip() {
|
|||||||
SDL_UnlockSurface(_screen);
|
SDL_UnlockSurface(_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Copy to another surface, then scale it onto the screen.
|
||||||
|
SDL_Surface *temp =
|
||||||
|
SDL_CreateRGBSurfaceFrom(_frame_buffer->pbuf, _frame_buffer->xsize, _frame_buffer->ysize,
|
||||||
|
32, _frame_buffer->linesize, 0xff0000, 0x00ff00, 0x0000ff, 0xff000000);
|
||||||
|
SDL_SetAlpha(temp, SDL_RLEACCEL, 0);
|
||||||
|
SDL_BlitSurface(temp, NULL, _screen, NULL);
|
||||||
|
SDL_FreeSurface(temp);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Flip(_screen);
|
SDL_Flip(_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +263,25 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TinySDLGraphicsWindow::supports_pixel_zoom
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns true if a call to set_pixel_zoom() will be
|
||||||
|
// respected, false if it will be ignored. If this
|
||||||
|
// returns false, then get_pixel_factor() will always
|
||||||
|
// return 1.0, regardless of what value you specify for
|
||||||
|
// set_pixel_zoom().
|
||||||
|
//
|
||||||
|
// This may return false if the underlying renderer
|
||||||
|
// doesn't support pixel zooming, or if you have called
|
||||||
|
// this on a DisplayRegion that doesn't have both
|
||||||
|
// set_clear_color() and set_clear_depth() enabled.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TinySDLGraphicsWindow::
|
||||||
|
supports_pixel_zoom() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TinySDLGraphicsWindow::close_window
|
// Function: TinySDLGraphicsWindow::close_window
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
virtual void process_events();
|
virtual void process_events();
|
||||||
virtual void set_properties_now(WindowProperties &properties);
|
virtual void set_properties_now(WindowProperties &properties);
|
||||||
|
|
||||||
|
virtual bool supports_pixel_zoom() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void close_window();
|
virtual void close_window();
|
||||||
virtual bool open_window();
|
virtual bool open_window();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user