mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
RefreshRate only needs to be integer
This commit is contained in:
parent
178e5a2710
commit
217065e21c
@ -16,7 +16,7 @@ namespace OpenTK {
|
||||
internal DisplayResolution() { }
|
||||
|
||||
// Creates a new DisplayResolution object for the primary DisplayDevice.
|
||||
internal DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate) {
|
||||
internal DisplayResolution(int width, int height, int bitsPerPixel, int refreshRate) {
|
||||
Width = width; Height = height;
|
||||
BitsPerPixel = bitsPerPixel; RefreshRate = refreshRate;
|
||||
}
|
||||
@ -31,7 +31,7 @@ namespace OpenTK {
|
||||
public int BitsPerPixel;
|
||||
|
||||
/// <summary> The vertical refresh rate of this display. </summary>
|
||||
public float RefreshRate;
|
||||
public int RefreshRate;
|
||||
}
|
||||
|
||||
/// <summary> Defines a display device on the underlying system. </summary>
|
||||
@ -80,7 +80,7 @@ namespace OpenTK {
|
||||
}
|
||||
|
||||
/// <summary> Returns vertical refresh rate of this display. </summary>
|
||||
public float RefreshRate {
|
||||
public int RefreshRate {
|
||||
get { return curResolution.RefreshRate; }
|
||||
internal set { curResolution.RefreshRate = value; }
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ namespace OpenTK.Platform.MacOS
|
||||
int width = (int) dict.GetNumberValue("Width");
|
||||
int height = (int) dict.GetNumberValue("Height");
|
||||
int bpp = (int) dict.GetNumberValue("BitsPerPixel");
|
||||
double freq = dict.GetNumberValue("RefreshRate");
|
||||
int freq = (int) dict.GetNumberValue("RefreshRate");
|
||||
bool current = currentMode.DictRef == dict.DictRef;
|
||||
|
||||
if (current) {
|
||||
opentk_dev_current_res = new DisplayResolution(width, height, bpp, (float)freq);
|
||||
opentk_dev_current_res = new DisplayResolution(width, height, bpp, freq);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace OpenTK.Platform.X11 {
|
||||
|
||||
ushort curRotation;
|
||||
int curSizesIndex = API.XRRConfigCurrentConfiguration(screenConfig, out curRotation);
|
||||
float curRefreshRate = API.XRRConfigCurrentRate(screenConfig);
|
||||
int curRefreshRate = API.XRRConfigCurrentRate(screenConfig);
|
||||
int curDepth = API.XDefaultDepth(API.DefaultDisplay, screen);
|
||||
API.XRRFreeScreenConfigInfo(screenConfig);
|
||||
|
||||
|
@ -234,7 +234,7 @@ void Huffman_Build(HuffmanTable* table, UInt8* bitLens, Int32 count) {
|
||||
* - set fast value to specify a 'value' value, and to skip 'len' bits
|
||||
*/
|
||||
if (len <= INFLATE_FAST_BITS) {
|
||||
Int16 packed = (Int16)((len << 9) | value), j;
|
||||
Int16 packed = (Int16)((len << INFLATE_FAST_BITS) | value), j;
|
||||
Int32 codeword = table->FirstCodewords[len] + (bl_offsets[len] - table->FirstOffsets[len]);
|
||||
codeword <<= (INFLATE_FAST_BITS - len);
|
||||
|
||||
@ -255,10 +255,10 @@ Int32 Huffman_Decode(InflateState* state, HuffmanTable* table) {
|
||||
}
|
||||
|
||||
/* Try fast accelerated table lookup */
|
||||
if (state->NumBits >= 9) {
|
||||
if (state->NumBits >= INFLATE_FAST_BITS) {
|
||||
Int32 packed = table->Fast[Inflate_PeekBits(state, INFLATE_FAST_BITS)];
|
||||
if (packed >= 0) {
|
||||
Int32 bits = packed >> 9;
|
||||
Int32 bits = packed >> INFLATE_FAST_BITS;
|
||||
Inflate_ConsumeBits(state, bits);
|
||||
return packed & 0x1FF;
|
||||
}
|
||||
@ -287,7 +287,7 @@ Int32 Huffman_Unsafe_Decode(InflateState* state, HuffmanTable* table) {
|
||||
UInt32 codeword = Inflate_PeekBits(state, INFLATE_FAST_BITS);
|
||||
Int32 packed = table->Fast[codeword];
|
||||
if (packed >= 0) {
|
||||
Int32 bits = packed >> 9;
|
||||
Int32 bits = packed >> INFLATE_FAST_BITS;
|
||||
Inflate_ConsumeBits(state, bits);
|
||||
return packed & 0x1FF;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "DisplayDevice.h"
|
||||
|
||||
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Real32 refreshRate) {
|
||||
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Int32 refreshRate) {
|
||||
DisplayResolution res;
|
||||
res.Width = width; res.Height = height;
|
||||
res.BitsPerPixel = bitsPerPixel; res.RefreshRate = refreshRate;
|
||||
@ -74,8 +74,8 @@ ColorFormat ColorFormat_FromRGBA(UInt8 r, UInt8 g, UInt8 b, UInt8 a) {
|
||||
GraphicsMode GraphicsMode_Make(ColorFormat color, UInt8 depth, UInt8 stencil, UInt8 buffers) {
|
||||
GraphicsMode mode;
|
||||
mode.Format = color;
|
||||
mode.Depth = depth;
|
||||
mode.Stencil = stencil;
|
||||
mode.DepthBits = depth;
|
||||
mode.StencilBits = stencil;
|
||||
mode.Buffers = buffers;
|
||||
return mode;
|
||||
}
|
||||
|
@ -12,75 +12,42 @@
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
|
||||
/* Contains information regarding a monitor's display resolution. */
|
||||
typedef struct DisplayResolution_ {
|
||||
/* The width of this display in pixels. */
|
||||
Int32 Width;
|
||||
/* The height of this display in pixels. */
|
||||
Int32 Height;
|
||||
/* The number of bits per pixel of this display. Typical values include 8, 16, 24 and 32. */
|
||||
Int32 BitsPerPixel;
|
||||
Int32 Width, Height, BitsPerPixel;
|
||||
/* The vertical refresh rate of this display. */
|
||||
Real32 RefreshRate;
|
||||
Int32 RefreshRate;
|
||||
} DisplayResolution;
|
||||
|
||||
/* Constructs a new display resolution instance. */
|
||||
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Real32 refreshRate);
|
||||
DisplayResolution DisplayResolution_Make(Int32 width, Int32 height, Int32 bitsPerPixel, Int32 refreshRate);
|
||||
|
||||
|
||||
/* Defines a display device on the underlying system.*/
|
||||
typedef struct DisplayDevice_ {
|
||||
/* The current resolution of the display device.*/
|
||||
DisplayResolution CurResolution;
|
||||
/* The bounds of the display device.*/
|
||||
Rectangle2D Bounds;
|
||||
/* Metadata unique to this display device instance. */
|
||||
void* Metadata;
|
||||
} DisplayDevice;
|
||||
|
||||
/* Constructs a new display device instance. */
|
||||
DisplayDevice DisplayDevice_Make(DisplayResolution* curResolution);
|
||||
/* Updates the bounds of the display device to the given bounds. */
|
||||
void DisplayDevice_SetBounds(DisplayDevice* device, Rectangle2D* bounds);
|
||||
/* The primary / default / main display device. */
|
||||
DisplayDevice DisplayDevice_Default;
|
||||
|
||||
#if !USE_DX
|
||||
/* Contains Red, Green, Blue and Alpha components for a color format of the given bits per pixel. */
|
||||
typedef struct ColorFormat_ {
|
||||
/* Gets the bits per pixel for the Red channel. */
|
||||
UInt8 R;
|
||||
/* Gets the bits per pixel for the Green channel. */
|
||||
UInt8 G;
|
||||
/* Gets the bits per pixel for the Blue channel. */
|
||||
UInt8 B;
|
||||
/* Gets the bits per pixel for the Alpha channel. */
|
||||
UInt8 A;
|
||||
/* Gets whether this ColorFormat is indexed. */
|
||||
UInt8 R, G, B, A;
|
||||
bool IsIndexed;
|
||||
/* Gets the sum of Red, Green, Blue and Alpha bits per pixel. */
|
||||
Int32 BitsPerPixel;
|
||||
} ColorFormat;
|
||||
|
||||
/* Constructs a color format from given bits per pixel. */
|
||||
ColorFormat ColorFormat_FromBPP(Int32 bpp);
|
||||
/* Constructs a color format from given bits per component. */
|
||||
ColorFormat ColorFormat_FromRGBA(UInt8 r, UInt8 g, UInt8 b, UInt8 a);
|
||||
|
||||
|
||||
/* Defines the format for graphics operations. */
|
||||
typedef struct GraphicsMode_ {
|
||||
/* The OpenTK.Graphics.ColorFormat that describes the color format for this GraphicsFormat. */
|
||||
ColorFormat Format;
|
||||
/* The bits per pixel for the depth buffer for this GraphicsFormat. */
|
||||
UInt8 Depth;
|
||||
/* The bits per pixel for the stencil buffer of this GraphicsFormat. */
|
||||
UInt8 Stencil;
|
||||
/* The number of buffers associated with this DisplayMode. */
|
||||
UInt8 DepthBits, StencilBits;
|
||||
/* The number of buffers associated with this DisplayMode. */
|
||||
UInt8 Buffers;
|
||||
} GraphicsMode;
|
||||
|
||||
/* Constructs a new GraphicsMode with the specified parameters. */
|
||||
GraphicsMode GraphicsMode_Make(ColorFormat color, UInt8 depth, UInt8 stencil, UInt8 buffers);
|
||||
/* Returns an GraphicsMode compatible with the underlying platform. */
|
||||
GraphicsMode GraphicsMode_MakeDefault(void);
|
||||
|
@ -58,7 +58,7 @@ typedef struct FontDesc_ { void* Handle; UInt16 Size, Style; } FontDesc;
|
||||
#define Int32_MaxValue ((Int32)2147483647L)
|
||||
#define UInt32_MaxValue ((UInt32)4294967295UL)
|
||||
|
||||
#define USE_DX true
|
||||
#define USE_DX false
|
||||
|
||||
#if USE_DX
|
||||
typedef void* GfxResourceID;
|
||||
|
@ -59,7 +59,7 @@ void Platform_Init(void) {
|
||||
EnumDisplaySettingsA(device.DeviceName, ENUM_REGISTRY_SETTINGS, &mode)) {
|
||||
if (mode.dmBitsPerPel > 0) {
|
||||
resolution = DisplayResolution_Make(mode.dmPelsWidth, mode.dmPelsHeight,
|
||||
mode.dmBitsPerPel, (Real32)mode.dmDisplayFrequency);
|
||||
mode.dmBitsPerPel, mode.dmDisplayFrequency);
|
||||
devPrimary = (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) != 0;
|
||||
}
|
||||
}
|
||||
@ -442,8 +442,8 @@ void Platform_SetBitmap(Bitmap* bmp) {
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
/* TODO: Check return values */
|
||||
platform_dib = CreateDIBSection(hdc, &bmi, 0, &platform_bits, NULL, 0);
|
||||
if (platform_dib == NULL) ErrorHandler_Fail("Failed to allocate DIB for text");
|
||||
platform_oldBmp = SelectObject(hdc, platform_dib);
|
||||
}
|
||||
|
||||
|
@ -711,15 +711,15 @@ void GLContext_SelectGraphicsMode(GraphicsMode mode) {
|
||||
pfd.cColorBits = (UInt8)(color.R + color.G + color.B);
|
||||
|
||||
pfd.iPixelType = color.IsIndexed ? PFD_TYPE_COLORINDEX : PFD_TYPE_RGBA;
|
||||
pfd.cRedBits = (UInt8)color.R;
|
||||
pfd.cGreenBits = (UInt8)color.G;
|
||||
pfd.cBlueBits = (UInt8)color.B;
|
||||
pfd.cAlphaBits = (UInt8)color.A;
|
||||
pfd.cRedBits = color.R;
|
||||
pfd.cGreenBits = color.G;
|
||||
pfd.cBlueBits = color.B;
|
||||
pfd.cAlphaBits = color.A;
|
||||
|
||||
pfd.cDepthBits = (UInt8)mode.Depth;
|
||||
pfd.cStencilBits = (UInt8)mode.Stencil;
|
||||
if (mode.Depth <= 0) pfd.dwFlags |= PFD_DEPTH_DONTCARE;
|
||||
if (mode.Buffers > 1) pfd.dwFlags |= PFD_DOUBLEBUFFER;
|
||||
pfd.cDepthBits = mode.DepthBits;
|
||||
pfd.cStencilBits = mode.StencilBits;
|
||||
if (mode.DepthBits <= 0) pfd.dwFlags |= PFD_DEPTH_DONTCARE;
|
||||
if (mode.Buffers > 1) pfd.dwFlags |= PFD_DOUBLEBUFFER;
|
||||
|
||||
Int32 modeIndex = ChoosePixelFormat(win_DC, &pfd);
|
||||
if (modeIndex == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user