我正在训练用 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) 是否有可能投出std::vector<std::shared_ptr<Object>>
到std::vector<std::shared_ptr<SpecializedObject>>
那里SpecializedObject
继承Object
,无需建立一个新的数组(或通过矢量迭代)?