Cg 和 OpenGL 3

发布于 2024-09-18 10:57:51 字数 435 浏览 1 评论 0原文

我目前正在学习 OpenGL 2 和 3 之间的差异,我注意到许多函数,例如 glVertexglVertexPointerglColorglColorPointer等都消失了。

我习惯使用Cg来处理着色器。例如,我会编写这个简单的顶点着色器:

void main(in inPos : POSITION, out outPos : POSITION) {
    outPos = inPos;
}

然后我会使用 glVertexglVertexPointer 来设置 inPos 的值。

但由于 OpenGL 3 中不再提供这些函数,您应该如何进行绑定呢?

I'm currently learning the differences between OpenGL 2 and 3, and I noticed that many functions like glVertex, glVertexPointer, glColor, glColorPointer, etc. have disappeared.

I'm used to using Cg to handle shaders. For example I'd write this simple vertex shader:

void main(in inPos : POSITION, out outPos : POSITION) {
    outPos = inPos;
}

And then I'd use either glVertex or glVertexPointer to set the values of inPos.

But since these functions are no longer available in OpenGL 3, how are you supposed to do the bindings?

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

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

发布评论

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

评论(1

嘴硬脾气大 2024-09-25 10:57:52

首先,我建议您查看的答案这个问题:OpenGL 3.x 有什么不同?

其次,Norbert Nopper 有很多关于使用 OpenGL 3 和 GLSL 的示例 这里

最后,这是一个简单的 GLSL 示例,它向您展示了如何绑定顶点着色器程序和片段着色器程序。

First I'll recommend you to take a look at the answer to this question: What's so different about OpenGL 3.x?

Secondly, Norbert Nopper has lots of examples on using OpenGL 3 and GLSL here

Finally here's a simple GLSL example which shows you how to bind both a vertex and a fragment shader program.

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