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); }
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); }
//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); } } } } }
private void applyConfigOnUiThread() { _graphics.BindTexture2D(ID); _graphics.SetTextureMinFilter(_config.ScaleDownFilter); _graphics.SetTextureMagFilter(_config.ScaleUpFilter); _graphics.SetTextureWrapS(_config.WrapX); _graphics.SetTextureWrapT(_config.WrapY); }
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); }
public void LoadTexture(int?textureToBind) { var scan0 = _bitmap.LockPixels(); if (textureToBind != null) { _graphics.BindTexture2D(textureToBind.Value); } _graphics.TexImage2D(Width, Height, scan0); _bitmap.UnlockPixels(); }
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); }
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); }