C++ Passing arguments to a function -


recently started program in c/c++, find little bit hard understand things. example, vertices.h file:

#ifndef _vertices_h #define _vertices_h  typedef struct {     float xyzw[4];     float rgba[4]; } vertex;  extern vertex vertices[]; extern glubyte indices[];  #endif 

and vertices.c file:

#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  }; 

not, need create function in other .h file use vertices array. here shader.c file:

#include "vertices.h"  void createvbo(){ #############################################1 // operations uses passed vertices array } 

and "shaders.h" file:

#ifndef _shaders_h #define _shaders_h  void createvbo(); #############################################################2  #endif 

now question is, in main function call function createvbo, , want pass vertices array need. in case, i'v declared 1, want declare more , pass in 1 want. basically, dont know how declare arguments of function createvbo. lines i'm missing signed ####.

void dosemthing(int argc, char* argv[]){ ... createvbo(); #############################################################3 } 

vertices[] global , don't need pass through parameter. can pass vertices too.

make function below

void createvbo(vertex vertices[]); 

call it

createvbo(vertices); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -