如何使用XNA画线? [英] How do I draw lines using XNA?

查看:100
本文介绍了如何使用XNA画线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一堆涉及XNA(及其各种版本)的教程,但我对绘制图元仍然有些困惑.一切似乎都令人费解.

I've read a bunch of tutorials involving XNA (and it's various versions) and I still am a little confused on drawing primitives. Everything seems to be really convoluted.

有人可以使用代码向我展示在屏幕上绘制一两行的最简单的XNA实现吗?也许有一个简短的解释(包括样板)?

Can someone show me, using code, the simplest XNA implementation of drawing one or two lines on to the screen? Perhaps with a brief explanation (including the boilerplate)?

我不是游戏程序员,并且几乎没有XNA经验.我的最终目标是在屏幕上绘制一些线条,这些线条最终将随着旋转等(手动)进行变换.但是,对于这第一步.我只需要画线即可!我记得在我远古的OpenGL时代,用一些方法调用画一条线是相当简单的.我应该简单地恢复使用非托管的Directx调用吗?

I'm not a games programmer and I have little XNA experience. My ultimate goal is to draw some lines onto the screen which I will eventually transform with rotations, etc (by hand). However, for this first step.. I need to simply draw the lines! I remember back in my ancient OpenGL days it was fairly straightforward when drawing a line with a few method calls. Should I simply revert to using unmanaged directx calls?

推荐答案

使用XNA时,必须以3d卡可以理解的方式来表示所有内容(甚至2d图元),这意味着一条线只是一条线.一组顶点.

When working with XNA, everything (even 2d primitives) have to be expressed in a way that a 3d card can understand, which means that a line is just a set of vertices.

MSDN在这里有一个很好的演练:

MSDN has a pretty good walkthrough here:

http://msdn.microsoft.com/en-us/library/bb196414.aspx#ID2EEF

您会发现,渲染基本线所需的代码要比设置纹理四边形并旋转所需的代码更多,因为从本质上讲,渲染线条时您执行相同的操作.

You'll find that it takes more code to render a primitive line than it would take to just setup a textured quad and rotate that, since in essence, your doing the same thing when rendering a line.

这篇关于如何使用XNA画线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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