allow optional SW renderer

This commit is contained in:
cxgeorge 2002-02-22 01:10:21 +00:00
parent e1247ce046
commit bf18d91d80
4 changed files with 160 additions and 132 deletions

View File

@ -38,6 +38,9 @@ bool gl_show_fps_meter = config_wgldisplay.GetBool("show-fps-meter", false);
float gl_fps_meter_update_interval = max(0.5,config_wgldisplay.GetFloat("fps-meter-update-interval", 1.7)); float gl_fps_meter_update_interval = max(0.5,config_wgldisplay.GetFloat("fps-meter-update-interval", 1.7));
int gl_forced_pixfmt=config_wgldisplay.GetInt("gl-force-pixfmt", 0); int gl_forced_pixfmt=config_wgldisplay.GetInt("gl-force-pixfmt", 0);
bool wgl_force_sw_renderer = config_wgldisplay.GetBool("gl-force-software-renderer", false);
bool wgl_allow_sw_renderer = config_wgldisplay.GetBool("gl-allow-software-renderer", false);
bool bResponsive_minimized_fullscreen_window = config_wgldisplay.GetBool("responsive-minimized-fullscreen-window",false); bool bResponsive_minimized_fullscreen_window = config_wgldisplay.GetBool("responsive-minimized-fullscreen-window",false);
// Set this true to not attempt to use any of the function calls that // Set this true to not attempt to use any of the function calls that

View File

@ -38,6 +38,8 @@ extern int gl_forced_pixfmt;
extern bool bResponsive_minimized_fullscreen_window; extern bool bResponsive_minimized_fullscreen_window;
extern bool support_wiregl; extern bool support_wiregl;
extern bool ime_composition_w; extern bool ime_composition_w;
extern bool wgl_force_sw_renderer;
extern bool wgl_allow_sw_renderer;
extern EXPCL_PANDAGL void init_libwgldisplay(); extern EXPCL_PANDAGL void init_libwgldisplay();

View File

