 Timestamp:
 Jun 27, 2010, 11:15:55 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/testmap.cpp
r14 r16 50 50 { 51 51 glGenBuffers(3, buflist); 52 53 float vertices[8 * 20 * 15];54 for (int y = 0; y < 15; y++)55 for (int x = 0; x < 20; x++)56 {57 vertices[8 * (20 * y + x) + 0] = x * 32;58 vertices[8 * (20 * y + x) + 1] = y * 32;59 vertices[8 * (20 * y + x) + 2] = x * 32 + 32;60 vertices[8 * (20 * y + x) + 3] = y * 32;61 vertices[8 * (20 * y + x) + 4] = x * 32 + 32;62 vertices[8 * (20 * y + x) + 5] = y * 32 + 32;63 vertices[8 * (20 * y + x) + 6] = x * 32;64 vertices[8 * (20 * y + x) + 7] = y * 32 + 32;65 }66 glBindBuffer(GL_ARRAY_BUFFER, buflist[0]);67 glBufferData(GL_ARRAY_BUFFER,68 8 * 20 * 15 * sizeof(float), vertices, GL_STATIC_DRAW);69 70 int indices[4 * 20 * 15];71 for (int n = 0; n < 4 * 20 * 15; n++)72 indices[n] = n;73 glBindBuffer(GL_ARRAY_BUFFER, buflist[2]);74 glBufferData(GL_ARRAY_BUFFER,75 4 * 20 * 15 * sizeof(int), indices, GL_STATIC_DRAW);76 52 } 77 53 … … 125 101 8 * 20 * 15 * sizeof(float), uvs, GL_STATIC_DRAW); 126 102 103 float vertices[8 * 20 * 15]; 104 for (int y = 0; y < 15; y++) 105 for (int x = 0; x < 20; x++) 106 { 107 vertices[8 * (20 * y + x) + 0] = x * 32; 108 vertices[8 * (20 * y + x) + 1] = y * 32; 109 vertices[8 * (20 * y + x) + 2] = x * 32 + 32; 110 vertices[8 * (20 * y + x) + 3] = y * 32; 111 vertices[8 * (20 * y + x) + 4] = x * 32 + 32; 112 vertices[8 * (20 * y + x) + 5] = y * 32 + 32; 113 vertices[8 * (20 * y + x) + 6] = x * 32; 114 vertices[8 * (20 * y + x) + 7] = y * 32 + 32; 115 } 116 glBindBuffer(GL_ARRAY_BUFFER, buflist[0]); 117 glBufferData(GL_ARRAY_BUFFER, 118 8 * 20 * 15 * sizeof(float), vertices, GL_STATIC_DRAW); 119 120 int indices[4 * 20 * 15]; 121 for (int n = 0; n < 4 * 20 * 15; n++) 122 indices[n] = n; 123 glBindBuffer(GL_ARRAY_BUFFER, buflist[2]); 124 glBufferData(GL_ARRAY_BUFFER, 125 4 * 20 * 15 * sizeof(int), indices, GL_STATIC_DRAW); 126 127 127 glEnableClientState(GL_VERTEX_ARRAY); 128 128 glEnableClientState(GL_TEXTURE_COORD_ARRAY); … … 198 198 int main(int argc, char **argv) 199 199 { 200 SDL_Surface *video; 200 201 int done; 201 202 … … 208 209 209 210 /* Create a 640x480 OpenGL screen */ 210 if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) 211 video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL); 212 if (!video) 211 213 { 212 214 fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError()); … … 236 238 done = 1; 237 239 if (event.type == SDL_KEYDOWN) 238 if (event.key.keysym.sym == SDLK_ESCAPE) 240 { 241 if (event.key.keysym.sym == SDLK_RETURN) 242 SDL_WM_ToggleFullScreen(video); 243 else if (event.key.keysym.sym == SDLK_ESCAPE) 239 244 done = 1; 245 } 240 246 } 241 247
Note: See TracChangeset
for help on using the changeset viewer.