コード例 #1
0
        public void InitWithBitmapGL11(Bitmap imageSource, GL11.All filter)
        {
            //TODO:  Android.Opengl.GLUtils.GetInternalFormat()
            openGLVersion = GLContextVersion.Gles1_1;

            _format = SurfaceFormat.Color;
            if (imageSource.HasAlpha)
            {
                _format = SurfaceFormat.Color;
            }

            // scale up bitmap to be power of 2 dimensions but dont exceed 1024x1024.
            // Note: may not have to do this with OpenGL 2+

            _width  = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Width) / Math.Log10(2))));
            _height = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Height) / Math.Log10(2))));

            _size.Width  = imageSource.Width;
            _size.Height = imageSource.Height;

            using (Bitmap imageScaled = Bitmap.CreateScaledBitmap(imageSource, _width, _height, false))
            {
                GL11.GL.GenTextures(1, ref _name);
                GL11.GL.BindTexture(GL11.All.Texture2D, _name);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMinFilter, (int)filter);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMagFilter, (int)filter);

                Android.Opengl.GLUtils.TexImage2D((int)GL11.All.Texture2D, 0, imageScaled, 0);
            }

            _maxS = _size.Width / (float)_width;
            _maxT = _size.Height / (float)_height;

            _pixelData = imageSource.Handle;
        }
コード例 #2
0
        public void InitWithDataGL20(IntPtr data, SurfaceFormat pixelFormat, int width, int height, Size size, GL20.All filter)
        {
            openGLVersion = GLContextVersion.Gles2_0;

            GL20.GL.GenTextures(1, ref _name);
            GL20.GL.BindTexture(GL20.All.Texture2D, _name);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMinFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMagFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapS, (int)GL20.All.ClampToEdge);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapT, (int)GL20.All.ClampToEdge);

            int sz = 0;

            switch (pixelFormat)
            {
            case SurfaceFormat.Color /*kTexture2DPixelFormat_RGBA8888*/:
            case SurfaceFormat.Dxt1:
            case SurfaceFormat.Dxt3:
                sz = 4;
                GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedByte, data);
                break;

            case SurfaceFormat.Bgra4444 /*kTexture2DPixelFormat_RGBA4444*/:
                sz = 2;
                GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedShort4444, data);
                break;

            case SurfaceFormat.Bgra5551 /*kTexture2DPixelFormat_RGB5A1*/:
                sz = 2;
                GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedShort5551, data);
                break;

            case SurfaceFormat.Alpha8 /*kTexture2DPixelFormat_A8*/:
                sz = 1;
                GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Alpha, (int)width, (int)height, 0, GL20.All.Alpha, GL20.All.UnsignedByte, data);
                break;

            default:
                throw new NotSupportedException("Texture format");
            }

            _size   = size;
            _width  = width;
            _height = height;
            _format = pixelFormat;
            _maxS   = size.Width / (float)width;
            _maxT   = size.Height / (float)height;

            _pixelData = data;
        }
コード例 #3
0
        public static GLCalls GetGLCalls(GLContextVersion api)
        {
            switch (api)
            {
            case GLContextVersion.Gles1_1:
                return(CreateES1());

            case GLContextVersion.Gles2_0:
                return(CreateES2());

            case GLContextVersion.Gles3_0:
                return(CreateES3());

            case GLContextVersion.Gles3_1:
                return(CreateES31());
            }
            throw new ArgumentException("api");
        }
