Only include resolutions with 2 buffers
FossilOrigin-Name: 657aecaa88446eb91d1a58fff2169d8c698528c22a4b5ba9197fb0a1316d70cc
This commit is contained in:
parent
ccef3f6323
commit
bee59f3938
4 changed files with 47 additions and 12 deletions
|
@ -135,14 +135,14 @@ refreshEnumToFloat(GrScreenRefresh_t refresh)
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFSet OF_GENERIC(OFPair OF_GENERIC(OFValue *, OFNumber *) *) *)
|
- (OFArray OF_GENERIC(OFPair OF_GENERIC(OFValue *, OFNumber *) *) *)
|
||||||
availableResolutions
|
availableResolutions
|
||||||
{
|
{
|
||||||
OFMutableSet *ret = [OFMutableSet set];
|
OFMutableArray *ret = [OFMutableArray array];
|
||||||
GrResolution query = {
|
GrResolution query = {
|
||||||
.resolution = GR_QUERY_ANY,
|
.resolution = GR_QUERY_ANY,
|
||||||
.refresh = GR_QUERY_ANY,
|
.refresh = GR_QUERY_ANY,
|
||||||
.numColorBuffers = GR_QUERY_ANY,
|
.numColorBuffers = 2,
|
||||||
.numAuxBuffers = 1
|
.numAuxBuffers = 1
|
||||||
};
|
};
|
||||||
size_t size = grQueryResolutions(&query, NULL);
|
size_t size = grQueryResolutions(&query, NULL);
|
||||||
|
@ -176,6 +176,10 @@ refreshEnumToFloat(GrScreenRefresh_t refresh)
|
||||||
OFFreeMemory(resolutions);
|
OFFreeMemory(resolutions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ret sortUsingFunction: O3DCompareResolution
|
||||||
|
context: NULL
|
||||||
|
options: OFArraySortDescending];
|
||||||
|
|
||||||
[ret makeImmutable];
|
[ret makeImmutable];
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -17,16 +17,10 @@
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
#ifdef __cplusplus
|
typedef OFPair OF_GENERIC(OFValue *, OFNumber *) *O3DResolution;
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
extern OFString *const O3DRendererDeviceIndex;
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@protocol O3DRenderer <OFObject>
|
@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;
|
OFNumber *) *) *availableResolutions;
|
||||||
|
|
||||||
+ (instancetype)alloc;
|
+ (instancetype)alloc;
|
||||||
|
@ -34,4 +28,14 @@ extern OFString *const O3DRendererDeviceIndex;
|
||||||
(nullable OFDictionary OF_GENERIC(OFString *, id) *)options;
|
(nullable OFDictionary OF_GENERIC(OFString *, id) *)options;
|
||||||
@end
|
@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
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -16,3 +16,30 @@
|
||||||
#import "O3DRenderer.h"
|
#import "O3DRenderer.h"
|
||||||
|
|
||||||
OFString *const O3DRendererDeviceIndex = @"O3DRendererDeviceIndex";
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ OF_APPLICATION_DELEGATE(TestsAppDelegate)
|
||||||
[[[O3DEngine alloc] initWithRenderer: renderer
|
[[[O3DEngine alloc] initWithRenderer: renderer
|
||||||
options: nil] autorelease];
|
options: nil] autorelease];
|
||||||
|
|
||||||
[OFStdOut writeFormat: @"Available resolutions: %@",
|
[OFStdOut writeFormat: @"Available resolutions: %@\n",
|
||||||
engine.renderer.availableResolutions];
|
engine.renderer.availableResolutions];
|
||||||
|
|
||||||
[OFApplication terminate];
|
[OFApplication terminate];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue