00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "pandabase.h"
00016
00017 #ifdef HAVE_SDL
00018
00019 #include "tinySDLGraphicsPipe.h"
00020 #include "tinySDLGraphicsWindow.h"
00021 #include "tinyGraphicsStateGuardian.h"
00022 #include "config_tinydisplay.h"
00023 #include "frameBufferProperties.h"
00024
00025 TypeHandle TinySDLGraphicsPipe::_type_handle;
00026
00027
00028
00029
00030
00031
00032 TinySDLGraphicsPipe::
00033 TinySDLGraphicsPipe() {
00034 _is_valid = true;
00035
00036 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
00037 tinydisplay_cat.error()
00038 << "Cannot initialize SDL video.\n";
00039 _is_valid = false;
00040 }
00041 }
00042
00043
00044
00045
00046
00047
00048 TinySDLGraphicsPipe::
00049 ~TinySDLGraphicsPipe() {
00050 if (SDL_WasInit(SDL_INIT_VIDEO)) {
00051 SDL_QuitSubSystem(SDL_INIT_VIDEO);
00052 }
00053
00054 SDL_Quit();
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 string TinySDLGraphicsPipe::
00068 get_interface_name() const {
00069 return "TinyPanda";
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079 PT(GraphicsPipe) TinySDLGraphicsPipe::
00080 pipe_constructor() {
00081 return new TinySDLGraphicsPipe;
00082 }
00083
00084
00085
00086
00087
00088
00089 PT(GraphicsOutput) TinySDLGraphicsPipe::
00090 make_output(const string &name,
00091 const FrameBufferProperties &fb_prop,
00092 const WindowProperties &win_prop,
00093 int flags,
00094 GraphicsEngine *engine,
00095 GraphicsStateGuardian *gsg,
00096 GraphicsOutput *host,
00097 int retry,
00098 bool &precertify) {
00099 if (!_is_valid) {
00100 return NULL;
00101 }
00102
00103 TinyGraphicsStateGuardian *tinygsg = 0;
00104 if (gsg != 0) {
00105 DCAST_INTO_R(tinygsg, gsg, NULL);
00106 }
00107
00108
00109
00110 if (retry == 0) {
00111 if (((flags&BF_require_parasite)!=0)||
00112 ((flags&BF_refuse_window)!=0)||
00113 ((flags&BF_resizeable)!=0)||
00114 ((flags&BF_size_track_host)!=0)||
00115 ((flags&BF_rtt_cumulative)!=0)||
00116 ((flags&BF_can_bind_color)!=0)||
00117 ((flags&BF_can_bind_every)!=0)) {
00118 return NULL;
00119 }
00120 return new TinySDLGraphicsWindow(engine, this, name, fb_prop, win_prop,
00121 flags, gsg, host);
00122 }
00123
00124
00125 return NULL;
00126 }
00127
00128 #endif // HAVE_SDL