public OpenGLTexture( uint handle, GLenum target, int levelCount ) { Handle = handle; Target = target; HasMipmaps = levelCount > 1; WrapS = TextureAddressMode.Wrap; WrapT = TextureAddressMode.Wrap; WrapR = TextureAddressMode.Wrap; Filter = TextureFilter.Linear; Anistropy = 4.0f; MaxMipmapLevel = 0; LODBias = 0.0f; }
private void DrawRangeElementsNoBase( GLenum mode, int start, int end, int count, GLenum type, IntPtr indices, int baseVertex ) { glDrawRangeElements( mode, start, end, count, type, indices ); }
/* ** PBuffer functions */ [DllImport(agl)] static extern byte aglCreatePBuffer (int width, int height, GLenum target, GLenum internalFormat, long max_level, AGLPbuffer *pbuffer);
static extern byte aglGetInteger(AGLContext ctx, GLenum pname, int* @params);
/* ** Global library options */ [DllImport(agl)] static extern byte aglConfigure(GLenum pname, uint param);
private static void DebugCallback( GLenum source, GLenum type, uint id, GLenum severity, int length, IntPtr message, // const GLchar* IntPtr userParam // const GLvoid* ) { FNAPlatform.Log( Marshal.PtrToStringAnsi(message) + "\n\tSource: " + source.ToString() + "\n\tType: " + type.ToString() + "\n\tSeverity: " + severity.ToString() ); if (type == GLenum.GL_DEBUG_TYPE_ERROR_ARB) { throw new InvalidOperationException("ARB_debug_output found an error."); } }
static extern bool aglIsEnabled(AGLContext ctx, GLenum pname);
public static extern void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
public static extern void GetTexParameteriv(GLenum target, GLuint pname, ref GLint params_k);
public static cl_mem CreateFromGLTexture3D(cl_context context, cl_mem_flags flags, GLenum target, GLint mipLevel, GLuint texture, out ErrorCode errcode_ret) { return(OpenCLAPI.clCreateFromGLTexture3D(context, flags, target, mipLevel, texture, out errcode_ret)); }
public static extern void BindTexture(GLenum target, GLuint texture);
public OpenGLTexture( uint handle, GLenum target, int levelCount ) { Handle = handle; Target = target; HasMipmaps = levelCount > 1; }
private OpenGLTexture CreateTexture( GLenum target, int levelCount ) { uint handle; glCreateTextures(target, 1, out handle); OpenGLTexture result = new OpenGLTexture( handle, target, levelCount ); return result; }
/* ** PBuffer functions */ [DllImport(agl)] static extern byte aglCreatePBuffer(int width, int height, GLenum target, GLenum internalFormat, long max_level, AGLPbuffer *pbuffer);
private void DrawElementsInstancedNoBase( GLenum mode, int count, GLenum type, IntPtr indices, int instanceCount, int baseVertex ) { glDrawElementsInstanced( mode, count, type, indices, instanceCount ); }
public static extern void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
private void GetTexImageESError( GLenum target, int level, GLenum format, GLenum type, IntPtr pixels ) { throw new NotSupportedException("glGetTexImage is not available in ES!"); }
public static extern void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
private string glGetString(GLenum pname) { unsafe { return new string((sbyte*) INTERNAL_glGetString(pname)); } }
public static extern void FramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);
public void SetRenderTargets( RenderTargetBinding[] renderTargets, IGLRenderbuffer renderbuffer, DepthFormat depthFormat ) { // Bind the right framebuffer, if needed if (renderTargets == null) { BindFramebuffer( (Backbuffer is OpenGLBackbuffer) ? (Backbuffer as OpenGLBackbuffer).Handle : 0 ); flipViewport = 1; return; } else { BindFramebuffer(targetFramebuffer); flipViewport = -1; } int i; uint[] attachments = new uint[renderTargets.Length]; GLenum[] attachmentTypes = new GLenum[renderTargets.Length]; for (i = 0; i < renderTargets.Length; i += 1) { IGLRenderbuffer colorBuffer = (renderTargets[i].RenderTarget as IRenderTarget).ColorBuffer; if (colorBuffer != null) { attachments[i] = (colorBuffer as OpenGLRenderbuffer).Handle; attachmentTypes[i] = GLenum.GL_RENDERBUFFER; } else { attachments[i] = (renderTargets[i].RenderTarget.texture as OpenGLTexture).Handle; if (renderTargets[i].RenderTarget is RenderTarget2D) { attachmentTypes[i] = GLenum.GL_TEXTURE_2D; } else { attachmentTypes[i] = GLenum.GL_TEXTURE_CUBE_MAP_POSITIVE_X + (int) renderTargets[i].CubeMapFace; } } } // Update the color attachments, DrawBuffers state for (i = 0; i < attachments.Length; i += 1) { if (attachments[i] != currentAttachments[i]) { if (currentAttachments[i] != 0) { if ( attachmentTypes[i] != GLenum.GL_RENDERBUFFER && currentAttachmentTypes[i] == GLenum.GL_RENDERBUFFER ) { glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, GLenum.GL_RENDERBUFFER, 0 ); } else if ( attachmentTypes[i] == GLenum.GL_RENDERBUFFER && currentAttachmentTypes[i] != GLenum.GL_RENDERBUFFER ) { glFramebufferTexture2D( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, currentAttachmentTypes[i], 0, 0 ); } } if (attachmentTypes[i] == GLenum.GL_RENDERBUFFER) { glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, GLenum.GL_RENDERBUFFER, attachments[i] ); } else { glFramebufferTexture2D( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, attachmentTypes[i], attachments[i], 0 ); } currentAttachments[i] = attachments[i]; currentAttachmentTypes[i] = attachmentTypes[i]; } else if (attachmentTypes[i] != currentAttachmentTypes[i]) { // Texture cube face change! glFramebufferTexture2D( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, attachmentTypes[i], attachments[i], 0 ); currentAttachmentTypes[i] = attachmentTypes[i]; } } while (i < currentAttachments.Length) { if (currentAttachments[i] != 0) { if (currentAttachmentTypes[i] == GLenum.GL_RENDERBUFFER) { glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, GLenum.GL_RENDERBUFFER, 0 ); } else { glFramebufferTexture2D( GLenum.GL_FRAMEBUFFER, GLenum.GL_COLOR_ATTACHMENT0 + i, currentAttachmentTypes[i], 0, 0 ); } currentAttachments[i] = 0; currentAttachmentTypes[i] = GLenum.GL_TEXTURE_2D; } i += 1; } if (attachments.Length != currentDrawBuffers) { glDrawBuffers(attachments.Length, drawBuffersArray); currentDrawBuffers = attachments.Length; } // Update the depth/stencil attachment /* FIXME: Notice that we do separate attach calls for the stencil. * We _should_ be able to do a single attach for depthstencil, but * some drivers (like Mesa) cannot into GL_DEPTH_STENCIL_ATTACHMENT. * Use XNAToGL.DepthStencilAttachment when this isn't a problem. * -flibit */ uint handle; if (renderbuffer == null) { handle = 0; } else { handle = (renderbuffer as OpenGLRenderbuffer).Handle; } if (handle != currentRenderbuffer) { if (currentDepthStencilFormat == DepthFormat.Depth24Stencil8) { glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_STENCIL_ATTACHMENT, GLenum.GL_RENDERBUFFER, 0 ); } currentDepthStencilFormat = depthFormat; glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_DEPTH_ATTACHMENT, GLenum.GL_RENDERBUFFER, handle ); if (currentDepthStencilFormat == DepthFormat.Depth24Stencil8) { glFramebufferRenderbuffer( GLenum.GL_FRAMEBUFFER, GLenum.GL_STENCIL_ATTACHMENT, GLenum.GL_RENDERBUFFER, handle ); } currentRenderbuffer = handle; } }
public JsonObject getParameter(GLenum pname) { object result = API.Apply("getParameter", pname); return(new JsonObject(result)); }
static extern byte aglConfigure(GLenum pname, uint param);
[DllImport(agl)] static extern byte aglIsEnabled(AGLContext ctx, GLenum pname);
/* ** Surface texture function */ [DllImport(agl)] static extern void aglSurfaceTexture (AGLContext context, GLenum target, GLenum internalformat, AGLContext surfacecontext) ;
[DllImport(agl)] static extern byte aglDescribePBuffer (AGLPbuffer pbuffer, int *width, int *height, GLenum *target, GLenum *internalFormat, int *max_level);
static extern byte aglGetInteger(AGLContext ctx, GLenum pname, int * @params);
private void DrawRangeElementsUnchecked( GLenum mode, int start, int end, int count, GLenum type, IntPtr indices ) { glDrawElements( mode, count, type, indices ); }
/* ** Surface texture function */ [DllImport(agl)] static extern void aglSurfaceTexture(AGLContext context, GLenum target, GLenum internalformat, AGLContext surfacecontext);
private void PolygonModeESError(GLenum face, GLenum mode) { throw new NotSupportedException("glPolygonMode is not available in ES!"); }
public OpenGLBuffer( uint handle, IntPtr bufferSize, GLenum dynamic ) { Handle = handle; BufferSize = bufferSize; Dynamic = dynamic; }
private void GetBufferSubDataESError( GLenum target, IntPtr offset, IntPtr size, IntPtr data ) { throw new NotSupportedException("glGetBufferSubData is not available in ES!"); }
private OpenGLTexture CreateTexture( GLenum target, int levelCount ) { uint handle; glGenTextures(1, out handle); OpenGLTexture result = new OpenGLTexture( handle, target, levelCount ); BindTexture(result); glTexParameteri( result.Target, GLenum.GL_TEXTURE_WRAP_S, XNAToGL.Wrap[(int) result.WrapS] ); glTexParameteri( result.Target, GLenum.GL_TEXTURE_WRAP_T, XNAToGL.Wrap[(int) result.WrapT] ); glTexParameteri( result.Target, GLenum.GL_TEXTURE_WRAP_R, XNAToGL.Wrap[(int) result.WrapR] ); glTexParameteri( result.Target, GLenum.GL_TEXTURE_MAG_FILTER, XNAToGL.MagFilter[(int) result.Filter] ); glTexParameteri( result.Target, GLenum.GL_TEXTURE_MIN_FILTER, result.HasMipmaps ? XNAToGL.MinMipFilter[(int) result.Filter] : XNAToGL.MinFilter[(int) result.Filter] ); glTexParameterf( result.Target, GLenum.GL_TEXTURE_MAX_ANISOTROPY_EXT, (result.Filter == TextureFilter.Anisotropic) ? Math.Max(result.Anistropy, 1.0f) : 1.0f ); glTexParameteri( result.Target, GLenum.GL_TEXTURE_BASE_LEVEL, result.MaxMipmapLevel ); if (!useES2) { glTexParameterf( result.Target, GLenum.GL_TEXTURE_LOD_BIAS, result.LODBias ); } return result; }
private static void DebugCallback( GLenum source, GLenum type, uint id, GLenum severity, int length, IntPtr message, // const GLchar* IntPtr userParam // const GLvoid* ) { System.Console.WriteLine( "{0}\n\tSource: {1}\n\tType: {2}\n\tSeverity: {3}", Marshal.PtrToStringAnsi(message), source.ToString(), type.ToString(), severity.ToString() ); if (type == GLenum.GL_DEBUG_TYPE_ERROR_ARB) { throw new Exception("ARB_debug_output found an error."); } }
private void ToggleGLState(GLenum feature, bool enable) { if (enable) { glEnable(feature); } else { glDisable(feature); } }
private string glGetStringi(GLenum pname, uint index) { unsafe { return new string((sbyte*) INTERNAL_glGetStringi(pname, index)); } }