Mercurial > hg > Game > Cerium
changeset 1130:5addc6c1d5c4 draft
fix.
author | root@dolphins.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 13 Feb 2011 22:34:44 +0900 |
parents | a8bffdb5d2e3 |
children | 220f9032d2d2 |
files | Renderer/Engine/SceneGraph.cc Renderer/Engine/polygon.cc Renderer/Engine/polygon.h Renderer/Engine/viewer.cc Renderer/Engine/viewerGL.cc |
diffstat | 5 files changed, 43 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc Sun Feb 13 07:20:55 2011 +0900 +++ b/Renderer/Engine/SceneGraph.cc Sun Feb 13 22:34:44 2011 +0900 @@ -167,7 +167,7 @@ parent_name = (char *)xmlGetProp(surface,(xmlChar *)"parent"); for (int i = 0; i < 16; i++) { - matrix[i] = 0; + matrix[i] = 0; real_matrix[i] = 0; } @@ -206,7 +206,7 @@ size = 0; //data = NULL; - texture_info.texture_id = -1; + texture_info->texture_id = -1; move = no_move; collision = no_collision; @@ -533,9 +533,8 @@ printf("Can't load image %s\n",filename); exit(0); } - - texture_info.texture_id = makeTapestries(manager, texture_image, tex_id); - tex_id = texture_info.texture_id; + texture_info->texture_id = makeTapestries(manager, texture_image, tex_id); + tex_id = texture_info->texture_id; if (unlink(image_name)) { cout << "unlink error\n"; @@ -544,17 +543,17 @@ /** * 以前に Load されている Texture を共用 */ - texture_info.texture_id = tex_id; + texture_info->texture_id = tex_id; } // こんなことすると list[] のいみあるのかなーと // 微妙に思う、自分で書き換えた感想 by gongo - texture_info.t_w = list[tex_id].t_w; - texture_info.t_h = list[tex_id].t_h;; - texture_info.pixels_orig = list[tex_id].pixels_orig; - texture_info.pixels = list[tex_id].pixels; - texture_info.scale_max = list[tex_id].scale_max; - texture_info.texture_image = list[tex_id].texture_image; + texture_info->t_w = list[tex_id].t_w; + texture_info->t_h = list[tex_id].t_h;; + texture_info->pixels_orig = list[tex_id].pixels_orig; + texture_info->pixels = list[tex_id].pixels; + texture_info->scale_max = list[tex_id].scale_max; + texture_info->texture_image = list[tex_id].texture_image; }
--- a/Renderer/Engine/polygon.cc Sun Feb 13 07:20:55 2011 +0900 +++ b/Renderer/Engine/polygon.cc Sun Feb 13 22:34:44 2011 +0900 @@ -15,8 +15,13 @@ using namespace std; -Polygon::Polygon(void) + + +Polygon::Polygon() { + matrix = (float*)polygon_allocate(sizeof(float)*16); + real_matrix = (float*)polygon_allocate(sizeof(float)*16); + texture_info = (texture_list*)polygon_allocate(sizeof(texture_list)); position_init(); } @@ -221,16 +226,16 @@ //Uint32 temp, pixel; Uint8 red, green, blue; - fmt = texture_info.texture_image->format; + fmt = texture_info->texture_image->format; if (tx<0) tx = 0; - if (texture_info.texture_image->w-1< tx) tx = texture_info.texture_image->w-1 ; + if (texture_info->texture_image->w-1< tx) tx = texture_info->texture_image->w-1 ; if (ty<0) ty = 0; - if (texture_info.texture_image->h-1< ty) ty = texture_info.texture_image->h-1 ; + if (texture_info->texture_image->h-1< ty) ty = texture_info->texture_image->h-1 ; //SDL_LockSurface(texture_image); - char *p = get_pixel(tx,ty,texture_info.texture_image); + char *p = get_pixel(tx,ty,texture_info->texture_image); blue = (Uint8) p[0]; green = (Uint8) p[1]; red = (Uint8) p[2];
--- a/Renderer/Engine/polygon.h Sun Feb 13 07:20:55 2011 +0900 +++ b/Renderer/Engine/polygon.h Sun Feb 13 22:34:44 2011 +0900 @@ -10,20 +10,15 @@ class Polygon { public: + long long size; const char *name; const char *parent_name; - //float *data; //"vertex" and "normal" and "texture" - - //float *matrix; - //float *real_matrix; - //texture_list *texture_info; - - float matrix[16] ; - float real_matrix[16] ; - texture_list texture_info; - + float *matrix; + float *real_matrix; + texture_list *texture_info; + PolygonPackPtr pp; int pp_num; @@ -44,6 +39,15 @@ Uint32 get_rgb(int tx, int ty); public: + void* + polygon_allocate(int size) + { + void *buff = 0; + if (size==0) return 0; + posix_memalign(&buff, 16, size); + return buff; + } + void position_init(void); void tree_draw();
--- a/Renderer/Engine/viewer.cc Sun Feb 13 07:20:55 2011 +0900 +++ b/Renderer/Engine/viewer.cc Sun Feb 13 22:34:44 2011 +0900 @@ -450,9 +450,10 @@ PolygonPackPtr out_pp = r[ppi].ppack; HTaskPtr task_create_pp = manager->create_task(Dummy); task_create_pp->set_cpu(CPU_PPE); - + + SceneGraphPtr t = (SceneGraphPtr)manager->allocate(sizeof(SceneGraph)); //多分このsg_remove_listであってる?。チェック対象かも - for (SceneGraphPtr t = sgroot->sg_remove_list; t != NULL; t = t->next) { + for (t = sgroot->sg_remove_list; t != NULL; t = t->next) { for (int i = 0; i < t->pp_num; i++) { HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph); @@ -460,7 +461,7 @@ create_pp->add_inData(&t->pp[i], sizeof(PolygonPack)); create_pp->add_inData(t->matrix, sizeof(float)*16); create_pp->add_inData(t->real_matrix, sizeof(float)*16); - create_pp->add_inData(&t->texture_info, sizeof(texture_list)); + create_pp->add_inData(t->texture_info, sizeof(texture_list)); if ( (unsigned long)t->matrix & 0xf) { printf("marix not aligned\n"); @@ -470,7 +471,7 @@ printf("real_matrix not aligned\n"); } - if ((unsigned long)&t->texture_info & 0xf) { + if ((unsigned long)t->texture_info & 0xf) { printf("texture_info not aligned\n"); }
--- a/Renderer/Engine/viewerGL.cc Sun Feb 13 07:20:55 2011 +0900 +++ b/Renderer/Engine/viewerGL.cc Sun Feb 13 22:34:44 2011 +0900 @@ -201,10 +201,10 @@ while (sg) { if (sg->flag_drawable) { - if (!sg->texture_info.gl_tex) { - sg->texture_info.gl_tex = SDL_GL_LoadTexture(sg->texture_info.texture_image); + if (!sg->texture_info->gl_tex) { + sg->texture_info->gl_tex = SDL_GL_LoadTexture(sg->texture_info->texture_image); } - texture = sg->texture_info.gl_tex; + texture = sg->texture_info->gl_tex; glBindTexture(GL_TEXTURE_2D, texture); glEnable(GL_TEXTURE_2D);