在 OpenGL 中绘制一个简单的抗锯齿火柴人

发布于 2024-11-03 21:35:54 字数 436 浏览 1 评论 0原文

我想在屏幕上画一个简单的 2D 火柴人。我还希望它能够消除锯齿。

问题是我想使用骨骼系统,该系统将在我知道如何根据关节位置绘制火柴人本身之后编写。这意味着我不能使用精灵 - 我希望我的火柴人在代码中完全可控。

如果也能画曲线那就太好了。

使用模型绘制 3D 火柴人也很棒,甚至更好。相机的位置将像 2D 一样,但我仍然会有深度。问题是我只有 Maya 经验,在 OpenGL 中模型的导出和顶点权重似乎一团糟......

我试图找到用于 2D 抗锯齿绘图的库或启用多重采样并正常绘制,但我没有运气。我还尝试使用 OpenGL 的本机抗锯齿功能,但它似乎已被弃用,并且线连接很糟糕...

我不希望它太复杂,因为,好吧,它不应该如此 - 这只是我的第一部分程序,它正在画一个火柴人...

我希望你们能帮助我,我相信你们比我更了解:)

I would like to draw a simple 2D stickman on the screen. I also want it to be anti-aliased.

The problem is that I want to use a bones system, which will be written after I would know how to draw the stickman itself based on the joints positions. This means I can't use sprites - I want my stickman to be fully controlable in the code.

It would be great if it will be possible to draw curves too.

Drawing a 3D stickman using a model would also be great if not better. The camera will be positioned like it's 2D, but I would still have depth. The problem is that I only have experience in Maya, and exporting and vertex weighting of the model in OpenGL seems like a mess...

I tried to find libraries for 2D anti-aliased drawing or enable multi-sampling and draw normally, but I had no luck. I also tried to use OpenGL's native anti-aliasing but it seems deprecated and the line joins are bad...

I don't want it to be too complicated because, well, it shouldn't be - it's just the first part of my program, and it's drawing a stickman...

I hope you guys can help me, I'm sure you know better than me :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给不了的爱 2024-11-10 21:35:54

您可以启用 GL_SMOOTH。要检查您的设备是否支持平滑线条所需的线宽,可以使用 glGet(GL_SMOOTH_LINE_WIDTH_RANGE);

如果您希望代码是通用的,您还可以使用抗锯齿纹理。
看看这个链接

http://www.opengl .org/resources/code/samples/advanced/advanced97/notes/node62.html

You could enable GL_SMOOTH. To check if you device supports your required line width for smooth lines, you can use glGet(GL_SMOOTH_LINE_WIDTH_RANGE);

If you want your code to be generic, you can also use antialiased textures.
Take a look at this link

http://www.opengl.org/resources/code/samples/advanced/advanced97/notes/node62.html

丢了幸福的猪 2024-11-10 21:35:54

获得抗锯齿的唯一方法是使用 GL 库,它知道如何获取抗锯齿 GL 上下文,对于 示例,SDL。对于火柴人来说,你可以用彩色多边形来绘制他。

The only way to get antialiasing is use GL library which knows how to get antialiased GL context, for example, SDL. As of stickman, you can draw him with colored polygons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文