コード例 #4
0
        public void InitWithBitmapGL20(Bitmap imageSource, GL20.All filter)
        {
            //TODO:  Android.Opengl.GLUtils.GetInternalFormat()
            //Android.Opengl.GLUtils.GetInternalFormat(imageSource);
            openGLVersion = GLContextVersion.Gles2_0;

            _format = SurfaceFormat.Color;
            if (imageSource.HasAlpha)
            {
                _format = SurfaceFormat.Color;
            }

            _width  = imageSource.Width;
            _height = imageSource.Height;

            _size.Width  = imageSource.Width;
            _size.Height = imageSource.Height;

            GL20.GL.GenTextures(1, ref _name);
            GL20.GL.BindTexture(GL20.All.Texture2D, _name);

            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMinFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMagFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapS, (int)GL20.All.ClampToEdge);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapT, (int)GL20.All.ClampToEdge);

            Android.Opengl.GLUtils.TexImage2D((int)GL20.All.Texture2D, 0, imageSource, 0);
            imageSource.Recycle();

            //int errAndroidGL = Android.Opengl.GLES20.GlGetError();
            //GL20.All errGenericGL = GL20.GL.GetError();
            //if(errAndroidGL != Android.Opengl.GLES20.GlNoError || errGenericGL != GL20.All.NoError )
            //    Console.WriteLine(string.Format("OpenGL-ES 2.0:\n\tAndroid:{0,10:X}\n\tGeneric:{0, 10:X}", errAndroidGL, errGenericGL));

            _maxS = _size.Width / (float)_width;
            _maxT = _size.Height / (float)_height;
        }
コード例 #5
0
		public AndroidGraphicsContext (GraphicsMode mode, IWindowInfo window, IGraphicsContext sharedContext,
								GLContextVersion glesVersion, GraphicsContextFlags flags)
コード例 #6
0
		internal static AndroidGraphicsContext CreateGraphicsContext (GraphicsMode mode, IWindowInfo window,
			IGraphicsContext sharedContext, GLContextVersion glVersion, GraphicsContextFlags flags)
コード例 #7
0
 public AndroidGraphicsContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext sharedContext,
                               GLContextVersion glesVersion, GraphicsContextFlags flags)
コード例 #8
0
 internal static AndroidGraphicsContext CreateGraphicsContext(GraphicsMode mode, IWindowInfo window,
                                                              IGraphicsContext sharedContext, GLContextVersion glVersion, GraphicsContextFlags flags)
コード例 #9
0
ファイル: ESTexture2D.cs プロジェクト: Jorgemagic/MonoGame
        public void InitWithDataGL20(IntPtr data, SurfaceFormat pixelFormat, int width, int height, Size size, GL20.All filter)
        {
            openGLVersion = GLContextVersion.Gles2_0;

            GL20.GL.GenTextures(1, ref _name);
            GL20.GL.BindTexture(GL20.All.Texture2D, _name);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMinFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureMagFilter, (int)filter);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapS, (int)GL20.All.ClampToEdge);
            GL20.GL.TexParameter(GL20.All.Texture2D, GL20.All.TextureWrapT, (int)GL20.All.ClampToEdge);

            int sz = 0;

            switch (pixelFormat)
            {
                case SurfaceFormat.Color /*kTexture2DPixelFormat_RGBA8888*/:
                case SurfaceFormat.Dxt1:
                case SurfaceFormat.Dxt3:
                    sz = 4;
                    GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedByte, data);
                    break;
                case SurfaceFormat.Bgra4444 /*kTexture2DPixelFormat_RGBA4444*/:
                    sz = 2;
                    GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedShort4444, data);
                    break;
                case SurfaceFormat.Bgra5551 /*kTexture2DPixelFormat_RGB5A1*/:
                    sz = 2;
                    GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Rgba, (int)width, (int)height, 0, GL20.All.Rgba, GL20.All.UnsignedShort5551, data);
                    break;
                case SurfaceFormat.Alpha8 /*kTexture2DPixelFormat_A8*/:
                    sz = 1;
                    GL20.GL.TexImage2D(GL20.All.Texture2D, 0, (int)GL20.All.Alpha, (int)width, (int)height, 0, GL20.All.Alpha, GL20.All.UnsignedByte, data);
                    break;
                default:
                    throw new NotSupportedException("Texture format");
            }

            _size = size;
            _width = width;
            _height = height;
            _format = pixelFormat;
            _maxS = size.Width / (float)width;
            _maxT = size.Height / (float)height;

            _pixelData = data;
        }
