J'ai une structure et un pointeur vers un tableau 2D. Mais quand j'essaye d'assigner un tableau 2D réel à ce pointeur je ne réussis pas - le compilateur dit que mon pointeur est un pointeur vers un tableau 1D.Modification d'un pointeur sur un tableau en C
Voici mon 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
}
Comment puis-je le faire fonctionner?
Merci.
+1 pour plus de clarté ........ –