| 1 |
#include <ClanLib/application.h> |
| 2 |
#include <ClanLib/core.h> |
| 3 |
#include <ClanLib/display.h> |
| 4 |
#include <ClanLib/gl.h> |
| 5 |
|
| 6 |
#include <fstream> |
| 7 |
#include "time.h" |
| 8 |
|
| 9 |
///////////////////////////////////////////////////////////////////////////// |
| 10 |
// Application class |
| 11 |
|
| 12 |
class Application : public CL_ClanApplication |
| 13 |
{ |
| 14 |
public: |
| 15 |
int main(int argc, char** argv); |
| 16 |
|
| 17 |
void init_log(int loops); |
| 18 |
void log(const std::string &channel, const std::string &message); |
| 19 |
|
| 20 |
int small_gradient_nooverdraw(CL_DisplayWindow &window, int loops); |
| 21 |
int small_gradient_overdraw(CL_DisplayWindow &window, int loops); |
| 22 |
int big_gradient_noalpha(CL_DisplayWindow &window, int loops); |
| 23 |
int big_gradient_alpha(CL_DisplayWindow &window, int loops); |
| 24 |
int lines_and_rects(CL_DisplayWindow &window, int loops); |
| 25 |
int surface_large(CL_DisplayWindow &window, int loops); |
| 26 |
int surface_small(CL_DisplayWindow &window, int loops); |
| 27 |
int surface_small_and_large(CL_DisplayWindow &window, int loops); |
| 28 |
int sprite(CL_DisplayWindow &window, int loops); |
| 29 |
int sprite_multiple(CL_DisplayWindow &window, int loops); |
| 30 |
int font(CL_DisplayWindow &window, int loops); |
| 31 |
int complex1(CL_DisplayWindow &window, int loops); |
| 32 |
int pixelbuffer_tga_load(CL_DisplayWindow &window, int loops); |
| 33 |
int pixelbuffer_png_load(CL_DisplayWindow &window, int loops); |
| 34 |
int pixelbuffer_jpg_load(CL_DisplayWindow &window, int loops); |
| 35 |
int surface_tga_load(CL_DisplayWindow &window, int loops); |
| 36 |
int surface_png_load(CL_DisplayWindow &window, int loops); |
| 37 |
int surface_jpg_load(CL_DisplayWindow &window, int loops); |
| 38 |
int sprite_load(CL_DisplayWindow &window, int loops); |
| 39 |
int font_load(CL_DisplayWindow &window, int loops); |
| 40 |
} app; |
| 41 |
|
| 42 |
///////////////////////////////////////////////////////////////////////////// |
| 43 |
// Application main entry point: |
| 44 |
|
| 45 |
int Application::main(int argc, char** argv) |
| 46 |
{ |
| 47 |
CL_ConsoleWindow debug_console("Debug console"); |
| 48 |
debug_console.redirect_stdio(); |
| 49 |
|
| 50 |
try |
| 51 |
{ |
| 52 |
CL_SetupCore::init(); |
| 53 |
CL_SetupDisplay::init(); |
| 54 |
CL_SetupGL::init(); |
| 55 |
|
| 56 |
int loops = 500; |
| 57 |
|
| 58 |
CL_DisplayWindow window("ClanLib Benchmark", 1024, 768, false, true); |
| 59 |
|
| 60 |
init_log(loops); |
| 61 |
|
| 62 |
std::map<std::string, int> results[2]; |
| 63 |
std::map<std::string, int>::iterator it; |
| 64 |
|
| 65 |
results[0]["1-01a. Small gradient - no overdraw"] = small_gradient_nooverdraw(window, loops); |
| 66 |
results[0]["1-01b. Small gradient - overdraw"] = small_gradient_overdraw(window, loops); |
| 67 |
results[0]["1-02a. Big gradient - no alpha"] = big_gradient_noalpha(window, loops); |
| 68 |
results[0]["1-02b. Big gradient - alpha"] = big_gradient_alpha(window, loops); |
| 69 |
results[0]["1-03a. Lines and rects"] = lines_and_rects(window, loops); |
| 70 |
results[0]["1-04a. Surface small"] = surface_small(window, loops); |
| 71 |
results[0]["1-04b. Surface large"] = surface_large(window, loops); |
| 72 |
results[0]["1-04c. Surface small & large"] = surface_small_and_large(window, loops); |
| 73 |
results[0]["1-05a. Single sprite"] = sprite(window, loops); |
| 74 |
results[0]["1-05b. Multiple sprites"] = sprite_multiple(window, loops); |
| 75 |
results[0]["1-06a. Font"] = font(window, loops); |
| 76 |
results[0]["1-07a. Lines, Surfaces, Sprites and Fonts"] = complex1(window, loops); |
| 77 |
|
| 78 |
int total1 = 0; |
| 79 |
for(it = results[0].begin(); it != results[0].end(); ++it) |
| 80 |
{ |
| 81 |
log((*it).first, CL_String::from_int((*it).second)); |
| 82 |
total1 += (*it).second; |
| 83 |
} |
| 84 |
log("SCORE DRAWING", CL_String::from_int(total1)); |
| 85 |
|
| 86 |
results[1]["2-01a. Pixelbuffer tga loading"] = pixelbuffer_tga_load(window, loops); |
| 87 |
results[1]["2-01b. Pixelbuffer png loading"] = pixelbuffer_png_load(window, loops); |
| 88 |
results[1]["2-01c. Pixelbuffer jpg loading"] = pixelbuffer_jpg_load(window, loops); |
| 89 |
results[1]["2-02a. Surface tga creation"] = surface_tga_load(window, loops); |
| 90 |
results[1]["2-02b. Surface png creation"] = surface_png_load(window, loops); |
| 91 |
results[1]["2-02c. Surface jpg creation"] = surface_jpg_load(window, loops); |
| 92 |
results[1]["2-03a. Sprite creation"] = sprite_load(window, loops); |
| 93 |
results[1]["2-04a. Font creation"] = font_load(window, loops); |
| 94 |
|
| 95 |
int total2 = 0; |
| 96 |
for(it = results[1].begin(); it != results[1].end(); ++it) |
| 97 |
{ |
| 98 |
log((*it).first, CL_String::from_int((*it).second)); |
| 99 |
total2 += (*it).second; |
| 100 |
} |
| 101 |
log("SCORE LOADING", CL_String::from_int(total2)); |
| 102 |
|
| 103 |
log("SCORE TOTAL", CL_String::from_int(total1 + total2)); |
| 104 |
|
| 105 |
CL_SetupGL::deinit(); |
| 106 |
CL_SetupDisplay::deinit(); |
| 107 |
CL_SetupCore::deinit(); |
| 108 |
} |
| 109 |
catch (CL_Error error) |
| 110 |
{ |
| 111 |
std::cout << "Uncaught error: " << error.message.c_str() << std::endl; |
| 112 |
} |
| 113 |
|
| 114 |
debug_console.display_close_message(); |
| 115 |
|
| 116 |
return 0; |
| 117 |
} |
| 118 |
|
| 119 |
void Application::init_log(int loops) |
| 120 |
{ |
| 121 |
std::ofstream file; |
| 122 |
file.open("benchmark_results.txt", std::ios::out | std::ios::app); |
| 123 |
|
| 124 |
time_t t = time(NULL); |
| 125 |
file << std::endl << "Benchmark v0.4 - " << loops << " loops" << std::endl; |
| 126 |
file << "ClanLib v" << CL_VERSION_STRING << std::endl; |
| 127 |
file << ctime(&t); |
| 128 |
} |
| 129 |
|
| 130 |
void Application::log(const std::string &channel, const std::string &message) |
| 131 |
{ |
| 132 |
std::ofstream file; |
| 133 |
file.open("benchmark_results.txt", std::ios::out | std::ios::app); |
| 134 |
|
| 135 |
std::string log = CL_String::format("%1: %2", channel, message); |
| 136 |
|
| 137 |
file << log << std::endl; |
| 138 |
std::cout << log << std::endl; |
| 139 |
|
| 140 |
file.close(); |
| 141 |
} |
| 142 |
|
| 143 |
int Application::small_gradient_nooverdraw(CL_DisplayWindow &window, int loops) |
| 144 |
{ |
| 145 |
CL_GraphicContext *gc = window.get_gc(); |
| 146 |
int start_time = CL_System::get_time(); |
| 147 |
|
| 148 |
int frames = 0; |
| 149 |
while (frames < loops) |
| 150 |
{ |
| 151 |
gc->clear(); |
| 152 |
|
| 153 |
for(int y=0; y<70; ++y) |
| 154 |
for(int x=0; x<100; ++x) |
| 155 |
gc->fill_rect( |
| 156 |
CL_Rect(x * 10, y * 10, x * 10 + 10, y * 10 + 10), |
| 157 |
CL_Gradient(CL_Color::white, CL_Color::green, CL_Color::red, CL_Color::blue)); |
| 158 |
|
| 159 |
window.flip(); |
| 160 |
CL_System::keep_alive(); |
| 161 |
|
| 162 |
frames++; |
| 163 |
} |
| 164 |
|
| 165 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 166 |
} |
| 167 |
|
| 168 |
int Application::small_gradient_overdraw(CL_DisplayWindow &window, int loops) |
| 169 |
{ |
| 170 |
CL_GraphicContext *gc = window.get_gc(); |
| 171 |
int start_time = CL_System::get_time(); |
| 172 |
|
| 173 |
int frames = 0; |
| 174 |
while (frames < loops) |
| 175 |
{ |
| 176 |
gc->clear(); |
| 177 |
|
| 178 |
for(int i=0; i<300; ++i) |
| 179 |
for(int y=0; y<7; ++y) |
| 180 |
for(int x=0; x<10; ++x) |
| 181 |
gc->fill_rect( |
| 182 |
CL_Rect(x * 10, y * 10, x * 10 + 10, y * 10 + 10), |
| 183 |
CL_Gradient(CL_Color::white, CL_Color::green, CL_Color::red, CL_Color::blue)); |
| 184 |
|
| 185 |
window.flip(); |
| 186 |
CL_System::keep_alive(); |
| 187 |
|
| 188 |
frames++; |
| 189 |
} |
| 190 |
|
| 191 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 192 |
} |
| 193 |
|
| 194 |
int Application::big_gradient_noalpha(CL_DisplayWindow &window, int loops) |
| 195 |
{ |
| 196 |
CL_GraphicContext *gc = window.get_gc(); |
| 197 |
int start_time = CL_System::get_time(); |
| 198 |
|
| 199 |
int frames = 0; |
| 200 |
while (frames < loops) |
| 201 |
{ |
| 202 |
gc->clear(); |
| 203 |
|
| 204 |
for(int i=0; i<10; i++) |
| 205 |
for(int y=0; y<7; ++y) |
| 206 |
for(int x=0; x<10; ++x) |
| 207 |
gc->fill_rect( |
| 208 |
CL_Rect(x * 100, y * 100, x * 100 + 100, y * 100 + 100), |
| 209 |
CL_Gradient(CL_Color::white, CL_Color::green, CL_Color::red, CL_Color::blue)); |
| 210 |
|
| 211 |
window.flip(); |
| 212 |
CL_System::keep_alive(); |
| 213 |
|
| 214 |
frames++; |
| 215 |
} |
| 216 |
|
| 217 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 218 |
} |
| 219 |
|
| 220 |
int Application::big_gradient_alpha(CL_DisplayWindow &window, int loops) |
| 221 |
{ |
| 222 |
CL_GraphicContext *gc = window.get_gc(); |
| 223 |
int start_time = CL_System::get_time(); |
| 224 |
|
| 225 |
int frames = 0; |
| 226 |
while (frames < loops) |
| 227 |
{ |
| 228 |
gc->clear(); |
| 229 |
|
| 230 |
for(int i=0; i<10; i++) |
| 231 |
for(int y=0; y<7; ++y) |
| 232 |
for(int x=0; x<10; ++x) |
| 233 |
gc->fill_rect( |
| 234 |
CL_Rect(x * 100, y * 100, x * 100 + 100, y * 100 + 100), |
| 235 |
CL_Gradient(CL_Color(255,255,255,100), CL_Color(0,255,0,100), CL_Color(255,0,0,100), CL_Color(0,0,255,100))); |
| 236 |
|
| 237 |
window.flip(); |
| 238 |
CL_System::keep_alive(); |
| 239 |
|
| 240 |
frames++; |
| 241 |
} |
| 242 |
|
| 243 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 244 |
} |
| 245 |
|
| 246 |
int Application::lines_and_rects(CL_DisplayWindow &window, int loops) |
| 247 |
{ |
| 248 |
CL_GraphicContext *gc = window.get_gc(); |
| 249 |
int start_time = CL_System::get_time(); |
| 250 |
|
| 251 |
int frames = 0; |
| 252 |
while (frames < loops) |
| 253 |
{ |
| 254 |
gc->clear(); |
| 255 |
|
| 256 |
for(int y=0; y<700; y += 30) |
| 257 |
for(int x=0; x<1000; x += 30) |
| 258 |
{ |
| 259 |
gc->draw_line(0, 0, x, y, CL_Color(255, 255, 255)); |
| 260 |
gc->draw_rect(CL_Rect(0, 0, x, y), CL_Color(255, 0, 255)); |
| 261 |
} |
| 262 |
|
| 263 |
window.flip(); |
| 264 |
CL_System::keep_alive(); |
| 265 |
|
| 266 |
frames++; |
| 267 |
} |
| 268 |
|
| 269 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 270 |
} |
| 271 |
|
| 272 |
int Application::surface_large(CL_DisplayWindow &window, int loops) |
| 273 |
{ |
| 274 |
CL_GraphicContext *gc = window.get_gc(); |
| 275 |
|
| 276 |
CL_Surface surface("images/image1.tga"); |
| 277 |
surface.set_alpha(0.5f); |
| 278 |
|
| 279 |
int start_time = CL_System::get_time(); |
| 280 |
|
| 281 |
int frames = 0; |
| 282 |
while (frames < loops) |
| 283 |
{ |
| 284 |
gc->clear(); |
| 285 |
|
| 286 |
for(int y=0; y<700; y += 60) |
| 287 |
for(int x=0; x<1000; x += 60) |
| 288 |
surface.draw(x, y, gc); |
| 289 |
|
| 290 |
window.flip(); |
| 291 |
CL_System::keep_alive(); |
| 292 |
|
| 293 |
frames++; |
| 294 |
} |
| 295 |
|
| 296 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 297 |
} |
| 298 |
|
| 299 |
int Application::surface_small(CL_DisplayWindow &window, int loops) |
| 300 |
{ |
| 301 |
CL_GraphicContext *gc = window.get_gc(); |
| 302 |
|
| 303 |
CL_Surface surface("images/image2.tga"); |
| 304 |
|
| 305 |
int start_time = CL_System::get_time(); |
| 306 |
|
| 307 |
int frames = 0; |
| 308 |
while (frames < loops) |
| 309 |
{ |
| 310 |
gc->clear(); |
| 311 |
|
| 312 |
for(int y=0; y<700; y += 20) |
| 313 |
for(int x=0; x<1000; x += 20) |
| 314 |
surface.draw(x, y, gc); |
| 315 |
|
| 316 |
window.flip(); |
| 317 |
CL_System::keep_alive(); |
| 318 |
|
| 319 |
frames++; |
| 320 |
} |
| 321 |
|
| 322 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 323 |
} |
| 324 |
|
| 325 |
int Application::surface_small_and_large(CL_DisplayWindow &window, int loops) |
| 326 |
{ |
| 327 |
CL_GraphicContext *gc = window.get_gc(); |
| 328 |
|
| 329 |
CL_Surface surface1("images/image1.tga"); |
| 330 |
CL_Surface surface2("images/image2.tga"); |
| 331 |
|
| 332 |
int start_time = CL_System::get_time(); |
| 333 |
|
| 334 |
int frames = 0; |
| 335 |
while (frames < loops) |
| 336 |
{ |
| 337 |
gc->clear(); |
| 338 |
|
| 339 |
for(int y=0; y<700; y += 80) |
| 340 |
for(int x=0; x<1000; x += 80) |
| 341 |
{ |
| 342 |
surface1.draw(x, y, gc); |
| 343 |
surface2.draw(x, y, gc); |
| 344 |
} |
| 345 |
|
| 346 |
window.flip(); |
| 347 |
CL_System::keep_alive(); |
| 348 |
|
| 349 |
frames++; |
| 350 |
} |
| 351 |
|
| 352 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 353 |
} |
| 354 |
|
| 355 |
int Application::font(CL_DisplayWindow &window, int loops) |
| 356 |
{ |
| 357 |
CL_GraphicContext *gc = window.get_gc(); |
| 358 |
|
| 359 |
CL_SpriteDescription desc; |
| 360 |
desc.add_paletteclipped_frames( |
| 361 |
new CL_PCXProvider("images/clanfont.pcx"), 129, 209, true); |
| 362 |
|
| 363 |
CL_Sprite sprite(desc); |
| 364 |
CL_Font font( |
| 365 |
sprite, |
| 366 |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", |
| 367 |
10); |
| 368 |
font.set_alignment(origin_center); |
| 369 |
font.set_color(0.0f, 1.0f, 0.0f, 1.0f); |
| 370 |
|
| 371 |
int start_time = CL_System::get_time(); |
| 372 |
|
| 373 |
int frames = 0; |
| 374 |
while (frames < loops) |
| 375 |
{ |
| 376 |
gc->clear(); |
| 377 |
|
| 378 |
for(int y=0; y<700; y += 40) |
| 379 |
for(int x=0; x<1000; x += 40) |
| 380 |
font.draw(x, y, "Bitmap font", gc); |
| 381 |
|
| 382 |
window.flip(); |
| 383 |
CL_System::keep_alive(); |
| 384 |
|
| 385 |
frames++; |
| 386 |
} |
| 387 |
|
| 388 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 389 |
} |
| 390 |
|
| 391 |
int Application::sprite(CL_DisplayWindow &window, int loops) |
| 392 |
{ |
| 393 |
CL_GraphicContext *gc = window.get_gc(); |
| 394 |
|
| 395 |
CL_SpriteDescription desc; |
| 396 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0001.tga"), true); |
| 397 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0002.tga"), true); |
| 398 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0003.tga"), true); |
| 399 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0004.tga"), true); |
| 400 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0005.tga"), true); |
| 401 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0006.tga"), true); |
| 402 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0007.tga"), true); |
| 403 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0008.tga"), true); |
| 404 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0009.tga"), true); |
| 405 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0010.tga"), true); |
| 406 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0011.tga"), true); |
| 407 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0012.tga"), true); |
| 408 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0013.tga"), true); |
| 409 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0014.tga"), true); |
| 410 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0015.tga"), true); |
| 411 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0016.tga"), true); |
| 412 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0017.tga"), true); |
| 413 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0018.tga"), true); |
| 414 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0019.tga"), true); |
| 415 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0020.tga"), true); |
| 416 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0021.tga"), true); |
| 417 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0022.tga"), true); |
| 418 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0023.tga"), true); |
| 419 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0024.tga"), true); |
| 420 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0025.tga"), true); |
| 421 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0026.tga"), true); |
| 422 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0027.tga"), true); |
| 423 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0028.tga"), true); |
| 424 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0029.tga"), true); |
| 425 |
|
| 426 |
CL_Sprite sprite(desc); |
| 427 |
sprite.set_alignment(origin_center); |
| 428 |
|
| 429 |
int start_time = CL_System::get_time(); |
| 430 |
|
| 431 |
int frames = 0; |
| 432 |
while (frames < loops) |
| 433 |
{ |
| 434 |
gc->clear(); |
| 435 |
|
| 436 |
for(int y=0; y<700; y += 16) |
| 437 |
for(int x=0; x<1000; x += 16) |
| 438 |
sprite.draw(x, y, gc); |
| 439 |
|
| 440 |
sprite.update(); |
| 441 |
|
| 442 |
window.flip(); |
| 443 |
CL_System::keep_alive(); |
| 444 |
|
| 445 |
frames++; |
| 446 |
} |
| 447 |
|
| 448 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 449 |
} |
| 450 |
|
| 451 |
int Application::sprite_multiple(CL_DisplayWindow &window, int loops) |
| 452 |
{ |
| 453 |
CL_GraphicContext *gc = window.get_gc(); |
| 454 |
|
| 455 |
CL_SpriteDescription desc1; |
| 456 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0001.tga"), true); |
| 457 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0002.tga"), true); |
| 458 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0003.tga"), true); |
| 459 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0004.tga"), true); |
| 460 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0005.tga"), true); |
| 461 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0006.tga"), true); |
| 462 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0007.tga"), true); |
| 463 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0008.tga"), true); |
| 464 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0009.tga"), true); |
| 465 |
desc1.add_frame(new CL_TargaProvider("images/manwalk_0010.tga"), true); |
| 466 |
|
| 467 |
CL_SpriteDescription desc2; |
| 468 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0011.tga"), true); |
| 469 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0012.tga"), true); |
| 470 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0013.tga"), true); |
| 471 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0014.tga"), true); |
| 472 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0015.tga"), true); |
| 473 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0016.tga"), true); |
| 474 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0017.tga"), true); |
| 475 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0018.tga"), true); |
| 476 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0019.tga"), true); |
| 477 |
desc2.add_frame(new CL_TargaProvider("images/manwalk_0020.tga"), true); |
| 478 |
|
| 479 |
CL_SpriteDescription desc3; |
| 480 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0021.tga"), true); |
| 481 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0022.tga"), true); |
| 482 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0023.tga"), true); |
| 483 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0024.tga"), true); |
| 484 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0025.tga"), true); |
| 485 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0026.tga"), true); |
| 486 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0027.tga"), true); |
| 487 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0028.tga"), true); |
| 488 |
desc3.add_frame(new CL_TargaProvider("images/manwalk_0029.tga"), true); |
| 489 |
|
| 490 |
CL_Sprite sprite1(desc1); |
| 491 |
CL_Sprite sprite2(desc2); |
| 492 |
CL_Sprite sprite3(desc3); |
| 493 |
|
| 494 |
int start_time = CL_System::get_time(); |
| 495 |
|
| 496 |
int frames = 0; |
| 497 |
while (frames < loops) |
| 498 |
{ |
| 499 |
gc->clear(); |
| 500 |
|
| 501 |
for(int y=0; y<700; y += 32) |
| 502 |
{ |
| 503 |
for(int x=0; x<1000; x += 32) |
| 504 |
{ |
| 505 |
sprite1.draw(x, y, gc); |
| 506 |
sprite2.draw(x + 10, y + 10, gc); |
| 507 |
sprite3.draw(x + 20, y + 20, gc); |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
sprite1.update(); |
| 512 |
sprite2.update(); |
| 513 |
sprite3.update(); |
| 514 |
|
| 515 |
window.flip(); |
| 516 |
CL_System::keep_alive(); |
| 517 |
|
| 518 |
frames++; |
| 519 |
} |
| 520 |
|
| 521 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 522 |
} |
| 523 |
|
| 524 |
int Application::complex1(CL_DisplayWindow &window, int loops) |
| 525 |
{ |
| 526 |
CL_GraphicContext *gc = window.get_gc(); |
| 527 |
|
| 528 |
CL_SpriteDescription desc; |
| 529 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0001.tga"), true); |
| 530 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0002.tga"), true); |
| 531 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0003.tga"), true); |
| 532 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0004.tga"), true); |
| 533 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0005.tga"), true); |
| 534 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0006.tga"), true); |
| 535 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0007.tga"), true); |
| 536 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0008.tga"), true); |
| 537 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0009.tga"), true); |
| 538 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0010.tga"), true); |
| 539 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0011.tga"), true); |
| 540 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0012.tga"), true); |
| 541 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0013.tga"), true); |
| 542 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0014.tga"), true); |
| 543 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0015.tga"), true); |
| 544 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0016.tga"), true); |
| 545 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0017.tga"), true); |
| 546 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0018.tga"), true); |
| 547 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0019.tga"), true); |
| 548 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0020.tga"), true); |
| 549 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0021.tga"), true); |
| 550 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0022.tga"), true); |
| 551 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0023.tga"), true); |
| 552 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0024.tga"), true); |
| 553 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0025.tga"), true); |
| 554 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0026.tga"), true); |
| 555 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0027.tga"), true); |
| 556 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0028.tga"), true); |
| 557 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0029.tga"), true); |
| 558 |
CL_Sprite sprite(desc); |
| 559 |
|
| 560 |
CL_SpriteDescription fontdesc; |
| 561 |
fontdesc.add_paletteclipped_frames( |
| 562 |
new CL_PCXProvider("images/clanfont.pcx"), 129, 209, true); |
| 563 |
CL_Sprite fontsprite(fontdesc); |
| 564 |
CL_Font font( |
| 565 |
fontsprite, |
| 566 |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", |
| 567 |
10); |
| 568 |
|
| 569 |
CL_Surface surface1("images/image1.tga"); |
| 570 |
CL_Surface surface2("images/image2.tga"); |
| 571 |
|
| 572 |
int start_time = CL_System::get_time(); |
| 573 |
|
| 574 |
int frames = 0; |
| 575 |
while (frames < loops) |
| 576 |
{ |
| 577 |
gc->clear(); |
| 578 |
|
| 579 |
for(int y=0; y<700; y += 150) |
| 580 |
{ |
| 581 |
for(int x=0; x<1000; x += 150) |
| 582 |
{ |
| 583 |
gc->draw_line(0, 0, x, y, CL_Color(255, 255, 255)); |
| 584 |
gc->draw_rect(CL_Rect(0, 0, x, y), CL_Color(255, 0, 255, 100)); |
| 585 |
gc->fill_rect(CL_Rect(0, 0, x, y), CL_Color(255, 0, 255, 100)); |
| 586 |
gc->fill_rect( |
| 587 |
CL_Rect(x, y, x + 10, y + 10), |
| 588 |
CL_Gradient(CL_Color::white, CL_Color::green, CL_Color::red, CL_Color::blue)); |
| 589 |
sprite.draw(x, y, gc); |
| 590 |
surface1.draw(x, y, gc); |
| 591 |
surface2.draw(x, y, gc); |
| 592 |
font.draw(x, y, "Complex", gc); |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
sprite.update(); |
| 597 |
|
| 598 |
window.flip(); |
| 599 |
CL_System::keep_alive(); |
| 600 |
|
| 601 |
frames++; |
| 602 |
} |
| 603 |
|
| 604 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 605 |
} |
| 606 |
|
| 607 |
int Application::pixelbuffer_jpg_load(CL_DisplayWindow &window, int loops) |
| 608 |
{ |
| 609 |
CL_GraphicContext *gc = window.get_gc(); |
| 610 |
|
| 611 |
int start_time = CL_System::get_time(); |
| 612 |
|
| 613 |
int frames = 0; |
| 614 |
while (frames < loops) |
| 615 |
{ |
| 616 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.jpg"); |
| 617 |
b->lock(); |
| 618 |
b->unlock(); |
| 619 |
|
| 620 |
delete b; |
| 621 |
frames++; |
| 622 |
} |
| 623 |
|
| 624 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 625 |
} |
| 626 |
|
| 627 |
int Application::pixelbuffer_tga_load(CL_DisplayWindow &window, int loops) |
| 628 |
{ |
| 629 |
CL_GraphicContext *gc = window.get_gc(); |
| 630 |
|
| 631 |
int start_time = CL_System::get_time(); |
| 632 |
|
| 633 |
int frames = 0; |
| 634 |
while (frames < loops / 5) |
| 635 |
{ |
| 636 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.tga"); |
| 637 |
b->lock(); |
| 638 |
b->unlock(); |
| 639 |
|
| 640 |
delete b; |
| 641 |
frames++; |
| 642 |
} |
| 643 |
|
| 644 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 645 |
} |
| 646 |
|
| 647 |
int Application::pixelbuffer_png_load(CL_DisplayWindow &window, int loops) |
| 648 |
{ |
| 649 |
CL_GraphicContext *gc = window.get_gc(); |
| 650 |
|
| 651 |
int start_time = CL_System::get_time(); |
| 652 |
|
| 653 |
int frames = 0; |
| 654 |
while (frames < loops / 5) |
| 655 |
{ |
| 656 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.png"); |
| 657 |
b->lock(); |
| 658 |
b->unlock(); |
| 659 |
|
| 660 |
delete b; |
| 661 |
frames++; |
| 662 |
} |
| 663 |
|
| 664 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 665 |
} |
| 666 |
|
| 667 |
int Application::surface_tga_load(CL_DisplayWindow &window, int loops) |
| 668 |
{ |
| 669 |
CL_GraphicContext *gc = window.get_gc(); |
| 670 |
|
| 671 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.tga"); |
| 672 |
|
| 673 |
int start_time = CL_System::get_time(); |
| 674 |
|
| 675 |
int frames = 0; |
| 676 |
while (frames < loops / 5) |
| 677 |
{ |
| 678 |
CL_Surface *surface = new CL_Surface(b); |
| 679 |
delete surface; |
| 680 |
frames++; |
| 681 |
} |
| 682 |
|
| 683 |
int end_time = CL_System::get_time(); |
| 684 |
|
| 685 |
delete b; |
| 686 |
|
| 687 |
return int(frames / ((end_time - start_time) / 1000.0f)); |
| 688 |
} |
| 689 |
|
| 690 |
int Application::surface_png_load(CL_DisplayWindow &window, int loops) |
| 691 |
{ |
| 692 |
CL_GraphicContext *gc = window.get_gc(); |
| 693 |
|
| 694 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.png"); |
| 695 |
|
| 696 |
int start_time = CL_System::get_time(); |
| 697 |
|
| 698 |
int frames = 0; |
| 699 |
while (frames < loops / 5) |
| 700 |
{ |
| 701 |
CL_Surface *surface = new CL_Surface(b); |
| 702 |
delete surface; |
| 703 |
frames++; |
| 704 |
} |
| 705 |
|
| 706 |
int end_time = CL_System::get_time(); |
| 707 |
|
| 708 |
delete b; |
| 709 |
|
| 710 |
return int(frames / ((end_time - start_time) / 1000.0f)); |
| 711 |
} |
| 712 |
|
| 713 |
int Application::surface_jpg_load(CL_DisplayWindow &window, int loops) |
| 714 |
{ |
| 715 |
CL_GraphicContext *gc = window.get_gc(); |
| 716 |
|
| 717 |
CL_PixelBuffer *b = CL_ProviderFactory::load("images/image1.jpg"); |
| 718 |
|
| 719 |
int start_time = CL_System::get_time(); |
| 720 |
|
| 721 |
int frames = 0; |
| 722 |
while (frames < loops / 5) |
| 723 |
{ |
| 724 |
CL_Surface *surface = new CL_Surface(b); |
| 725 |
delete surface; |
| 726 |
frames++; |
| 727 |
} |
| 728 |
|
| 729 |
int end_time = CL_System::get_time(); |
| 730 |
|
| 731 |
delete b; |
| 732 |
|
| 733 |
return int(frames / ((end_time - start_time) / 1000.0f)); |
| 734 |
} |
| 735 |
|
| 736 |
int Application::sprite_load(CL_DisplayWindow &window, int loops) |
| 737 |
{ |
| 738 |
CL_GraphicContext *gc = window.get_gc(); |
| 739 |
|
| 740 |
CL_SpriteDescription desc; |
| 741 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0001.tga"), true); |
| 742 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0002.tga"), true); |
| 743 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0003.tga"), true); |
| 744 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0004.tga"), true); |
| 745 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0005.tga"), true); |
| 746 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0006.tga"), true); |
| 747 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0007.tga"), true); |
| 748 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0008.tga"), true); |
| 749 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0009.tga"), true); |
| 750 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0010.tga"), true); |
| 751 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0011.tga"), true); |
| 752 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0012.tga"), true); |
| 753 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0013.tga"), true); |
| 754 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0014.tga"), true); |
| 755 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0015.tga"), true); |
| 756 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0016.tga"), true); |
| 757 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0017.tga"), true); |
| 758 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0018.tga"), true); |
| 759 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0019.tga"), true); |
| 760 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0020.tga"), true); |
| 761 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0021.tga"), true); |
| 762 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0022.tga"), true); |
| 763 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0023.tga"), true); |
| 764 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0024.tga"), true); |
| 765 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0025.tga"), true); |
| 766 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0026.tga"), true); |
| 767 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0027.tga"), true); |
| 768 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0028.tga"), true); |
| 769 |
desc.add_frame(new CL_TargaProvider("images/manwalk_0029.tga"), true); |
| 770 |
|
| 771 |
int start_time = CL_System::get_time(); |
| 772 |
|
| 773 |
int frames = 0; |
| 774 |
while (frames < loops / 5) |
| 775 |
{ |
| 776 |
CL_Sprite *sprite = new CL_Sprite(desc); |
| 777 |
delete sprite; |
| 778 |
frames++; |
| 779 |
} |
| 780 |
|
| 781 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 782 |
} |
| 783 |
|
| 784 |
int Application::font_load(CL_DisplayWindow &window, int loops) |
| 785 |
{ |
| 786 |
CL_GraphicContext *gc = window.get_gc(); |
| 787 |
|
| 788 |
CL_SpriteDescription fontdesc; |
| 789 |
fontdesc.add_paletteclipped_frames( |
| 790 |
new CL_PCXProvider("images/clanfont.pcx"), 129, 209, true); |
| 791 |
|
| 792 |
int start_time = CL_System::get_time(); |
| 793 |
|
| 794 |
int frames = 0; |
| 795 |
while (frames < loops / 5) |
| 796 |
{ |
| 797 |
CL_Sprite *fontsprite = new CL_Sprite(fontdesc); |
| 798 |
CL_Font *font = new CL_Font( |
| 799 |
*fontsprite, |
| 800 |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", |
| 801 |
10); |
| 802 |
|
| 803 |
delete font; |
| 804 |
delete fontsprite; |
| 805 |
|
| 806 |
frames++; |
| 807 |
} |
| 808 |
|
| 809 |
return int(frames / ((CL_System::get_time() - start_time) / 1000.0f)); |
| 810 |
} |