public static void DrawQuad(Texture tex, float sx, float sy, float fx, float fy, float colorr = 1.0, float colorg = 1.0, float colorb = 1.0, float depth = 0.0, float alpha = 1.0, float tsx = 0.0, float tsy = 0.0, float tfx = 1.0, float tfy = 1.0) { check(); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, tex.Pointer); GL.Color4(colorr, colorg, colorb, alpha); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Begin(BeginMode.Quads); // Top-left! GL.TexCoord2(tsx, tsy); GL.Vertex3(sx, sy, depth); // Top-right! GL.TexCoord2(tfx, tsy); GL.Vertex3(fx, sy, depth); // Bottom-right! GL.TexCoord2(tfx, tfy); GL.Vertex3(fx, fy, depth); // Bottom-left! GL.TexCoord2(tsx, tfy); GL.Vertex3(sx, fy, depth); GL.End(); GL.Disable(EnableCap.Texture2D); }
private void drawCursor(Texture t, int x, int y) { Graphics.DrawQuad(t, x, y, x + t.Width, y + t.Height); }
public static void DestroyTexture(Texture tex) { check(true); GL.DeleteTexture(tex.Pointer); tex.Pointer = 0; }
public static void UploadTexture(Texture tex, System.Drawing.Bitmap bitmap) { check(true); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, tex.Pointer); lock (bitmap) { BitmapData bd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Actually upload the data. GL.TexImage2D(TextureTarget.Texture2D, 0, (int)PixelInternalFormat.Rgba8, bd.Width, bd.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bd.Scan0); bitmap.UnlockBits(bd); } GL.Disable(EnableCap.Texture2D); }