将纹理渲染到图像(.net cf) [英] Render texture to image (.net cf)

查看:137
本文介绍了将纹理渲染到图像(.net cf)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正在尝试在.net cf中绘制带有开放式gls的非矩形2D形状(多边形,椭圆形),这些形状带有渐变纹理.我以为我可以通过绘制一个其顶点着色的矩形来创建渐变,而不是使用该矩形作为实际形状上的纹理.唯一的问题是,我可以找到一个工作代码段,其中显示了如何将opengl场景渲染到Texture或Image(位图)对象上.
渐变必须是动态的,因此从文件中加载渐变是不可能的,我必须在运行时创建渐变.

请引导我朝正确的方向.
预先提交:Bali

Hi There!

I''m trying to draw non rectangular 2D shapes (polygons, ellipses) with open gl es in .net cf, which are textured with gradients. I thought that i could create the gradient by drawing a rectangle with its vertices colored and than use that rectangle as a texture on the actual shapes. The only problem is that i can find a working code snippet that show how to render an opengl scene onto a Texture or Image (Bitmap) object.
The gradients has to be dynamic so loading them from file is out of the question, i have to create them in run time.

Please guide me to the right direction.
Thx in advance: Bali

推荐答案

[ ^ ] NeHe文章(除其他内容外)还向您显示如何渲染到纹理.基本过程是将视口设置为纹理的大小,然后渲染所需的任何内容,最后使用glCopyTexImage2D将屏幕缓冲区复制到纹理.
如果您需要在每个帧上更新纹理,最好避免使用FBO(帧缓冲区对象)将其复制到纹理上并直接渲染到纹理上,这在此处 [ ^ ],但是稍微复杂一些.
This[^] NeHe article (among other things) shows you how to render to a texture. The basic procedure is to set the viewport to the size of the texture then render whatever you need, and finally to copy your screen buffer to the texture using glCopyTexImage2D.

If you need to update the texture every frame you''d be better off avoiding the copy to texture and rendering straight onto the texture using FBOs (Frame Buffer Objects) which is demonstrated Here[^] but it''s a little more complicated.


感谢您的回答,我将尝试一下.
Thank you for the answer, I''ll try it out.


这篇关于将纹理渲染到图像(.net cf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