本文整理汇总了C#中IGraphicsContext类的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext类的具体用法?C# IGraphicsContext怎么用?C# IGraphicsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IGraphicsContext类属于命名空间,在下文中一共展示了IGraphicsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EglContext
public EglContext(GraphicsMode mode, EglWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags)
{
if (mode == null)
throw new ArgumentNullException("mode");
if (window == null)
throw new ArgumentNullException("window");
EglContext eglContext = (EglContext) sharedContext;
int major1;
int minor1;
if (!Egl.Initialize(window.Display, out major1, out minor1))
throw new GraphicsContextException(string.Format("Failed to initialize EGL, error {0}.", (object) Egl.GetError()));
this.WindowInfo = window;
this.Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo, major > 1 ? RenderableFlags.ES2 : RenderableFlags.ES);
if (!this.Mode.Index.HasValue)
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
IntPtr config = this.Mode.Index.Value;
if (window.Surface == IntPtr.Zero)
window.CreateWindowSurface(config);
int[] attrib_list = new int[3]
{
12440,
major,
12344
};
this.HandleAsEGLContext = Egl.CreateContext(window.Display, config, eglContext != null ? eglContext.HandleAsEGLContext : IntPtr.Zero, attrib_list);
this.MakeCurrent((IWindowInfo) window);
}
示例2: SampleBrowser
public SampleBrowser(Context context, IGraphicsContext graphicsContext, IWindowInfo windowInfo)
{
// TODO: Complete member initialization
this.androidContext = context;
this.GLGraphicsContext = graphicsContext;
this.GlWindowInfo = windowInfo;
}
示例3: CreateContext
public void CreateContext(bool direct, IGraphicsContext source)
{
if (!(this.Handle == ContextHandle.Zero))
return;
++DummyGLContext.handle_count;
this.Handle = new ContextHandle((IntPtr) DummyGLContext.handle_count);
}
示例4: CreateProgram
public static ShaderProgram CreateProgram(IGraphicsContext context, string vertexSource, string fragmentSource)
{
int vertID = context.CreateShader(ShaderType.VertexShader);
int fragID = context.CreateShader(ShaderType.FragmentShader);
context.ShaderSource(vertID, vertexSource);
context.ShaderSource(fragID, fragmentSource);
context.CompileShader(vertID);
context.CompileShader(fragID);
Debug.LogInfo(context.GetShaderInfoLog(vertID));
Debug.LogInfo(context.GetShaderInfoLog(fragID));
int programID = context.CreateProgram();
context.AttachShader(programID, vertID);
context.AttachShader(programID, fragID);
context.LinkProgram(programID);
Debug.LogInfo(context.GetProgramInfoLog(programID));
return new ShaderProgram(context, vertID, fragID, programID);
}
示例5: CreateGLContext
public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{
WinWindowInfo winWindowInfo = (WinWindowInfo) window;
IntPtr display = this.GetDisplay(winWindowInfo.DeviceContext);
EglWindowInfo window1 = new EglWindowInfo(winWindowInfo.WindowHandle, display);
return (IGraphicsContext) new EglContext(handle, window1, shareContext, major, minor, flags);
}
示例6: DeleteAll
/// <summary>
/// 現在のコンテキストが持つテクスチャをすべて削除します。
/// </summary>
/// <remarks>
/// OpenGLの終了時に呼ばれます。
/// </remarks>
public static void DeleteAll(IGraphicsContext context)
{
//var context = context;
lock (textureListSync)
{
for (int index = 0; index < textureList.Count; )
{
var texture = textureList[index].Target as Texture;
if (texture == null)
{
// 要素を削除したため、indexの更新は行いません。
textureList.RemoveAt(index);
continue;
}
if (texture.Context == context)
{
// テクスチャを削除
texture.Destroy();
// 要素を削除したため、indexの更新は行いません。
textureList.RemoveAt(index);
continue;
}
index += 1;
}
}
}
示例7: AglContext
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext,
GetInt xoffset, GetInt yoffset)
{
Debug.Print("Share context: {0}", shareContext);
Debug.Print("Window info: {0}", window);
IntPtr shareContextRef = IntPtr.Zero;
XOffset = xoffset;
YOffset = yoffset;
carbonWindow = window;
if (shareContext is AglContext)
{
shareContextRef = ((AglContext)shareContext).Handle.Handle;
}
else if (shareContext is GraphicsContext)
{
ContextHandle shareHandle = shareContext != null ? (shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
shareContextRef = shareHandle.Handle;
}
if (shareContextRef == IntPtr.Zero)
{
Debug.Print("No context sharing will take place.");
}
CreateContext(mode, carbonWindow, shareContextRef, true);
}
示例8: QueueRenderCommands
public override void QueueRenderCommands(GameTime gameTime, Renderer renderer, IGraphicsContext context)
{
List<TerrainNode> nodesToRender = new List<TerrainNode>();
renderer.EnqueueLight(dlight);
// todo: maybe can parallelize
for (int i = 0; i < rootNodes.Length; i++)
{
if (rootNodes[i] != null)
{
List<TerrainNode> nodesFromThisCubeFace = new List<TerrainNode>();
findNodesToRender(nodesFromThisCubeFace, rootNodes[i], context.CurrentCamera);
nodesToRender.AddRange(nodesFromThisCubeFace);
}
}
int nodeCount = nodesToRender.Count;
NodeCount = nodeCount;
if (nodeCount > 0)
{
TerrainVertex[] vertices = nodesToRender.SelectMany(node => node.Geometry).ToArray();
var command = GenerateRenderCommand();
(command as RenderDeferredCommand<TerrainVertex>).NumVertices = vertices.Length;
vertexBuffer.SetData(vertices);
renderer.EnqueueDeferred(command as IRenderDeferredCommand);
}
}
示例9: AglContext
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext)
{
Debug.Print("Context Type: {0}", shareContext);
Debug.Print("Window info: {0}", window);
this.graphics_mode = mode;
this.carbonWindow = (CarbonWindowInfo)window;
if (shareContext is AglContext)
shareContextRef = ((AglContext)shareContext).Handle.Handle;
if (shareContext is GraphicsContext)
{
ContextHandle shareHandle = shareContext != null ?
(shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
shareContextRef = shareHandle.Handle;
}
if (shareContextRef == IntPtr.Zero)
{
Debug.Print("No context sharing will take place.");
}
CreateContext(mode, carbonWindow, shareContextRef, true);
}
示例10: EglContext
int swap_interval = 1; // Default interval is defined as 1 in EGL.
#endregion
#region Constructors
public EglContext(GraphicsMode mode, EglWindowInfo window, IGraphicsContext sharedContext,
int major, int minor, GraphicsContextFlags flags)
{
if (mode == null)
throw new ArgumentNullException("mode");
if (window == null)
throw new ArgumentNullException("window");
EglContext shared = (EglContext)sharedContext;
int dummy_major, dummy_minor;
if (!Egl.Initialize(window.Display, out dummy_major, out dummy_minor))
throw new GraphicsContextException(String.Format("Failed to initialize EGL, error {0}.", Egl.GetError()));
WindowInfo = window;
// Select an EGLConfig that matches the desired mode. We cannot use the 'mode'
// parameter directly, since it may have originated on a different system (e.g. GLX)
// and it may not support the desired renderer.
Mode = new EglGraphicsMode().SelectGraphicsMode(mode.ColorFormat,
mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat,
mode.Buffers, mode.Stereo,
major > 1 ? RenderableFlags.ES2 : RenderableFlags.ES);
if (!Mode.Index.HasValue)
throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
IntPtr config = Mode.Index.Value;
if (window.Surface == IntPtr.Zero)
window.CreateWindowSurface(config);
int[] attrib_list = new int[] { Egl.CONTEXT_CLIENT_VERSION, major, Egl.NONE };
HandleAsEGLContext = Egl.CreateContext(window.Display, config, shared != null ? shared.HandleAsEGLContext : IntPtr.Zero, attrib_list);
MakeCurrent(window);
}
示例11: iPhoneOSGraphicsContext
internal iPhoneOSGraphicsContext(ContextHandle handle, IWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags)
{
// ignore mode, window
iPhoneOSGraphicsContext shared = sharedContext as iPhoneOSGraphicsContext;
EAGLRenderingAPI version = 0;
if (major == 1 && minor == 1)
version = EAGLRenderingAPI.OpenGLES1;
else if (major == 2 && minor == 0)
version = EAGLRenderingAPI.OpenGLES2;
else if (major == 3 && minor == 0)
version = EAGLRenderingAPI.OpenGLES3;
else
throw new ArgumentException (string.Format("Unsupported GLES version {0}.{1}.", major, minor));
if (handle.Handle == IntPtr.Zero) {
EAGLContext = shared != null && shared.EAGLContext != null
? new EAGLContext(version, shared.EAGLContext.ShareGroup)
: new EAGLContext(version);
contextHandle = new ContextHandle(EAGLContext.Handle);
} else {
EAGLContext = (EAGLContext) Runtime.GetNSObject (handle.Handle);
contextHandle = handle;
}
}
示例12: VertexBuffer
public VertexBuffer(IGraphicsContext context, BufferUsageHint hint)
{
this.GraphicsContext = context;
this.hint = hint;
this.GraphicsContext.GenBuffers(1, out Handle);
}
示例13: RenderManager
protected RenderManager(IGraphicsContext graphics)
{
_graphics = graphics;
// todo: subscribe to changes to asset libraries and build a dirty list for each library which will be processed on the next call to UpdateAssets. also observe changes to group dormancy.
// 1. if a mesh has been removed, check the asset group and if it's empty, destroy the buffer. ignore removed meshes; we'll leave them in place for performance reasons.
// 2. if a mesh has been added or updated, rebuild the buffer for now. later we may be able to optimise to do in-place buffer updates if it's an issue, but it probably won't be.
}
示例14: Draw
public override void Draw(IGraphicsContext gc)
{
int depth = CountParentDepth ();
Color color = _Colors [depth]; // CountParentDepth is expensive - so don't call ComponentColor here...
Color contactColor = color;
if (IsNotEmptyString (TypeName) == false)
{
color = Color.Crimson;
}
if (IsNotEmptyString (Name) == false)
{
color = Color.Red;
}
gc.Color = color;
DrawComponent (gc, _Bounds.Left, _Bounds.Top, _Bounds.Width, _Bounds.Height, 20, 2+depth, color);
gc.Color = contactColor;
gc.Thickness = 2 + depth;
if (Selected)
{
foreach (IGlyph contact in ContactPoints)
{
contact.Draw (gc);
}
}
}
示例15: FreeMovementRenderableAsset
public FreeMovementRenderableAsset(IGraphicsContext context)
{
_texture = context.LoadTexture2D("freeMovementWidget");
_boundingBox = new AxisAlignedBoundingBox2D(0, 0, _texture.Height, _texture.Width);
RenderingOffset = -AABoundingBox.Center;
Origin = AABoundingBox.Center;
}