本文整理汇总了C#中GraphicsProfile类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsProfile类的具体用法?C# GraphicsProfile怎么用?C# GraphicsProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsProfile类属于命名空间,在下文中一共展示了GraphicsProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindClosestMatchingDisplayMode
/// <summary>
/// Find the display mode that most closely matches the requested display mode.
/// </summary>
/// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
/// <param name="mode">The mode.</param>
/// <returns>Returns the closes display mode.</returns>
/// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
/// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order. ScanlineOrdering Scaling Format Resolution RefreshRate When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering, Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output. If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output. Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
{
if (targetProfiles == null) throw new ArgumentNullException("targetProfiles");
ModeDescription closestDescription;
SharpDX.Direct3D11.Device deviceTemp = null;
try
{
var features = new SharpDX.Direct3D.FeatureLevel[targetProfiles.Length];
for (int i = 0; i < targetProfiles.Length; i++)
{
features[i] = (FeatureLevel)targetProfiles[i];
}
deviceTemp = new SharpDX.Direct3D11.Device(adapter.NativeAdapter, SharpDX.Direct3D11.DeviceCreationFlags.None, features);
}
catch (Exception) { }
var description = new SharpDX.DXGI.ModeDescription()
{
Width = mode.Width,
Height = mode.Height,
RefreshRate = mode.RefreshRate.ToSharpDX(),
Format = (SharpDX.DXGI.Format)mode.Format,
Scaling = DisplayModeScaling.Unspecified,
ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
};
using (var device = deviceTemp)
output.GetClosestMatchingMode(device, description, out closestDescription);
return DisplayMode.FromDescription(closestDescription);
}
示例2: GetGLVersion
public static void GetGLVersion(GraphicsProfile graphicsProfile, out int major, out int minor)
{
switch (graphicsProfile)
{
case GraphicsProfile.Level_9_1:
case GraphicsProfile.Level_9_2:
case GraphicsProfile.Level_9_3:
major = 3;
minor = 3;
return;
case GraphicsProfile.Level_10_0:
case GraphicsProfile.Level_10_1:
major = 4;
minor = 3;
return;
case GraphicsProfile.Level_11_0:
case GraphicsProfile.Level_11_1:
case GraphicsProfile.Level_11_2:
major = 4;
minor = 4;
return;
default:
throw new ArgumentOutOfRangeException("graphicsProfile");
}
}
示例3: GraphicsAdapter
internal GraphicsAdapter()
{
outputs = new [] { new GraphicsOutput() };
// set default values
int versionMajor = 1;
int versionMinor = 0;
// get real values
// using glGetIntegerv(GL_MAJOR_VERSION / GL_MINOR_VERSION) only works on opengl (es) > 3.0
var version = GL.GetString(StringName.Version);
if (version != null)
{
var splitVersion = version.Split(new char[] { '.', ' ' });
// find first number occurence because:
// - on OpenGL, "<major>.<minor>"
// - on OpenGL ES, "OpenGL ES <profile> <major>.<minor>"
for (var i = 0; i < splitVersion.Length - 1; ++i)
{
if (int.TryParse(splitVersion[i], out versionMajor))
{
int.TryParse(splitVersion[i + 1], out versionMinor);
break;
}
}
}
supportedGraphicsProfile = OpenGLUtils.GetFeatureLevel(versionMajor, versionMinor);
}
示例4: IsPreferredProfileAvailable
protected override bool IsPreferredProfileAvailable(GraphicsProfile[] preferredProfiles, out GraphicsProfile availableProfile)
{
if(!base.IsPreferredProfileAvailable(preferredProfiles, out availableProfile))
{
var minimumProfile = preferredProfiles.Min();
Assert.Ignore("This test requires the '{0}' graphic profile. It has been ignored", minimumProfile);
}
return true;
}
示例5: AddRef
/// <summary>
/// Gets a reference to the singleton instance.
/// </summary>
public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height, GraphicsProfile profile) {
// Increment the "how many controls sharing the device" reference count.
if (Interlocked.Increment(ref mReferenceCount) == 1) {
// If this is the first control to start using the
// device, we must create the singleton instance.
mSingletonInstance = new GraphicsDeviceService(windowHandle, width, height, profile);
}
return mSingletonInstance;
}
示例6: GetEffectBytes
public static byte[] GetEffectBytes(CompiledEffect effect, GraphicsProfile graphicsProfile)
{
switch (effect)
{
case CompiledEffect.CircleEffect:
return graphicsProfile == GraphicsProfile.HiDef ? CircleEffect.HiDefWindows : CircleEffect.ReachWindows;
default:
throw new Exception("Effect not found");
}
}
示例7: GraphicsDeviceService
/// <summary>
/// Constructor is private, because this is a singleton class:
/// client controls should use the public AddRef method instead.
/// </summary>
GraphicsDeviceService(GraphicsProfile profile, IntPtr windowHandle, int width, int height)
{
parameters = new PresentationParameters();
parameters.BackBufferWidth = Math.Max(width, 1);
parameters.BackBufferHeight = Math.Max(height, 1);
parameters.BackBufferFormat = SurfaceFormat.Color;
parameters.DepthStencilFormat = DepthFormat.Depth24Stencil8;
parameters.DeviceWindowHandle = windowHandle;
parameters.IsFullScreen = false;
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, profile, parameters);
}
示例8: FindBestTextureSize
/// <summary>
/// Utility function to check that the texture size is supported on the graphics platform for the provided graphics profile.
/// </summary>
/// <param name="textureFormat">The desired type of format for the output texture</param>
/// <param name="platform">The graphics platform</param>
/// <param name="graphicsProfile">The graphics profile</param>
/// <param name="textureSizeInput">The texture size input.</param>
/// <param name="textureSizeRequested">The texture size requested.</param>
/// <param name="generateMipmaps">Indicate if mipmaps should be generated for the output texture</param>
/// <param name="logger">The logger.</param>
/// <returns>true if the texture size is supported</returns>
/// <exception cref="System.ArgumentOutOfRangeException">graphicsProfile</exception>
public static Size2 FindBestTextureSize(TextureFormat textureFormat, GraphicsPlatform platform, GraphicsProfile graphicsProfile, Size2 textureSizeInput, Size2 textureSizeRequested, bool generateMipmaps, ILogger logger)
{
var textureSize = textureSizeRequested;
// compressed DDS files has to have a size multiple of 4.
if (platform == GraphicsPlatform.Direct3D11 && textureFormat == TextureFormat.Compressed
&& ((textureSizeRequested.Width % 4) != 0 || (textureSizeRequested.Height % 4) != 0))
{
textureSize.Width = unchecked((int)(((uint)(textureSizeRequested.Width + 3)) & ~(uint)3));
textureSize.Height = unchecked((int)(((uint)(textureSizeRequested.Height + 3)) & ~(uint)3));
}
var maxTextureSize = 0;
// determine if the desired size if valid depending on the graphics profile
switch (graphicsProfile)
{
case GraphicsProfile.Level_9_1:
case GraphicsProfile.Level_9_2:
case GraphicsProfile.Level_9_3:
if (generateMipmaps && (!IsPowerOfTwo(textureSize.Width) || !IsPowerOfTwo(textureSize.Height)))
{
// TODO: TEMPORARY SETUP A MAX TEXTURE OF 1024. THIS SHOULD BE SPECIFIED DONE IN THE ASSET INSTEAD
textureSize.Width = Math.Min(MathUtil.NextPowerOfTwo(textureSize.Width), 1024);
textureSize.Height = Math.Min(MathUtil.NextPowerOfTwo(textureSize.Height), 1024);
logger.Warning("Graphic profiles 9.1/9.2/9.3 do not support mipmaps with textures that are not power of 2. Asset is automatically resized to " + textureSize);
}
maxTextureSize = graphicsProfile >= GraphicsProfile.Level_9_3 ? 4096 : 2048;
break;
case GraphicsProfile.Level_10_0:
case GraphicsProfile.Level_10_1:
maxTextureSize = 8192;
break;
case GraphicsProfile.Level_11_0:
case GraphicsProfile.Level_11_1:
case GraphicsProfile.Level_11_2:
maxTextureSize = 16384;
break;
default:
throw new ArgumentOutOfRangeException("graphicsProfile");
}
if (textureSize.Width > maxTextureSize || textureSize.Height > maxTextureSize)
{
logger.Error("Graphic profile {0} do not support texture with resolution {2} x {3} because it is larger than {1}. " +
"Please reduce texture size or upgrade your graphic profile.", graphicsProfile, maxTextureSize, textureSize.Width, textureSize.Height);
return new Size2(Math.Min(textureSize.Width, maxTextureSize), Math.Min(textureSize.Height, maxTextureSize));
}
return textureSize;
}
示例9: GetFeatureLevel
/// <summary>
/// Gets the level of feature ?
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static FeatureLevel GetFeatureLevel( GraphicsProfile profile )
{
if (profile==GraphicsProfile.HiDef) {
return FeatureLevel.Level_11_0;
}
if (profile==GraphicsProfile.Reach) {
return FeatureLevel.Level_10_0;
}
if (profile==GraphicsProfile.Mobile) {
return FeatureLevel.Level_9_3;
}
throw new ArgumentException("profile");
}
示例10: GetShaderVersion
/// <summary>
/// Gets the version of shader
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
public static string GetShaderVersion( GraphicsProfile profile )
{
if (profile==GraphicsProfile.HiDef) {
return "5_0";
}
if (profile==GraphicsProfile.Reach) {
return "4_0";
}
if (profile==GraphicsProfile.Mobile) {
return "2_0";
}
throw new ArgumentException("profile");
}
示例11: GraphicsAdapter
internal GraphicsAdapter()
{
outputs = new [] { new GraphicsOutput() };
// set default values
int detectedVersion = 100;
var renderer = GL.GetString(StringName.Renderer);
var vendor = GL.GetString(StringName.Vendor);
// Stay close to D3D: Cut renderer after first / (ex: "GeForce 670/PCIe/SSE2")
var rendererSlash = renderer.IndexOf('/');
if (rendererSlash != -1)
renderer = renderer.Substring(0, rendererSlash);
// Stay close to D3D: Remove "Corporation" from vendor
vendor = vendor.Replace(" Corporation", string.Empty);
// Generate adapter Description
Description = $"{vendor} {renderer}";
// get real values
// using glGetIntegerv(GL_MAJOR_VERSION / GL_MINOR_VERSION) only works on opengl (es) > 3.0
var version = GL.GetString(StringName.Version);
if (version != null)
{
var splitVersion = version.Split(new char[] { '.', ' ' });
// find first number occurrence because:
// - on OpenGL, "<major>.<minor>"
// - on OpenGL ES, "OpenGL ES <profile> <major>.<minor>"
for (var i = 0; i < splitVersion.Length - 1; ++i)
{
int versionMajor, versionMinor;
if (int.TryParse(splitVersion[i], out versionMajor))
{
// Note: minor version might have stuff concat, take only until not digits
var versionMinorString = splitVersion[i + 1];
versionMinorString = new string(versionMinorString.TakeWhile(c => char.IsDigit(c)).ToArray());
int.TryParse(versionMinorString, out versionMinor);
detectedVersion = versionMajor * 100 + versionMinor * 10;
break;
}
}
}
supportedGraphicsProfile = OpenGLUtils.GetFeatureLevel(detectedVersion);
}
示例12: GraphicsDeviceService
/// <summary>
/// Constructor is private, because this is a singleton class:
/// client controls should use the public AddRef method instead.
/// </summary>
protected GraphicsDeviceService(IntPtr windowHandle, int width, int height, GraphicsProfile profile) {
mParameters = new PresentationParameters {
BackBufferWidth = Math.Max(width, 1),
BackBufferHeight = Math.Max(height, 1),
BackBufferFormat = SurfaceFormat.Color,
DepthStencilFormat = DepthFormat.Depth24,
DeviceWindowHandle = windowHandle,
PresentationInterval = PresentInterval.Immediate,
IsFullScreen = false
};
GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, profile, mParameters) {
BlendState = BlendState.Additive,
DepthStencilState = DepthStencilState.Default
};
}
示例13: GetGLVersions
public static IEnumerable<int> GetGLVersions(GraphicsProfile[] graphicsProfiles)
{
if (graphicsProfiles != null && graphicsProfiles.Length > 0)
{
foreach (var profile in graphicsProfiles)
{
if (profile >= GraphicsProfile.Level_10_0)
yield return 3;
else
yield return 2;
}
}
else
{
yield return 2;
}
}
示例14: ImportParameters
public ImportParameters(TextureConvertParameters textureParameters)
{
var asset = textureParameters.Texture;
IsSRgb = asset.SRgb;
DesiredSize = new Size2((int)asset.Width, (int)asset.Height);
IsSizeInPercentage = asset.IsSizeInPercentage;
DesiredFormat = asset.Format;
DesiredAlpha = asset.Alpha;
TextureHint = asset.Hint;
GenerateMipmaps = asset.GenerateMipmaps;
PremultiplyAlpha = asset.PremultiplyAlpha;
ColorKeyColor = asset.ColorKeyColor;
ColorKeyEnabled = asset.ColorKeyEnabled;
TextureQuality = textureParameters.TextureQuality;
GraphicsPlatform = textureParameters.GraphicsPlatform;
GraphicsProfile = textureParameters.GraphicsProfile;
Platform = textureParameters.Platform;
}
示例15: GetGLVersion
public static GLVersion GetGLVersion(GraphicsProfile graphicsProfile)
{
switch (graphicsProfile)
{
case GraphicsProfile.Level_9_1:
case GraphicsProfile.Level_9_2:
case GraphicsProfile.Level_9_3:
return GLVersion.ES2;
case GraphicsProfile.Level_10_0:
case GraphicsProfile.Level_10_1:
return GLVersion.ES3;
case GraphicsProfile.Level_11_0:
case GraphicsProfile.Level_11_1:
case GraphicsProfile.Level_11_2:
return GLVersion.ES31;
default:
throw new ArgumentOutOfRangeException("graphicsProfile");
}
}