Hi,
I have got a structure and in it a pointer to a 2D array. But when I try to assign an actual 2D array to that pointer I do not succeed - compiler says that my pointer is a pointer to a 1D array.
Here's my code:
typedef GLfloat Vertex2f[2];
typedef GLfloat TextureCoordinate[2];
typedef struct {
GLuint texture_name; // OpenGL ID of texture used for this sprite
Vertex2f *vertices; // array of vertices
TextureCoordinate *texture_coords; // texture vertices to match
GLubyte *vertex_indices;
} game_sprite;
void loadState()
{
game_sprite ballSprite;
createAndLoadTexture("ball.png", &ballSprite.texture_name);
const Vertex2f tempVerticesArray[4] = {
{-100.0f, -100.0f},
{-100.0f, 100.0f},
{100.0f, 100.0f},
{100.0f, -100.0f}
};
ballSprite.vertices = &tempVerticesArray; //The problem appears to be here
}
How can I make it work?
Thanks.