@ -640,6 +640,10 @@ void wglGraphicsWindow::config() {
gl_supports_bgr = (_extensions_str.find("GL_EXT_bgra")!=_extensions_str.npos); gl_supports_bgr = (_extensions_str.find("GL_EXT_bgra")!=_extensions_str.npos);
// hard to imagine a windows-based driver that doesnt support this ordering
if(!gl_supports_bgr)
wgldisplay_cat.info() << "Note GL_EXT_bgra not supported, textures must be swizzled!\n";
if (gl_show_fps_meter) { if (gl_show_fps_meter) {
_start_time = timeGetTime(); _start_time = timeGetTime();
@ -791,26 +795,21 @@ void PrintPFD(PIXELFORMATDESCRIPTOR *pfd,char *msg) {
} }
#endif #endif
//////////////////////////////////////////////////////////////////// // this helper routine looks for either HW-only or SW-only format, but not both
// Function: choose visual // returns number of pixelformat
// Access: int wglGraphicsWindow::find_pixfmtnum(bool bLookforHW) {
// Description:
////////////////////////////////////////////////////////////////////
int wglGraphicsWindow::choose_visual() {
int mask = _props._mask; int mask = _props._mask;
int want_depth_bits = _props._want_depth_bits; int want_depth_bits = _props._want_depth_bits;
int want_color_bits = _props._want_color_bits; int want_color_bits = _props._want_color_bits;
OGLDriverType drvtype; OGLDriverType drvtype;
if (mask & W_MULTISAMPLE) { if (mask & W_MULTISAMPLE) {
wgldisplay_cat.info() wgldisplay_cat.error() << "config() - multisample not supported"<< endl;
<< "config() - multisample not supported"<< endl;
mask &= ~W_MULTISAMPLE; mask &= ~W_MULTISAMPLE;
} }
wgldisplay_cat.info()
<< "mask =0x" << (void*) mask if(wgldisplay_cat.is_debug())
<< endl; wgldisplay_cat.debug() << "mask =0x" << (void*) mask << endl;
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd,sizeof(PIXELFORMATDESCRIPTOR)); ZeroMemory(&pfd,sizeof(PIXELFORMATDESCRIPTOR));
@ -826,41 +825,24 @@ int wglGraphicsWindow::choose_visual() {
int cur_bpp=GetDeviceCaps(_hdc,BITSPIXEL); int cur_bpp=GetDeviceCaps(_hdc,BITSPIXEL);
int pfnum; int pfnum;
#ifdef _DEBUG
if (wgldisplay_cat.is_debug()) {
for(pfnum=1;pfnum<=MaxPixFmtNum;pfnum++) {
DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if ((pfd.dwFlags & PFD_GENERIC_ACCELERATED) && (pfd.dwFlags & PFD_GENERIC_FORMAT))
drvtype=MCD;
else if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) && !(pfd.dwFlags & PFD_GENERIC_FORMAT))
drvtype=ICD;
else {
drvtype=Software;
continue; // skipping all SW fmts
}
// use wglinfo.exe instead
char msg[200];
sprintf(msg,"GL PixelFormat[%d]",pfnum);
PrintPFD(&pfd,msg);
}
}
#endif
for(pfnum=1;pfnum<=MaxPixFmtNum;pfnum++) { for(pfnum=1;pfnum<=MaxPixFmtNum;pfnum++) {
DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
// official, nvidia sanctioned way. should be equiv to my algorithm // official, nvidia sanctioned way. should be equiv to my algorithm
if ((pfd.dwFlags & PFD_GENERIC_FORMAT) != 0) { if ((pfd.dwFlags & PFD_GENERIC_FORMAT) != 0)
drvtype = Software; drvtype = Software;
continue;
}
else if (pfd.dwFlags & PFD_GENERIC_ACCELERATED) else if (pfd.dwFlags & PFD_GENERIC_ACCELERATED)
drvtype = MCD; drvtype = MCD;
else else
drvtype = ICD; drvtype = ICD;
// skip driver types we are not looking for
if((drvtype==Software) && bLookforHW)
continue;
if((drvtype!=Software) && !bLookforHW)
continue;
#if MY_OLD_ALGORITHM #if MY_OLD_ALGORITHM
if ((pfd.dwFlags & PFD_GENERIC_ACCELERATED) && (pfd.dwFlags & PFD_GENERIC_FORMAT)) if ((pfd.dwFlags & PFD_GENERIC_ACCELERATED) && (pfd.dwFlags & PFD_GENERIC_FORMAT))
drvtype=MCD; drvtype=MCD;
@ -872,15 +854,14 @@ int wglGraphicsWindow::choose_visual() {
} }
#endif #endif
if (wgldisplay_cat.is_debug())
wgldisplay_cat->debug() << "----------------" << endl;
if ((pfd.iPixelType == PFD_TYPE_COLORINDEX) && !(mask & W_INDEX)) if ((pfd.iPixelType == PFD_TYPE_COLORINDEX) && !(mask & W_INDEX))
continue; continue;
DWORD dwReqFlags=(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW); DWORD dwReqFlags=(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW);
if (wgldisplay_cat.is_debug()) { if (wgldisplay_cat.is_debug()) {
wgldisplay_cat->debug() << "----------------" << endl;
if (mask & W_ALPHA) if (mask & W_ALPHA)
wgldisplay_cat->debug() << "want alpha, pfd says '" wgldisplay_cat->debug() << "want alpha, pfd says '"
<< (int)(pfd.cAlphaBits) << "'" << endl; << (int)(pfd.cAlphaBits) << "'" << endl;
@ -923,22 +904,63 @@ int wglGraphicsWindow::choose_visual() {
break; break;
} }
if (pfnum>MaxPixFmtNum) { if(pfnum>MaxPixFmtNum)
wgldisplay_cat.error() << "ERROR: couldn't find HW-accelerated OpenGL pixfmt appropriate for this desktop!!\n"; pfnum=0;
wgldisplay_cat.error() << "make sure OpenGL driver is installed, and try reducing the screen size\n";
if (cur_bpp>16) return pfnum;
wgldisplay_cat.error() << "or reducing the desktop screen pixeldepth\n"; }
////////////////////////////////////////////////////////////////////
// Function: choose visual
// Access:
// Description:
////////////////////////////////////////////////////////////////////
int wglGraphicsWindow::choose_visual(void) {
int pfnum;
bool bUsingSoftware=false;
if(wgl_force_sw_renderer) {
pfnum=find_pixfmtnum(false);
if(pfnum==0) {
wgldisplay_cat.error() << "ERROR: couldn't find compatible software-renderer OpenGL pixfmt, check your window properties!\n";
exit(1); exit(1);
} }
bUsingSoftware=true;
} else {
pfnum=find_pixfmtnum(true);
if(pfnum==0) {
if(wgl_allow_sw_renderer) {
pfnum=find_pixfmtnum(false);
if(pfnum==0) {
wgldisplay_cat.error() << "ERROR: couldn't find HW or Software OpenGL pixfmt appropriate for this desktop!!\n";
}
} else {
wgldisplay_cat.error() << "ERROR: couldn't find HW-accelerated OpenGL pixfmt appropriate for this desktop!!\n";
}
if(pfnum==0) {
wgldisplay_cat.error()
<< "make sure OpenGL driver is installed, and try reducing the screen size, reducing the\n"
<< "desktop screen pixeldepth to 16bpp,and check your panda window properties\n";
exit(1);
}
bUsingSoftware=true;
}
}
if(wgl_allow_sw_renderer && bUsingSoftware) {
wgldisplay_cat.info() << "Couldn't find compatible OGL HW pixelformat, using software rendering...\n";
}
DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &_pixelformat);
#ifdef _DEBUG #ifdef _DEBUG
char msg[200]; char msg[200];
sprintf(msg,"Selected GL PixelFormat is #%d",pfnum); sprintf(msg,"Selected GL PixelFormat is #%d",pfnum);
PrintPFD(&pfd,msg); PrintPFD(&_pixelformat,msg);
#endif #endif
memcpy(&_pixelformat,&pfd,sizeof(PIXELFORMATDESCRIPTOR));
return pfnum; return pfnum;
} }

View File

@ -93,9 +93,10 @@ protected:
// PIXELFORMATDESCRIPTOR* try_for_visual(wglGraphicsPipe *pipe, // PIXELFORMATDESCRIPTOR* try_for_visual(wglGraphicsPipe *pipe,
// int mask, int want_depth_bits = 1, int want_color_bits = 1); // int mask, int want_depth_bits = 1, int want_color_bits = 1);
// static void get_config(PIXELFORMATDESCRIPTOR* visual, int attrib, int *value); // static void get_config(PIXELFORMATDESCRIPTOR* visual, int attrib, int *value);
int choose_visual(); int choose_visual(void);
int find_pixfmtnum(bool bLookforHW);
virtual void config(); virtual void config();
void setup_colormap(); void setup_colormap(void);
void enable_mouse_input(bool val); void enable_mouse_input(bool val);
void enable_mouse_motion(bool val); void enable_mouse_motion(bool val);