在 OpenGL 中绘制一个简单的抗锯齿火柴人
我想在屏幕上画一个简单的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以启用 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
获得抗锯齿的唯一方法是使用 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.