最近、C/C++ でプログラミングを始めましたが、特定のことを理解するのが少し難しいと感じています。たとえば、私の vertices.h ファイル:
#ifndef _vertices_h
#define _vertices_h
typedef struct
{
float XYZW[4];
float RGBA[4];
} Vertex;
extern Vertex Vertices[];
extern GLubyte Indices[];
#endif
そして私の vertices.c ファイル:
#include "vertices.h"
Vertex Vertices[] =
{
{ { 0.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f, 1.0f } }
};
GLubyte Indices[] = {
0, 1, 3,
0, 3, 2,
3, 1, 4,
3, 4, 2
};
いいえ、Vertices 配列を使用する他の .h ファイルに関数を作成する必要があります。以下は shader.c ファイルです。
#include "vertices.h"
void CreateVBO(){ #############################################1
// some operations that uses the passed Vertices array
}
そして私の「shaders.h」ファイル:
#ifndef _shaders_h
#define _shaders_h
void CreateVBO(); #############################################################2
#endif
私の質問は、メイン関数で CreateVBO 関数を呼び出し、必要な Vertices Array を渡したいということです。私の場合、宣言したのは 1 だけですが、もっと宣言して、必要なものを渡したいと思います。したがって、基本的に、CreateVBO関数の引数を宣言する方法が本当にわかりません。行方不明の行は #### で署名されています。
void doSemthing(int argc, char* argv[]){
...
CreateVBO(); #############################################################3
}