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