小编Tal*_*eed的帖子

未声明的标识符“gl_Position”

我正在训练用 cpp 做 opengl 的东西,但我的程序中有一个错误:/(vertexShader)

这是 vertexShader 的代码:

void main(void)
{
    gl_Position = gl_Vertex; 
}
Run Code Online (Sandbox Code Playgroud)

这里有调用着色器的主 cpp 文件:

#include <GL/glew.h>
#include <GL/freeglut.h>
#include <stdio.h>

static char* readFile(const char* filename) {
    // Open the file
    FILE* fp = fopen(filename, "rb");
    // Move the file pointer to the end of the file and determing the length
    fseek(fp, 0, SEEK_END);
    long file_length = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    char* contents = new char[file_length + 1];
    // zero out memory
    for (int i = 0; …
Run Code Online (Sandbox Code Playgroud)

c++ opengl shader

5
推荐指数
1
解决办法
6230
查看次数

投射整个矢量

是否有可能投出std::vector<std::shared_ptr<Object>>std::vector<std::shared_ptr<SpecializedObject>>那里SpecializedObject继承Object,无需建立一个新的数组(或通过矢量迭代)?

c++ polymorphism vector static-cast reinterpret-cast

4
推荐指数
1
解决办法
624
查看次数