OpenGL ES creating a 2D mesh - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Graphics & Audio Programming (/forum-9.html) +--- Thread: OpenGL ES creating a 2D mesh (/thread-1271.html) OpenGL ES creating a 2D mesh - soulstorm - May 20, 2009 02:37 AM Using OpenGL ES, I am trying to create a mesh that takes up the entire screen. My intention is to apply a texture to it and then distort it. My screen is 480x320 in size. Here is what I have done: Code: ```#define kWindowWidth 480 #define kWindowHeight 360 #define kHorisontalDivisions 30 #define kVerticalDivisions 10 GLfloat pictureMeshVertices[kHorisontalDivisions][kVerticalDivisions][3]; GLfloat pictureMeshVerticesUnified[kHorisontalDivisions*kVerticalDivisions*3];``` Code: ```- (void)populateMesh {     int x;     int y;     int completedTriangles;          float height = kWindowHeight/kVerticalDivisions;     float width = kWindowWidth/kHorisontalDivisions;          NSLog(@"width: %f, height: %f", width, height);          for (y=0; y < kVerticalDivisions; y++) {         for (x=0, completedTriangles=0; x < kHorisontalDivisions-1; x++, completedTriangles+=2) {             pictureMeshVertices[completedTriangles][y][0] = (float)(x * width) + 0.0f;             pictureMeshVertices[completedTriangles][y][1] = (float)(y * height) + height;             pictureMeshVertices[completedTriangles][y][2] = 0.0f;                          pictureMeshVertices[completedTriangles+1][y][0] = (float) (x * width) + 0.0f;             pictureMeshVertices[completedTriangles+1][y][1] = (float) ((y * height) + 0.0f);             pictureMeshVertices[completedTriangles+1][y][2] = (float) 0.0f;                          NSLog(@"filling Line %i, %i: %f, %f, %f",completedTriangles, y,  pictureMeshVertices[completedTriangles][y][0], pictureMeshVertices[completedTriangles][y][1], pictureMeshVertices[completedTriangles][y][2] );             NSLog(@"filling Line %i, %i: %f, %f, %f", completedTriangles+1, y,pictureMeshVertices[completedTriangles+1][y][0], pictureMeshVertices[completedTriangles+1][y][1], pictureMeshVertices[completedTriangles+1][y][2] );                      }     }          int i;     int j;     int k;     int count = 0;     for (j=0; j