equal
deleted
inserted
replaced
99 } |
99 } |
100 } |
100 } |
101 } |
101 } |
102 |
102 |
103 void Terrain::generatePixelBuffer (void) { |
103 void Terrain::generatePixelBuffer (void) { |
|
104 |
|
105 #if GRAPHICS_ENABLED |
104 // initialize textures |
106 // initialize textures |
105 generateTexture(); |
107 generateTexture(); |
106 |
108 |
107 // create the pixel buffer of the correct size |
109 // create the pixel buffer of the correct size |
108 pixbuf = CL_PixelBuffer(width, height, 4 * width, CL_PixelFormat::rgba8888); |
110 pixbuf = CL_PixelBuffer(width, height, 4 * width, CL_PixelFormat::rgba8888); |
112 for (PixelDimension y = 0; y < height; y++) { |
114 for (PixelDimension y = 0; y < height; y++) { |
113 // draw textureized pixel color |
115 // draw textureized pixel color |
114 pixbuf.draw_pixel(x, y, getTexturePixel(x, y)); |
116 pixbuf.draw_pixel(x, y, getTexturePixel(x, y)); |
115 } |
117 } |
116 } |
118 } |
|
119 |
|
120 #else |
|
121 // no-op |
|
122 |
|
123 #endif |
|
124 |
117 } |
125 } |
118 |
126 |
119 /* |
127 /* |
120 * Texture generation utility functions |
128 * Texture generation utility functions |
121 */ |
129 */ |
408 } |
416 } |
409 |
417 |
410 return normal; |
418 return normal; |
411 } |
419 } |
412 |
420 |
|
421 #if GRAPHICS_ENABLED |
413 void Terrain::draw (graphics::Display &display, PixelCoordinate camera) { |
422 void Terrain::draw (graphics::Display &display, PixelCoordinate camera) { |
414 // XXX: can we optimize this somehow? |
423 // XXX: can we optimize this somehow? |
415 |
424 |
416 // load the terrain pixbuf as a surface |
425 // load the terrain pixbuf as a surface |
417 CL_Surface surf (pixbuf); |
426 CL_Surface surf (pixbuf); |
418 |
427 |
419 // draw it onto the graphics, offset by camera position |
428 // draw it onto the graphics, offset by camera position |
420 surf.draw(-camera.x, -camera.y, display.get_gc()); |
429 surf.draw(-camera.x, -camera.y, display.get_gc()); |
421 } |
430 } |
422 |
431 #endif |
|
432 |