diff options
Diffstat (limited to '')
-rw-r--r-- | ClientHamr/extantz/crappisspuke.cpp | 6 | ||||
-rw-r--r-- | ClientHamr/extantz/extantz.c | 86 | ||||
-rw-r--r-- | ClientHamr/extantz/extantz.h | 3 |
3 files changed, 58 insertions, 37 deletions
diff --git a/ClientHamr/extantz/crappisspuke.cpp b/ClientHamr/extantz/crappisspuke.cpp index 47a6353..90cbbed 100644 --- a/ClientHamr/extantz/crappisspuke.cpp +++ b/ClientHamr/extantz/crappisspuke.cpp | |||
@@ -116,6 +116,11 @@ EAPI int startIrr(GLData *gld) | |||
116 | driver = device->getVideoDriver(); gld->driver = driver; | 116 | driver = device->getVideoDriver(); gld->driver = driver; |
117 | smgr = device->getSceneManager(); gld->smgr = smgr; | 117 | smgr = device->getSceneManager(); gld->smgr = smgr; |
118 | 118 | ||
119 | device->setResizable(true); | ||
120 | driver->OnResize(dimension2d<u32>(gld->sfc_w, gld->sfc_h)); | ||
121 | // Just gives me a blank screen. grrrr | ||
122 | // driver->setViewPort(rect<s32>(0, 0, gld->sfc_w, gld->sfc_h)); | ||
123 | |||
119 | // set ambient light | 124 | // set ambient light |
120 | smgr->setAmbientLight (video::SColorf(0x00c0c0c0)); | 125 | smgr->setAmbientLight (video::SColorf(0x00c0c0c0)); |
121 | 126 | ||
@@ -202,6 +207,7 @@ EAPI void drawIrr_start(GLData *gld) | |||
202 | call everything is presented on the screen. | 207 | call everything is presented on the screen. |
203 | */ | 208 | */ |
204 | driver->beginScene(true, true, SColor(255, 100, 101, 140), videoData, NULL); // This does the context change, then clearBuffers() | 209 | driver->beginScene(true, true, SColor(255, 100, 101, 140), videoData, NULL); // This does the context change, then clearBuffers() |
210 | |||
205 | smgr->drawAll(); | 211 | smgr->drawAll(); |
206 | } | 212 | } |
207 | } | 213 | } |
diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c index 3fa130c..fb15019 100644 --- a/ClientHamr/extantz/extantz.c +++ b/ClientHamr/extantz/extantz.c | |||
@@ -329,7 +329,7 @@ load_shader(GLData *gld, GLenum type, const char *shader_src) | |||
329 | return shader; | 329 | return shader; |
330 | } | 330 | } |
331 | 331 | ||
332 | static void _resize_gears(GLData *gld, int w, int h) | 332 | static void _resize(GLData *gld) |
333 | { | 333 | { |
334 | Evas_GL_API *gl = gld->glapi; | 334 | Evas_GL_API *gl = gld->glapi; |
335 | 335 | ||
@@ -343,22 +343,21 @@ static void _resize_gears(GLData *gld, int w, int h) | |||
343 | 343 | ||
344 | // GL Viewport stuff. you can avoid doing this if viewport is all the | 344 | // GL Viewport stuff. you can avoid doing this if viewport is all the |
345 | // same as last frame if you want | 345 | // same as last frame if you want |
346 | if (w < h) | 346 | if (gld->img_w < gld->img_h) |
347 | ar = w; | 347 | ar = gld->img_w; |
348 | else | 348 | else |
349 | ar = h; | 349 | ar = gld->img_h; |
350 | 350 | ||
351 | m[0] = 0.1 * ar / w; | 351 | m[0] = 0.1 * ar / gld->img_w; |
352 | m[5] = 0.1 * ar / h; | 352 | m[5] = 0.1 * ar / gld->img_h; |
353 | memcpy(gld->proj, m, sizeof gld->proj); | 353 | memcpy(gld->proj, m, sizeof gld->proj); |
354 | #endif | 354 | #endif |
355 | // gl->glViewport(0, 0, (GLint) w, (GLint) h); | 355 | // gl->glViewport(0, 0, (GLint) gld->img_w, (GLint) gld->img_h); |
356 | } | 356 | } |
357 | 357 | ||
358 | static void on_pixels(void *data, Evas_Object *obj) | 358 | static void on_pixels(void *data, Evas_Object *obj) |
359 | { | 359 | { |
360 | static int count = 0; | 360 | static int count = 0; |
361 | int w, h; | ||
362 | GLData *gld = data; | 361 | GLData *gld = data; |
363 | if (!gld) | 362 | if (!gld) |
364 | return; | 363 | return; |
@@ -367,13 +366,29 @@ static void on_pixels(void *data, Evas_Object *obj) | |||
367 | 366 | ||
368 | // get the image size in case it changed with evas_object_image_size_set() | 367 | // get the image size in case it changed with evas_object_image_size_set() |
369 | if (gld->r1) | 368 | if (gld->r1) |
370 | evas_object_image_size_get(gld->r1, &w, &h); | 369 | { |
370 | Evas_Coord w, h; | ||
371 | |||
372 | // Poor mans resize check. coz Elm wont do it easily. | ||
373 | evas_object_geometry_get(gld->r1, NULL, NULL, &w, &h); | ||
374 | if ((gld->img_w != w) || (gld->img_h != h)) | ||
375 | { | ||
376 | float new_w = ((float) gld->scr_w / ((float) gld->scr_w * (float) w)); | ||
377 | float new_h = ((float) gld->scr_h / ((float) gld->scr_h * (float) h)); | ||
378 | |||
379 | gld->img_w = new_w; | ||
380 | gld->img_h = new_h; | ||
381 | evas_object_image_fill_set(gld->r1, 0, 0, gld->img_w, gld->img_h); | ||
382 | gld->resized = 1; | ||
383 | } | ||
384 | } | ||
371 | 385 | ||
372 | if (gld->useEGL) | 386 | if (gld->useEGL) |
373 | { | 387 | { |
374 | // Yes, we DO need to do our own make current, coz aparently the Irrlicht one is useless. | 388 | // Yes, we DO need to do our own make current, coz aparently the Irrlicht one is useless. |
375 | evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); | 389 | evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); |
376 | // gl->glViewport(0, 0, (GLint) w/2, (GLint) h); | 390 | if (gld->resized) |
391 | _resize(gld); | ||
377 | } | 392 | } |
378 | 393 | ||
379 | if (!gld->doneIrr) | 394 | if (!gld->doneIrr) |
@@ -389,21 +404,13 @@ static void on_pixels(void *data, Evas_Object *obj) | |||
389 | static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; | 404 | static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; |
390 | GLfloat m[16]; | 405 | GLfloat m[16]; |
391 | 406 | ||
392 | // set up the context and surface as the current one | ||
393 | // if (!gld->useIrr) | ||
394 | // evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); | ||
395 | |||
396 | // GL Viewport stuff. you can avoid doing this if viewport is all the | ||
397 | // same as last frame if you want | ||
398 | // TODO - might want to do this in response to some sort of resize event instead. Looks like it's needed to run once at least anyway. | ||
399 | // if (count == 0) | ||
400 | _resize_gears(gld, w, h/2); | ||
401 | 407 | ||
402 | // Draw the gears. | 408 | // Draw the gears. |
403 | // if (!gld->useIrr) | 409 | if (!gld->useIrr) |
404 | // gl->glClearColor(0.8, 0.8, 0.1, 0.1); | 410 | { |
405 | // if (!gld->useIrr) | 411 | gl->glClearColor(0.8, 0.8, 0.1, 0.1); |
406 | // gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 412 | gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
413 | } | ||
407 | 414 | ||
408 | memcpy(m, gld->proj, sizeof m); | 415 | memcpy(m, gld->proj, sizeof m); |
409 | rotate(m, 2 * M_PI * gld->view_rotx / 360.0, 1, 0, 0); | 416 | rotate(m, 2 * M_PI * gld->view_rotx / 360.0, 1, 0, 0); |
@@ -419,6 +426,7 @@ static void on_pixels(void *data, Evas_Object *obj) | |||
419 | 426 | ||
420 | drawIrr_end(gld); | 427 | drawIrr_end(gld); |
421 | count++; | 428 | count++; |
429 | gld->resized = 0; | ||
422 | } | 430 | } |
423 | 431 | ||
424 | static void | 432 | static void |
@@ -497,9 +505,9 @@ static void init_evas_gl(GLData *gld, int w, int h) | |||
497 | if (!gld->useEGL) | 505 | if (!gld->useEGL) |
498 | return; | 506 | return; |
499 | 507 | ||
500 | w -= 10; | 508 | w *= 2; // Compensate for the original halving of the window. |
501 | h -= 10; | 509 | w -= 1; |
502 | h = h / 2; | 510 | h -= 1; |
503 | 511 | ||
504 | ee = ecore_evas_ecore_evas_get(evas_object_evas_get(gld->win)); | 512 | ee = ecore_evas_ecore_evas_get(evas_object_evas_get(gld->win)); |
505 | canvas = ecore_evas_get(ee); | 513 | canvas = ecore_evas_get(ee); |
@@ -518,24 +526,27 @@ static void init_evas_gl(GLData *gld, int w, int h) | |||
518 | gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT; | 526 | gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT; |
519 | 527 | ||
520 | // create a surface and context | 528 | // create a surface and context |
521 | gld->sfc_w = w; | 529 | gld->sfc_w = gld->scr_w; |
522 | gld->sfc_h = h; | 530 | gld->sfc_h = gld->scr_h; |
523 | gld->sfc = evas_gl_surface_create(gld->evasgl, gld->cfg, w, h); | 531 | gld->sfc = evas_gl_surface_create(gld->evasgl, gld->cfg, gld->sfc_w, gld->sfc_h); |
524 | gld->ctx = evas_gl_context_create(gld->evasgl, NULL); // The second NULL is for sharing contexts I think, which might be what we want to do with Irrlicht. | 532 | gld->ctx = evas_gl_context_create(gld->evasgl, NULL); // The second NULL is for sharing contexts I think, which might be what we want to do with Irrlicht. |
525 | //-// | 533 | //-// |
526 | //-//-//-// END GL INIT BLOB | 534 | //-//-//-// END GL INIT BLOB |
527 | 535 | ||
528 | // set up the image object. a filled one by default | 536 | // set up the image object. a filled one by default |
529 | gld->r1 = evas_object_image_filled_add(canvas); | 537 | gld->r1 = evas_object_image_add(canvas); |
538 | evas_object_image_filled_set(gld->r1, EINA_FALSE); | ||
530 | evas_object_size_hint_align_set(gld->r1, EVAS_HINT_FILL, EVAS_HINT_FILL); | 539 | evas_object_size_hint_align_set(gld->r1, EVAS_HINT_FILL, EVAS_HINT_FILL); |
531 | evas_object_size_hint_weight_set(gld->r1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 540 | evas_object_size_hint_weight_set(gld->r1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
541 | elm_win_resize_object_add(gld->win, gld->r1); | ||
532 | // when the object is deleted - call the on_del callback. like the above, | 542 | // when the object is deleted - call the on_del callback. like the above, |
533 | // this is just being clean | 543 | // this is just being clean |
534 | evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_DEL, on_del, gld); | 544 | evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_DEL, on_del, gld); |
535 | // set up an actual pixel size fot the buffer data. it may be different | 545 | // set up an actual pixel size for the buffer data. it may be different |
536 | // to the output size. any windowing system has something like this, just | 546 | // to the output size. any windowing system has something like this, just |
537 | // evas has 2 sizes, a pixel size and the output object size | 547 | // evas has 2 sizes, a pixel size and the output object size |
538 | evas_object_image_size_set(gld->r1, w, h); | 548 | evas_object_image_size_set(gld->r1, gld->scr_w, gld->scr_h); |
549 | evas_object_image_fill_set(gld->r1, 0, 0, w, h); | ||
539 | // set up the native surface info to use the context and surface created | 550 | // set up the native surface info to use the context and surface created |
540 | // above | 551 | // above |
541 | 552 | ||
@@ -552,14 +563,15 @@ static void init_evas_gl(GLData *gld, int w, int h) | |||
552 | //-//-//-// END GL INIT BLOB | 563 | //-//-//-// END GL INIT BLOB |
553 | 564 | ||
554 | evas_object_show(gld->r1); | 565 | evas_object_show(gld->r1); |
555 | elm_box_pack_end(gld->bx, gld->r1); | 566 | // Might be good to pack it when I get the menu / address / indicator bar working. |
567 | // elm_box_pack_end(gld->bx, gld->r1); | ||
556 | 568 | ||
557 | evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); | 569 | evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); |
558 | 570 | ||
559 | gld->glapi->glEnable(GL_CULL_FACE); | 571 | gld->glapi->glEnable(GL_CULL_FACE); |
560 | gld->glapi->glEnable(GL_DEPTH_TEST); | 572 | gld->glapi->glEnable(GL_DEPTH_TEST); |
561 | gld->glapi->glEnable(GL_BLEND); | 573 | gld->glapi->glEnable(GL_BLEND); |
562 | gld->glapi->glViewport(0, 0, (GLint) w, (GLint) h); | 574 | gld->glapi->glViewport(0, 0, (GLint) gld->sfc_w, (GLint) gld->sfc_h); |
563 | 575 | ||
564 | #if DO_GEARS | 576 | #if DO_GEARS |
565 | GLint linked = 0; | 577 | GLint linked = 0; |
@@ -1010,9 +1022,9 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
1010 | elm_win_title_set(gld->win, "extantz virtual world manager"); | 1022 | elm_win_title_set(gld->win, "extantz virtual world manager"); |
1011 | evas_object_smart_callback_add(gld->win, "delete,request", _on_done, NULL); | 1023 | evas_object_smart_callback_add(gld->win, "delete,request", _on_done, NULL); |
1012 | 1024 | ||
1013 | elm_win_screen_size_get(gld->win, &x, &y, &w, &h); | 1025 | elm_win_screen_size_get(gld->win, &x, &y, &gld->scr_w, &gld->scr_h); |
1014 | w = w / 2; | 1026 | w = gld->scr_w / 2; |
1015 | h = h - 30; | 1027 | h = gld->scr_h - 30; |
1016 | 1028 | ||
1017 | bg = elm_bg_add(gld->win); | 1029 | bg = elm_bg_add(gld->win); |
1018 | elm_bg_load_size_set(bg, w, h); | 1030 | elm_bg_load_size_set(bg, w, h); |
diff --git a/ClientHamr/extantz/extantz.h b/ClientHamr/extantz/extantz.h index a3c46e5..5fec64c 100644 --- a/ClientHamr/extantz/extantz.h +++ b/ClientHamr/extantz/extantz.h | |||
@@ -136,10 +136,13 @@ struct _GLData | |||
136 | GLuint program; | 136 | GLuint program; |
137 | GLuint vtx_shader; | 137 | GLuint vtx_shader; |
138 | GLuint fgmt_shader; | 138 | GLuint fgmt_shader; |
139 | int scr_w, scr_h; | ||
139 | int sfc_w, sfc_h; | 140 | int sfc_w, sfc_h; |
141 | int img_w, img_h; | ||
140 | int useEGL : 1; | 142 | int useEGL : 1; |
141 | int useIrr : 1; | 143 | int useIrr : 1; |
142 | int doneIrr : 1; | 144 | int doneIrr : 1; |
145 | int resized : 1; | ||
143 | 146 | ||
144 | Evas_Object *bx, *r1; | 147 | Evas_Object *bx, *r1; |
145 | Ecore_Animator *animator; | 148 | Ecore_Animator *animator; |