Only include resolutions with 2 buffers

FossilOrigin-Name: 657aecaa88446eb91d1a58fff2169d8c698528c22a4b5ba9197fb0a1316d70cc
This commit is contained in:
Jonathan Schleifer 2022-12-25 19:24:13 +00:00
parent ccef3f6323
commit bee59f3938
4 changed files with 47 additions and 12 deletions

View file

@ -135,14 +135,14 @@ refreshEnumToFloat(GrScreenRefresh_t refresh)
[super dealloc];
}
- (OFSet OF_GENERIC(OFPair OF_GENERIC(OFValue *, OFNumber *) *) *)
- (OFArray OF_GENERIC(OFPair OF_GENERIC(OFValue *, OFNumber *) *) *)
availableResolutions
{
OFMutableSet *ret = [OFMutableSet set];
OFMutableArray *ret = [OFMutableArray array];
GrResolution query = {
.resolution = GR_QUERY_ANY,
.refresh = GR_QUERY_ANY,
.numColorBuffers = GR_QUERY_ANY,
.numColorBuffers = 2,
.numAuxBuffers = 1
};
size_t size = grQueryResolutions(&query, NULL);
@ -176,6 +176,10 @@ refreshEnumToFloat(GrScreenRefresh_t refresh)
OFFreeMemory(resolutions);
}
[ret sortUsingFunction: O3DCompareResolution
context: NULL
options: OFArraySortDescending];
[ret makeImmutable];
return ret;

View file

@ -17,16 +17,10 @@
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern OFString *const O3DRendererDeviceIndex;
#ifdef __cplusplus
}
#endif
typedef OFPair OF_GENERIC(OFValue *, OFNumber *) *O3DResolution;
@protocol O3DRenderer <OFObject>
@property (readonly, nonatomic) OFSet OF_GENERIC(OFPair OF_GENERIC(OFValue *,
@property (readonly, nonatomic) OFArray OF_GENERIC(OFPair OF_GENERIC(OFValue *,
OFNumber *) *) *availableResolutions;
+ (instancetype)alloc;
@ -34,4 +28,14 @@ extern OFString *const O3DRendererDeviceIndex;
(nullable OFDictionary OF_GENERIC(OFString *, id) *)options;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFString *const O3DRendererDeviceIndex;
extern OFComparisonResult O3DCompareResolution(id _Nullable left,
id _Nullable right, void *_Nullable context);
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END

View file

@ -16,3 +16,30 @@
#import "O3DRenderer.h"
OFString *const O3DRendererDeviceIndex = @"O3DRendererDeviceIndex";
OFComparisonResult
O3DCompareResolution(id left, id right, void *context)
{
OFSize leftResolution = [[left firstObject] sizeValue];
OFSize rightResolution = [[right firstObject] sizeValue];
if (leftResolution.width > rightResolution.width)
return OFOrderedDescending;
if (leftResolution.width < rightResolution.width)
return OFOrderedAscending;
if (leftResolution.height > rightResolution.height)
return OFOrderedDescending;
if (leftResolution.height < rightResolution.height)
return OFOrderedAscending;
float leftRefresh = [[left secondObject] floatValue];
float rightRefresh = [[right secondObject] floatValue];
if (leftRefresh > rightRefresh)
return OFOrderedDescending;
if (leftRefresh < rightRefresh)
return OFOrderedAscending;
return OFOrderedSame;
}

View file

@ -31,7 +31,7 @@ OF_APPLICATION_DELEGATE(TestsAppDelegate)
[[[O3DEngine alloc] initWithRenderer: renderer
options: nil] autorelease];
[OFStdOut writeFormat: @"Available resolutions: %@",
[OFStdOut writeFormat: @"Available resolutions: %@\n",
engine.renderer.availableResolutions];
[OFApplication terminate];