如何从头开始创建实时渲染窗口?

发布于 2024-12-28 18:55:01 字数 290 浏览 2 评论 0原文

我自己研究 3D 图形已经有一段时间了,我想更好地了解一切是如何工作的。我想做的是创建一个简单的游戏,而不使用 DirectX 或 OpenGL。我理解我相信的大部分数学,但我遇到的问题是我不知道如何控制窗口中显示的像素。

如何指定窗口中每个像素的颜色?

我知道我可能会遇到缓冲区和图像剪切方面的问题,以及可能会遇到可怕的效率问题,但我想创建自己的程序,以便我可以从高级语言的最低级别了解渲染过程的工作原理。我真的不知道从哪里开始。我已经弄清楚如何输出 BMP,但我希望有一个正在运行的程序每秒输出 20+ 帧。我该如何实现这个目标?

I've been studying 3D graphics on my own for a while now and I want to get a greater understanding of just how everything works. What I would like to do is to create a simple game without using DirectX or OpenGL. I understand most of the math I believe, but the problem I am running up against is I do not know how to get control of the pixels being displayed in a window.

How do I specify what color I want each pixel in my window to be?

I understand I will probably run into issues with buffers and image shearing and probably terrible efficiency problems, but I want to create my own program so that I could see from the very lowest level, of the high level language, how the rendering process works. I really have no idea where to start though. I've figured out how to output BMPs, but I would like to have a running program spitting out 20+ frames per second. How do I accomplish this?

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

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

发布评论

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

评论(3

不喜欢何必死缠烂打 2025-01-04 18:55:01

您可以选择一个允许您用像素值填充数组并将其显示为位图的环境。这样你就最接近在视频内存中读取 RGB 值了。 WPF、Silverlight、HTML5/Javascript 都可以做到这一点。如果您不使其全屏显示,这些技术目前应该足够了。

在 WPF 和Silverlight,使用 WriteableBitmap。

在HTML5,使用画布

然后由您来实现绘制直线、圆形、贝塞尔曲线、3D 投影的逻辑。

这很有趣,你会学到很多东西。

You could pick a environment that allows you to fill an array with values for pixels and display it as a bitmap. This way you come closest to poking RGB values in video memory. WPF, Silverlight, HTML5/Javascript can do this. If you do not make it full screen these technologies should suffice for now.

In WPF and Silverlight, use the WriteableBitmap.

In HTML5, use the canvas

Then it is up to you to implement the logic to draw lines, circles, bezier curves, 3D projections.

This is a lot of fun and you will learn a lot.

美胚控场 2025-01-04 18:55:01

我从字里行间看出,您更感兴趣的是从低级别完全控制渲染过程,而不是对如何在一个特定平台上实现这一目标有特定的兴趣。

如果是这样的话,那么您可能会得到一个很好的回报,比如 SDL ,它为您提供了可以直接渲染的帧缓冲区,但可以抽象出许多平台特定问题。它已经存在很长一段时间了,并且有一些很好的教程可以让您了解它是否是您正在寻找的东西 - 请参阅 本教程 以及同一系列中的后续教程,这应该足以让您入门并运行。

I'm reading between the lines that you're more interested in having full control over the rendering process from a low level, rather than having a specific interest in how to achieve that on one specific platform.

If that's the case then you will probably get a good bang for your buck looking at a library like SDL which provides you with a frame buffer that you can render to directly but abstracts away a lot of the platform specifics issues. It has been around for quite a while and there are some good tutorials to give you an idea of whether it's the kind of thing you're looking for - see this tutorial and the subsequent one in the same series, which should be enough to get you up and running.

时光沙漏 2025-01-04 18:55:01

您说您想创建某种渲染引擎,这意味着设计您自己的管道和矩阵类。您将使用它来将 3D 坐标转换为 2D 点。

当您获得一直在寻找的 2D 点时。例如,您可以在窗口上使用,您可以选择画笔并绘制三角形值,同时为它们着色。

我不知道为什么你需要位图,但如果你想练习说纹理,你也可以自己做,尽管当然在一台较弱的计算机上这可能会显着降低你的每秒帧数。

如果您的目标是了解渲染在最低级别上的工作原理。这无疑是一个很好的做法。

Jt施温施维加

You say you want to create some kind of a rendering engine, meaning desinging you own Pipeline and matrice classes. Which you are to use to transform 3D coordinates to 2D points.

When you have got the 2D points you've been looking for. You can use say for instance on windows, you can select a brush and draw you triangle values while coloring them at the same time.

I do not know why you would need Bitmaps, but if you want to practice say Texturing you can also do that yourself although off course on a weak computer this might take your frames per second significantly.

If you aim is to understand how rendering works on the lowest level. This is with no doubt a good practice.

Jt Schwinschwiga

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