[英]Is there any open source wrapper around UnityEngine.GL namespace that would provide System.Drawing.Graphics alike intereface?
我很想看看System.Drawing.Graphics
方法,如DrawPath(pen, path)
, TranslateTransform(dx, dy, order)
, ScaleTransform(sx, sy, order)
圍繞UnityEngine.GL
(或至少其他一些OpenGL庫)創建我自己的端口)。 有沒有這樣的包裝器/庫?
假設要繪制一個要統一使用的紋理,這是使用cairo來構建可直接用於opengl紋理化的位圖的最簡單示例。 包裝是Mono.Cairo
using System;
using Cairo;
namespace cairoTests
{
class Program
{
static void Main(string[] args)
{
int height = 512;
int width = 512;
int stride = 4 * width;
int bmpSize = stride * height;
byte[] bmp = new byte[bmpSize];
using (ImageSurface surf =
new ImageSurface(bmp, Format.Argb32, width, height, stride))
{
using (Context ctx = new Context(surf))
{
ctx.SetSourceRGB(1, 0, 0);
ctx.Rectangle(10, 10, 100, 100);
ctx.Fill();
}
surf.Flush();
//surf.WriteToPng(@"c:/test.png");
}
//now you have bmp filled, and may pass it to your game engine as texture
}
}
}
下一步是創建一個egl上下文,並嘗試將所有工作保留在gpu上,並傳遞最終紋理,就像綁定一個已經存在的紋理一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.