Reintroduce display mode information in Windows via Win32 API

Also clean up the CPUID code in winGraphicsPipe a bit
This commit is contained in:
rdb 2015-07-19 21:11:43 +02:00
parent 23441aa5bb
commit e515cbdbd1
3 changed files with 353 additions and 396 deletions

View File

@ -15,10 +15,52 @@
#include "graphicsStateGuardian.h" #include "graphicsStateGuardian.h"
#include "displayInformation.h" #include "displayInformation.h"
////////////////////////////////////////////////////////////////////
// Function: DisplayMode::Comparison Operator
// Access: Published
// Description: Returns true if these two DisplayModes are identical.
////////////////////////////////////////////////////////////////////
bool DisplayMode::
operator == (const DisplayMode &other) const {
return (width == other.width && height == other.height &&
bits_per_pixel == other.bits_per_pixel &&
refresh_rate == other.refresh_rate &&
fullscreen_only == other.fullscreen_only);
}
////////////////////////////////////////////////////////////////////
// Function: DisplayMode::Comparison Operator
// Access: Published
// Description: Returns false if these two DisplayModes are identical.
////////////////////////////////////////////////////////////////////
bool DisplayMode::
operator != (const DisplayMode &other) const {
return !operator == (other);
}
////////////////////////////////////////////////////////////////////
// Function: DisplayMode::output
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void DisplayMode::
output(ostream &out) const {
out << width << 'x' << height;
if (bits_per_pixel > 0) {
out << ' ' << bits_per_pixel << "bpp";
}
if (refresh_rate > 0) {
out << ' ' << refresh_rate << "Hz";
}
if (fullscreen_only > 0) {
out << " (fullscreen only)";
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: DisplayInformation::Destructor // Function: DisplayInformation::Destructor
// Access: Published // Access: Published
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
DisplayInformation:: DisplayInformation::
~DisplayInformation() { ~DisplayInformation() {
@ -181,6 +223,21 @@ get_total_display_modes() {
return _total_display_modes; return _total_display_modes;
} }
////////////////////////////////////////////////////////////////////
// Function: DisplayInformation::get_display_mode
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
const DisplayMode &DisplayInformation::
get_display_mode(int display_index) {
#ifndef NDEBUG
static DisplayMode err_mode = {0};
nassertr(display_index >= 0 && display_index < _total_display_modes, err_mode);
#endif
return _display_mode_array[display_index];
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: DisplayInformation::get_display_mode_width // Function: DisplayInformation::get_display_mode_width
// Access: Published // Access: Published

View File

@ -17,29 +17,30 @@
#include "typedef.h" #include "typedef.h"
typedef struct { struct EXPCL_PANDA_DISPLAY DisplayMode {
PUBLISHED:
int width; int width;
int height; int height;
int bits_per_pixel; int bits_per_pixel;
int refresh_rate; int refresh_rate;
int fullscreen_only; int fullscreen_only;
}
DisplayMode; bool operator == (const DisplayMode &other) const;
bool operator != (const DisplayMode &other) const;
void output(ostream &out) const;
};
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : DisplayInformation // Class : DisplayInformation
// Description : This class contains various display information. // Description : This class contains various display information.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_DISPLAY DisplayInformation { class EXPCL_PANDA_DISPLAY DisplayInformation {
PUBLISHED: PUBLISHED:
enum DetectionState { enum DetectionState {
DS_unknown, DS_unknown,
DS_success, DS_success,
DS_direct_3d_create_error, DS_direct_3d_create_error,
DS_create_window_error, DS_create_window_error,
DS_create_device_error, DS_create_device_error,
}; };
@ -54,6 +55,10 @@ PUBLISHED:
int get_window_bits_per_pixel(); int get_window_bits_per_pixel();
int get_total_display_modes(); int get_total_display_modes();
const DisplayMode &get_display_mode(int display_index);
MAKE_SEQ(get_display_modes, get_total_display_modes, get_display_mode);
// Older interface for display modes.
int get_display_mode_width(int display_index); int get_display_mode_width(int display_index);
int get_display_mode_height(int display_index); int get_display_mode_height(int display_index);
int get_display_mode_bits_per_pixel(int display_index); int get_display_mode_bits_per_pixel(int display_index);

File diff suppressed because it is too large Load Diff