mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 06:14:35 +00:00
Update context.c & glfwinfo.c
This commit is contained in:
parent
dc7c52ed31
commit
2c28530875
@ -28,10 +28,10 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -185,6 +185,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
unsigned int count)
|
unsigned int count)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
bool accelerationMatch, closestAccelerationMatch = false;
|
||||||
unsigned int missing, leastMissing = UINT_MAX;
|
unsigned int missing, leastMissing = UINT_MAX;
|
||||||
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
unsigned int colorDiff, leastColorDiff = UINT_MAX;
|
||||||
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
|
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
|
||||||
@ -201,6 +202,8 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accelerationMatch = desired->acceleration == current->acceleration;
|
||||||
|
|
||||||
// Count number of missing buffers
|
// Count number of missing buffers
|
||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
@ -312,16 +315,13 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
|
|
||||||
if (desired->sRGB && !current->sRGB)
|
if (desired->sRGB && !current->sRGB)
|
||||||
extraDiff++;
|
extraDiff++;
|
||||||
|
|
||||||
if (desired->acceleration && !current->acceleration)
|
|
||||||
extraDiff++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out if the current one is better than the best one found so far
|
// Figure out if the current one is better than the best one found so far
|
||||||
// Least number of missing buffers is the most important heuristic,
|
// Least number of missing buffers is the most important heuristic,
|
||||||
// then color buffer size match and lastly size match for other buffers
|
// then color buffer size match and lastly size match for other buffers
|
||||||
|
|
||||||
if (missing < leastMissing)
|
if ((accelerationMatch && !closestAccelerationMatch) || missing < leastMissing)
|
||||||
closest = current;
|
closest = current;
|
||||||
else if (missing == leastMissing)
|
else if (missing == leastMissing)
|
||||||
{
|
{
|
||||||
@ -334,6 +334,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
|
|
||||||
if (current == closest)
|
if (current == closest)
|
||||||
{
|
{
|
||||||
|
closestAccelerationMatch = accelerationMatch;
|
||||||
leastMissing = missing;
|
leastMissing = missing;
|
||||||
leastColorDiff = colorDiff;
|
leastColorDiff = colorDiff;
|
||||||
leastExtraDiff = extraDiff;
|
leastExtraDiff = extraDiff;
|
||||||
|
@ -383,6 +383,7 @@ int main(int argc, char** argv)
|
|||||||
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
int angle_type = GLFW_ANGLE_PLATFORM_TYPE_NONE;
|
||||||
bool cocoa_graphics_switching = false;
|
bool cocoa_graphics_switching = false;
|
||||||
bool disable_xcb_surface = false;
|
bool disable_xcb_surface = false;
|
||||||
|
bool acceleration = true;
|
||||||
|
|
||||||
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
enum { PLATFORM, CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
|
||||||
EXTENSIONS, LAYERS,
|
EXTENSIONS, LAYERS,
|
||||||
@ -390,7 +391,7 @@ int main(int argc, char** argv)
|
|||||||
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
|
||||||
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
|
||||||
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER, NOERROR_SRSLY,
|
||||||
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE };
|
ANGLE_TYPE, GRAPHICS_SWITCHING, XCB_SURFACE, NO_ACCELERATION };
|
||||||
const struct option options[] =
|
const struct option options[] =
|
||||||
{
|
{
|
||||||
{ "platform", 1, NULL, PLATFORM },
|
{ "platform", 1, NULL, PLATFORM },
|
||||||
@ -426,6 +427,7 @@ int main(int argc, char** argv)
|
|||||||
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
{ "angle-type", 1, NULL, ANGLE_TYPE },
|
||||||
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
{ "graphics-switching", 0, NULL, GRAPHICS_SWITCHING },
|
||||||
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
{ "vk-xcb-surface", 0, NULL, XCB_SURFACE },
|
||||||
|
{ "no-acceleration", 0, NULL, NO_ACCELERATION },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -654,6 +656,9 @@ int main(int argc, char** argv)
|
|||||||
case XCB_SURFACE:
|
case XCB_SURFACE:
|
||||||
disable_xcb_surface = true;
|
disable_xcb_surface = true;
|
||||||
break;
|
break;
|
||||||
|
case NO_ACCELERATION:
|
||||||
|
acceleration = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -708,6 +713,7 @@ int main(int argc, char** argv)
|
|||||||
glfwWindowHint(GLFW_STEREO, fb_stereo);
|
glfwWindowHint(GLFW_STEREO, fb_stereo);
|
||||||
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
|
glfwWindowHint(GLFW_SRGB_CAPABLE, fb_srgb);
|
||||||
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
|
glfwWindowHint(GLFW_DOUBLEBUFFER, fb_doublebuffer);
|
||||||
|
glfwWindowHint(GLFW_ACCELERATION, acceleration);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
|
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, cocoa_graphics_switching);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user