Example #1
0
			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;
			}
Example #2
0
		private void DrawRangeElementsNoBase(
			GLenum mode,
			int start,
			int end,
			int count,
			GLenum type,
			IntPtr indices,
			int baseVertex
		) {
			glDrawRangeElements(
				mode,
				start,
				end,
				count,
				type,
				indices
			);
		}
Example #3
0
 /*
  ** PBuffer functions
  */
 [DllImport(agl)] static extern byte aglCreatePBuffer (int width, int height, GLenum target, GLenum internalFormat, long max_level, AGLPbuffer *pbuffer); 
Example #4
0
 static extern byte aglGetInteger(AGLContext ctx, GLenum pname, int* @params);
Example #5
0
 /*
  ** Global library options
  */
 [DllImport(agl)] static extern byte aglConfigure(GLenum pname, uint param);
Example #6
0
		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.");
			}
		}
Example #7
0
 static extern bool aglIsEnabled(AGLContext ctx, GLenum pname);
Example #8
0
 public static extern void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
Example #9
0
 public static extern void GetTexParameteriv(GLenum target, GLuint pname, ref GLint params_k);
Example #10
0
 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));
 }
Example #11
0
 public static extern void BindTexture(GLenum target, GLuint texture);
Example #12
0
            public OpenGLTexture(
				uint handle,
				GLenum target,
				int levelCount
			)
            {
                Handle = handle;
                Target = target;
                HasMipmaps = levelCount > 1;
            }
Example #13
0
        private OpenGLTexture CreateTexture(
			GLenum target,
			int levelCount
		)
        {
            uint handle;
            glCreateTextures(target, 1, out handle);
            OpenGLTexture result = new OpenGLTexture(
                handle,
                target,
                levelCount
            );
            return result;
        }
Example #14
0
 /*
 ** PBuffer functions
 */
 [DllImport(agl)] static extern byte aglCreatePBuffer(int width, int height, GLenum target, GLenum internalFormat, long max_level, AGLPbuffer *pbuffer);
Example #15
0
		private void DrawElementsInstancedNoBase(
			GLenum mode,
			int count,
			GLenum type,
			IntPtr indices,
			int instanceCount,
			int baseVertex
		) {
			glDrawElementsInstanced(
				mode,
				count,
				type,
				indices,
				instanceCount
			);
		}
Example #16
0
 public static extern void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
Example #17
0
		private void GetTexImageESError(
			GLenum target,
			int level,
			GLenum format,
			GLenum type,
			IntPtr pixels
		) {
			throw new NotSupportedException("glGetTexImage is not available in ES!");
		}
Example #18
0
 public static extern void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
Example #19
0
 private string glGetString(GLenum pname)
 {
     unsafe
     {
         return new string((sbyte*) INTERNAL_glGetString(pname));
     }
 }
Example #20
0
 public static extern void FramebufferTextureMultiviewOVR(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);
Example #21
0
		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;
			}
		}
Example #22
0
        public JsonObject getParameter(GLenum pname)
        {
            object result = API.Apply("getParameter", pname);

            return(new JsonObject(result));
        }
Example #23
0
 static extern bool aglIsEnabled(AGLContext ctx, GLenum pname);
Example #24
0
 static extern byte aglConfigure(GLenum pname, uint param);
Example #25
0
 [DllImport(agl)] static extern byte aglIsEnabled(AGLContext ctx, GLenum pname);
Example #26
0
 /*
 ** Global library options
 */
 [DllImport(agl)] static extern byte aglConfigure(GLenum pname, uint param);
Example #27
0
 /*
  ** Surface texture function
  */
 [DllImport(agl)] static extern void aglSurfaceTexture (AGLContext context, GLenum target, GLenum internalformat, AGLContext surfacecontext) ;
Example #28
0
 [DllImport(agl)] static extern byte aglIsEnabled(AGLContext ctx, GLenum pname);
Example #29
0
 [DllImport(agl)] static extern byte aglDescribePBuffer (AGLPbuffer pbuffer, int *width, int *height, GLenum *target, GLenum *internalFormat, int *max_level);
Example #30
0
 static extern byte aglGetInteger(AGLContext ctx, GLenum pname, int * @params);
Example #31
0
		private void DrawRangeElementsUnchecked(
			GLenum mode,
			int start,
			int end,
			int count,
			GLenum type,
			IntPtr indices
		) {
			glDrawElements(
				mode,
				count,
				type,
				indices
			);
		}
Example #32
0
 /*
 ** Surface texture function
 */
 [DllImport(agl)] static extern void aglSurfaceTexture(AGLContext context, GLenum target, GLenum internalformat, AGLContext surfacecontext);
Example #33
0
		private void PolygonModeESError(GLenum face, GLenum mode)
		{
			throw new NotSupportedException("glPolygonMode is not available in ES!");
		}
Example #34
0
			public OpenGLBuffer(
				uint handle,
				IntPtr bufferSize,
				GLenum dynamic
			) {
				Handle = handle;
				BufferSize = bufferSize;
				Dynamic = dynamic;
			}
Example #35
0
		private void GetBufferSubDataESError(
			GLenum target,
			IntPtr offset,
			IntPtr size,
			IntPtr data
		) {
			throw new NotSupportedException("glGetBufferSubData is not available in ES!");
		}
Example #36
0
		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;
		}
Example #37
0
        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.");
            }
        }
Example #38
0
		private void ToggleGLState(GLenum feature, bool enable)
		{
			if (enable)
			{
				glEnable(feature);
			}
			else
			{
				glDisable(feature);
			}
		}
Example #39
0
 private string glGetStringi(GLenum pname, uint index)
 {
     unsafe
     {
         return new string((sbyte*) INTERNAL_glGetStringi(pname, index));
     }
 }
Example #40
0
 static extern byte aglConfigure(GLenum pname, uint param);