Mercurial > hg > Game > Cerium
changeset 1338:8c098a144c75 draft
change from malloc to new
author | e095732 <e095732@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 Jan 2012 16:42:14 +0900 |
parents | 8b60616fca45 |
children | b6ee60edacf0 |
files | Renderer/Engine/SceneGraphRoot.cc |
diffstat | 1 files changed, 24 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraphRoot.cc Sun Jan 08 21:48:02 2012 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Mon Jan 09 16:42:14 2012 +0900 @@ -24,7 +24,6 @@ sgroot->tmanager = manager; // SGLIST_LENGTH 決め打ちかぁ、動的生成にする場合上限決めておいた方がいいのかな - // sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); camera = new Camera(w, h, this, sgroot->tmanager); @@ -431,22 +430,25 @@ for (int i = 0;i < s->polylist_count;i++){ vcsum += s->vcount[i]; } - s->pcount = (float*)malloc(sizeof(float)*vcsum); + //s->pcount = (float*)malloc(sizeof(float)*vcsum); + s->pcount = new float[vcsum]; for (int i=0; pcont != NULL; i++) { pcont = pickup_float(pcont, s->pcount+i); - } - int vertexp[vcsum]; + } + int *vertexp; + vertexp = new int[vcsum]; for (int i=0;i<vcsum;i++){ vertexp[i]=0; } - float *vertex_table = (float*)malloc(sizeof(float)*s->vertex_float->count) ; - float *normal_table = (float*)malloc(sizeof(float)*s->normal_float->count) ; - float *texcoord_table = (float*)malloc(sizeof(float)*s->texcoord_float->count) ; - - - //float *vertex_table = new float[s->vertex_float->count]; - //float *normal_table = new float[s->normal_float->count]; - //float *texcoord_table = new float[s->texcoord_float->count]; + float *vertex_table; + float *normal_table; + float *texcoord_table; + vertex_table = new float[s->vertex_float->count]; + //float *vertex_table = (float*)malloc(sizeof(float)*s->vertex_float->count) ; + normal_table = new float[s->normal_float->count]; + //float *normal_table = (float*)malloc(sizeof(float)*s->normal_float->count) ; + texcoord_table = new float[s->texcoord_float->count]; + //float *texcoord_table = (float*)malloc(sizeof(float)*s->texcoord_float->count) ; int limit = vcsum * 2; if (s->texcoord_offset == 2){ @@ -462,6 +464,7 @@ i++; } } + delete s->pcount; for (int i=0; vertexp[i];i++) { if (s->vcount[i] == 4) { for (int j=0; j > s->vcount[i]; j++) { @@ -473,6 +476,7 @@ vertex_table[i] = s->vertex_float->u.array[vertexp[i]]; } } + delete s->vcount; int count = vcsum / 3; SceneGraphPtr sg = new SceneGraph(manager); @@ -532,13 +536,15 @@ printf("vertexp = %d\n", vertexp[i]); // printf("vertex_table= %f\n", vertex_table[i]); } - free(vertexp); + //free(vertexp); //free(vertex_table); //free(normal_table); //free(texcoord_table); - //delete vertex_table; - //delete normal_table; - //delete texcoord_table; + + delete vertexp; + delete vertex_table; + delete normal_table; + delete texcoord_table; /* got out of polylist */ s->polylist = 0; @@ -580,7 +586,8 @@ } } else if (!xmlStrcmp(cur->name, (xmlChar*)"vcount")) { char *vcont = (char*)xmlNodeGetContent(cur); - s->vcount = (float*)malloc(sizeof(float)*s->polylist_count); + //s->vcount = (float*)malloc(sizeof(float)*s->polylist_count); + s->vcount = new float[s->polylist_count]; for (int i=0; vcont!=NULL; i++) { /* store vcount list */ vcont = pickup_float(vcont, s->vcount+i);