コード例 #10
0
ファイル: ESTexture2D.cs プロジェクト: Jorgemagic/MonoGame
        public void InitWithBitmapGL20(Bitmap imageSource, GL20.All filter)
        {
            //TODO:  Android.Opengl.GLUtils.GetInternalFormat()
            //Android.Opengl.GLUtils.GetInternalFormat(imageSource);
            openGLVersion = GLContextVersion.Gles2_0;

            _format = SurfaceFormat.Color;
            if (imageSource.HasAlpha)
                _format = SurfaceFormat.Color;

            _width = imageSource.Width;
            _height = imageSource.Height;

            _size.Width = imageSource.Width;
            _size.Height = imageSource.Height;

            GL20.GL.GenTextures(1, ref _name);
            GL20.GL.BindTexture(GL20.All.Texture2D, _name);

            GL20.GL.TexParameter( GL20.All.Texture2D, GL20.All.TextureMinFilter, (int)filter);
            GL20.GL.TexParameter( GL20.All.Texture2D, GL20.All.TextureMagFilter, (int)filter);
            GL20.GL.TexParameter( GL20.All.Texture2D, GL20.All.TextureWrapS, (int)GL20.All.ClampToEdge);
            GL20.GL.TexParameter( GL20.All.Texture2D, GL20.All.TextureWrapT, (int)GL20.All.ClampToEdge);

            Android.Opengl.GLUtils.TexImage2D((int)GL20.All.Texture2D, 0, imageSource, 0);
            imageSource.Recycle();

            //int errAndroidGL = Android.Opengl.GLES20.GlGetError();
            //GL20.All errGenericGL = GL20.GL.GetError();
            //if(errAndroidGL != Android.Opengl.GLES20.GlNoError || errGenericGL != GL20.All.NoError )
            //    Console.WriteLine(string.Format("OpenGL-ES 2.0:\n\tAndroid:{0,10:X}\n\tGeneric:{0, 10:X}", errAndroidGL, errGenericGL));

            _maxS = _size.Width / (float)_width;
            _maxT = _size.Height / (float)_height;
        }
コード例 #11
0
ファイル: ESTexture2D.cs プロジェクト: Jorgemagic/MonoGame
        public void InitWithBitmapGL11(Bitmap imageSource, GL11.All filter)
        {
            //TODO:  Android.Opengl.GLUtils.GetInternalFormat()
            openGLVersion = GLContextVersion.Gles1_1;

            _format = SurfaceFormat.Color;
            if (imageSource.HasAlpha)
                _format = SurfaceFormat.Color;

            // scale up bitmap to be power of 2 dimensions but dont exceed 1024x1024.
            // Note: may not have to do this with OpenGL 2+

            _width = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Width) / Math.Log10(2))));
            _height = (int)Math.Pow(2, Math.Min(10, Math.Ceiling(Math.Log10(imageSource.Height) / Math.Log10(2))));

            _size.Width = imageSource.Width;
            _size.Height = imageSource.Height;

            using (Bitmap imageScaled = Bitmap.CreateScaledBitmap(imageSource, _width, _height, false))
            {
                GL11.GL.GenTextures(1, ref _name);
                GL11.GL.BindTexture(GL11.All.Texture2D, _name);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMinFilter, (int)filter);
                GL11.GL.TexParameter(GL11.All.Texture2D, GL11.All.TextureMagFilter, (int)filter);

                Android.Opengl.GLUtils.TexImage2D((int)GL11.All.Texture2D, 0, imageScaled, 0);
            }

            _maxS = _size.Width / (float)_width;
            _maxT = _size.Height / (float)_height;

            _pixelData = imageSource.Handle;
        }
コード例 #12
0
 internal static extern IntPtr evas_gl_context_version_create(IntPtr evas_gl, IntPtr share_ctx, GLContextVersion version);