コード例 #1
0
ファイル: GLUtils.cs プロジェクト: jeancallisti/MonoAGS
        public void DrawQuad(int texture, GLVertex[] vertices)
        {
            texture = getTexture(texture);
            _graphics.BindTexture2D(texture);

            _graphics.BufferData(vertices, GLVertex.Size, BufferType.ArrayBuffer);
            _graphics.InitPointers(GLVertex.Size);

            _graphics.BufferData(_quadIndices, sizeof(short), BufferType.ElementArrayBuffer);
            _graphics.SetShaderAppVars();

            _graphics.DrawElements(PrimitiveMode.Triangles, 6, _quadIndices);
        }
コード例 #2
0
        public bool Begin()
        {
            _graphics.BindTexture2D(Texture.ID);
            _graphics.BindFrameBuffer(_fbo);
            _graphics.FrameBufferTexture2D(Texture.ID);
            _graphics.BindTexture2D(0);
            if (!_graphics.DrawFrameBuffer())
            {
                return(false);
            }

            _graphics.Viewport(0, 0, _width, _height);
            return(true);
        }
コード例 #3
0
ファイル: IOSBitmap.cs プロジェクト: ebrucucen/MonoAGS
        //https://github.com/xamarin/mobile-samples/blob/master/TexturedCubeES30/TexturedCubeiOS/EAGLView.cs
        public void LoadTexture(int?textureToBind)
        {
            if (textureToBind != null)
            {
                _graphics.BindTexture2D(textureToBind.Value);
            }

            var width  = _cgImage.Width;
            var height = _cgImage.Height;

            using (CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB())
            {
                byte[]    imageData = new byte[height * width * 4];
                CGContext context   = new CGBitmapContext(imageData, width, height, 8, 4 * width, colorSpace,
                                                          CGBitmapFlags.PremultipliedLast | CGBitmapFlags.ByteOrder32Big);

                using (context)
                {
                    context.TranslateCTM(0, height);
                    context.ScaleCTM(1, -1);
                    context.ClearRect(new CGRect(0, 0, width, height));
                    context.DrawImage(new CGRect(0, 0, width, height), _cgImage);

                    unsafe
                    {
                        fixed(byte *p = imageData)
                        {
                            IntPtr ptr = (IntPtr)p;

                            _graphics.TexImage2D(Width, Height, ptr);
                        }
                    }
                }
            }
        }
コード例 #4
0
 private void applyConfigOnUiThread()
 {
     _graphics.BindTexture2D(ID);
     _graphics.SetTextureMinFilter(_config.ScaleDownFilter);
     _graphics.SetTextureMagFilter(_config.ScaleUpFilter);
     _graphics.SetTextureWrapS(_config.WrapX);
     _graphics.SetTextureWrapT(_config.WrapY);
 }
コード例 #5
0
        private int createTexture()
        {
            int text_texture = _graphics.GenTexture();

            _graphics.BindTexture2D(text_texture);
            _graphics.SetTextureMagFilter(ScaleUpFilters.Linear);
            _graphics.SetTextureMinFilter(ScaleDownFilters.Linear);
            //GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, 1024, 1024, 0,
            //    OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); // just allocate memory, so we can update efficiently using TexSubImage2D
            return(text_texture);
        }
コード例 #6
0
ファイル: AndroidBitmap.cs プロジェクト: saizant/MonoAGS
        public void LoadTexture(int?textureToBind)
        {
            var scan0 = _bitmap.LockPixels();

            if (textureToBind != null)
            {
                _graphics.BindTexture2D(textureToBind.Value);
            }

            _graphics.TexImage2D(Width, Height, scan0);
            _bitmap.UnlockPixels();
        }
コード例 #7
0
ファイル: GLShader.cs プロジェクト: tzachshabtay/MonoAGS
        private void bindTextures()
        {
            int i = 0;

            foreach (var pair in _textures)
            {
                _graphics.Uniform1(pair.Key, i);
                _graphics.ActiveTexture(i);
                _graphics.BindTexture2D(pair.Value);
                i++;
            }
            _graphics.ActiveTexture(0);
        }
コード例 #8
0
        public void LoadTexture(int?textureToBind)
        {
            BitmapData data = _bitmap.LockBits(new System.Drawing.Rectangle(0, 0, Width, Height),
                                               ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            if (textureToBind != null)
            {
                _graphics.BindTexture2D(textureToBind.Value);
            }

            _graphics.TexImage2D(Width, Height, data.Scan0);
            _bitmap.UnlockBits(data);
        }