From 3a7a5b2a212279cd2af72635dad574b160602bcc Mon Sep 17 00:00:00 2001 From: Mergul Date: Fri, 12 Jun 2020 14:53:59 +0200 Subject: [PATCH] Slightly changed rendering code -renderer draw function now takes struct instead of multiple parameters --- demos/source/demos/particles.d | 15 ++- demos/source/demos/simple.d | 14 ++- demos/source/demos/snake.d | 69 ++++++++++---- demos/source/demos/space_invaders.d | 73 ++++++++++---- demos/utils/source/ecs_utils/gfx/renderer.d | 100 +++++++++++++------- 5 files changed, 199 insertions(+), 72 deletions(-) diff --git a/demos/source/demos/particles.d b/demos/source/demos/particles.d index b58b775..8b27f80 100644 --- a/demos/source/demos/particles.d +++ b/demos/source/demos/particles.d @@ -134,19 +134,30 @@ struct DrawSystem void onUpdate(EntitiesData data) { if(launcher.renderer.prepared_items >= launcher.renderer.MaxObjects)return;//simple leave loop if max visible objects count was reached + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(2,2); + draw_data.coords = vec4(246,64,2,2)*px; + draw_data.color = 0x80808080; + draw_data.material_id = 2; + draw_data.thread_id = data.job_id; + draw_data.texture = particles_demo.texture; if(!data.color) { foreach(i; 0..data.length) { - launcher.renderer.draw(particles_demo.texture, data.locations[i], vec2(2,2), vec4(246,64,2,2)*px, 0, 0x80808080, 0, 2, 0, data.job_id); + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data);//particles_demo.texture, data.locations[i], vec2(2,2), vec4(246,64,2,2)*px, 0, 0x80808080, 0, 2, 0, data.job_id); } } else { foreach(i; 0..data.length) { - launcher.renderer.draw(particles_demo.texture, data.locations[i], vec2(2,2), vec4(246,64,2,2)*px, 0, data.color[i].value, 0, 2, 0, data.job_id); + draw_data.position = data.locations[i]; + draw_data.color = data.color[i].value; + launcher.renderer.draw(draw_data);//particles_demo.texture, data.locations[i], vec2(2,2), vec4(246,64,2,2)*px, 0, data.color[i].value, 0, 2, 0, data.job_id); } } diff --git a/demos/source/demos/simple.d b/demos/source/demos/simple.d index ac3b3f7..6876e4f 100644 --- a/demos/source/demos/simple.d +++ b/demos/source/demos/simple.d @@ -52,9 +52,21 @@ struct DrawSystem void onUpdate(EntitiesData data) { if(launcher.renderer.prepared_items >= launcher.renderer.MaxObjects)return;//simple leave loop if max visible objects count was reached + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(16,16); + draw_data.coords = vec4(0,0,1,1); + draw_data.color = 0x80808080; + draw_data.material_id = 0; + draw_data.thread_id = data.job_id; + draw_data.texture = simple.texture; + foreach(i; 0..data.length) { - launcher.renderer.draw(simple.texture, data.locations[i], vec2(16,16), vec4(0,0,1,1), cast(ushort)(data.locations[i].y), 0x80808080, 0, 0, 0, data.job_id); + draw_data.position = data.locations[i]; + draw_data.depth = cast(ushort)(data.locations[i].y); + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(simple.texture, data.locations[i], vec2(16,16), vec4(0,0,1,1), cast(ushort)(data.locations[i].y), 0x80808080, 0, 0, 0, data.job_id); // launcher.renderer.draw(data.textures[i].tex, data.locations[i].location, vec2(16,16), vec4(0,0,1,1), 0, 0x80808080, 0, 0, 0, data.job_id); //draw(renderer, data.textures[i].tex, data.locations[i], vec2(32,32), vec4(0,0,1,1)); } diff --git a/demos/source/demos/snake.d b/demos/source/demos/snake.d index 579bc54..c42f690 100644 --- a/demos/source/demos/snake.d +++ b/demos/source/demos/snake.d @@ -348,9 +348,21 @@ struct AnimationRenderSystem void onUpdate(EntitiesData data) { + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(16,16); + //draw_data.coords = vec4(0,0,1,1)*px; + draw_data.color = 0x80808080; + draw_data.material_id = 0; + draw_data.thread_id = 0; + draw_data.texture = snake.texture; + draw_data.depth = -1; foreach(i;0..data.length) { - launcher.renderer.draw(snake.texture, cast(vec2)cast(ivec2)data.location[i], vec2(16,16), data.animation[i].frames[cast(int)(data.animation[i].time)], -1, 0x80808080); + draw_data.position = data.location[i]; + draw_data.coords = data.animation[i].frames[cast(int)(data.animation[i].time)]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(snake.texture, cast(vec2)cast(ivec2)data.location[i], vec2(16,16), data.animation[i].frames[cast(int)(data.animation[i].time)], -1, 0x80808080); } } } @@ -649,9 +661,19 @@ struct DrawAppleSystem void onUpdate(EntitiesData data) { + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(16,16); + draw_data.coords = vec4(0,32*px,16*px,16*px); + draw_data.color = 0x80808080; + draw_data.material_id = 0; + draw_data.thread_id = 0; + draw_data.texture = snake.texture; foreach(i; 0..data.location.length) { - launcher.renderer.draw(snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(0,32*px,16*px,16*px), 0, 0x80808080, 0); + draw_data.position = vec2(data.location[i].x*16,data.location[i].y*16); + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(0,32*px,16*px,16*px), 0, 0x80808080, 0); } } } @@ -719,34 +741,49 @@ struct DrawSnakeSystem static void drawElement(ivec2 loc, SnakePart part) { + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(16,16); + draw_data.color = 0x80808080; + draw_data.texture = snake.texture; + draw_data.position = cast(vec2)loc; final switch(cast(ubyte)part) { - case SnakePart.tail_up:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(16,112,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.tail_down:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(0,112,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.tail_left:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(32,112,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.tail_right:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(0,144,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.turn_ld:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(64,128,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.turn_lu:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(32,144,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.turn_rd:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(16,144,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.turn_ru:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(64,112,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.vertical:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(16,128,16,16)*px, 0, 0x80808080, 0);break; - case SnakePart.horizontal:launcher.renderer.draw(.snake.texture, cast(vec2)loc, vec2(16,16), vec4(48,128,16,16)*px, 0, 0x80808080, 0);break; + case SnakePart.tail_up:draw_data.coords = vec4(16,112,16,16)*px;break; + case SnakePart.tail_down:draw_data.coords = vec4(0,112,16,16)*px;break; + case SnakePart.tail_left:draw_data.coords = vec4(32,112,16,16)*px;break; + case SnakePart.tail_right:draw_data.coords = vec4(0,144,16,16)*px;break; + case SnakePart.turn_ld:draw_data.coords = vec4(64,128,16,16)*px;break; + case SnakePart.turn_lu:draw_data.coords = vec4(32,144,16,16)*px;break; + case SnakePart.turn_rd:draw_data.coords = vec4(16,144,16,16)*px;break; + case SnakePart.turn_ru:draw_data.coords = vec4(64,112,16,16)*px;break; + case SnakePart.vertical:draw_data.coords = vec4(16,128,16,16)*px;break; + case SnakePart.horizontal:draw_data.coords = vec4(48,128,16,16)*px;break; } + launcher.renderer.draw(draw_data); } void onUpdate(EntitiesData data) { + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.size = vec2(16,16); + draw_data.color = 0x80808080; + draw_data.texture = snake.texture; + foreach(i; 0..data.length) { const (CSnake)* snake = &data.snake[i]; scope vec2 loc = cast(vec2)(data.location[i].location * 16); + draw_data.position = loc; final switch(snake.direction) { - case CMovement.Direction.up:launcher.renderer.draw(.snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(48,112,16,16)*px, 0, 0x80808080, 0);break; - case CMovement.Direction.down:launcher.renderer.draw(.snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(48,144,16,16)*px, 0, 0x80808080, 0);break; - case CMovement.Direction.left:launcher.renderer.draw(.snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(0,128,16,16)*px, 0, 0x80808080, 0);break; - case CMovement.Direction.right:launcher.renderer.draw(.snake.texture, vec2(data.location[i].x*16,data.location[i].y*16), vec2(16,16), vec4(32,128,16,16)*px, 0, 0x80808080, 0);break; + case CMovement.Direction.up:draw_data.coords = vec4(48,112,16,16)*px;break; + case CMovement.Direction.down:draw_data.coords = vec4(48,144,16,16)*px;break; + case CMovement.Direction.left:draw_data.coords = vec4(0,128,16,16)*px;break; + case CMovement.Direction.right:draw_data.coords = vec4(32,128,16,16)*px;break; } + launcher.renderer.draw(draw_data); if(snake.parts.length >1) { foreach(j;1..snake.parts.length - 1)drawElement(snake.parts[j]*16, snakePart(snake.parts[j], snake.parts[j+1], snake.parts[j-1])); diff --git a/demos/source/demos/space_invaders.d b/demos/source/demos/space_invaders.d index ce2cd6a..b08b9ac 100644 --- a/demos/source/demos/space_invaders.d +++ b/demos/source/demos/space_invaders.d @@ -976,31 +976,52 @@ struct DrawSystem void onUpdate(EntitiesData data) { + if(launcher.renderer.prepared_items >= launcher.renderer.MaxObjects)return;//simple leave loop if max visible objects count was reached + import ecs_utils.gfx.renderer; + Renderer.DrawData draw_data; + draw_data.color = 0x80808080; + draw_data.thread_id = data.job_id; + draw_data.texture = space_invaders.texture; + //uint color_mask = 0xFCFCFCFC; + uint const_map = 0x80A08080;//0x80808080; if(!data.depth) { if(data.hit_mark) { foreach(i; 0..data.length) { - uint color = 0x80808080 + 0x01010101 * data.hit_mark[i]; - short depth = cast(short)(data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color, 0, 0, 0, data.job_id); + draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i]; + draw_data.depth = cast(short)(data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color|const_map, 0, 0, 0, data.job_id); } } else if(data.rotation) { foreach(i; 0..data.length) { - short depth = cast(short)(data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080, data.rotation[i], 0, 0, data.job_id); + draw_data.depth = cast(short)(data.locations[i].y); + draw_data.angle = data.rotation[i]; + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080|const_map, data.rotation[i], 0, 0, data.job_id); } } else { foreach(i; 0..data.length) { - short depth = cast(short)(data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080, 0, 0, 0, data.job_id); + draw_data.depth = cast(short)(data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080|const_map, 0, 0, 0, data.job_id); } } } @@ -1012,18 +1033,27 @@ struct DrawSystem { foreach(i; 0..data.length) { - uint color = 0x80808080 + 0x01010101 * data.hit_mark[i]; - short depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color, data.rotation[i], 0, 0, data.job_id); + draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i]; + draw_data.angle = data.rotation[i]; + draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color|const_map, data.rotation[i], 0, 0, data.job_id); } } else { foreach(i; 0..data.length) { - uint color = 0x80808080 + 0x01010101 * data.hit_mark[i]; - short depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color, 0, 0, 0, data.job_id); + draw_data.color = 0x80808080 + 0x01010101 * data.hit_mark[i]; + draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, color|const_map, 0, 0, 0, data.job_id); } } } @@ -1031,16 +1061,25 @@ struct DrawSystem { foreach(i; 0..data.length) { - short depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080, data.rotation[i], 0, 0, data.job_id); + draw_data.angle = data.rotation[i]; + draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080|const_map, data.rotation[i], 0, 0, data.job_id); } } else { foreach(i; 0..data.length) { - short depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); - launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080, 0, 0, 0, data.job_id); + draw_data.depth = cast(short)(data.depth[i] * 8 + data.locations[i].y); + draw_data.coords = data.textures[i].coords; + draw_data.size = data.scale[i]; + draw_data.position = data.locations[i]; + launcher.renderer.draw(draw_data); + //launcher.renderer.draw(space_invaders.texture, data.locations[i].value, data.scale[i], data.textures[i].coords, depth, 0x80808080|const_map, 0, 0, 0, data.job_id); } } } diff --git a/demos/utils/source/ecs_utils/gfx/renderer.d b/demos/utils/source/ecs_utils/gfx/renderer.d index 4e34b54..ef53543 100644 --- a/demos/utils/source/ecs_utils/gfx/renderer.d +++ b/demos/utils/source/ecs_utils/gfx/renderer.d @@ -430,13 +430,29 @@ struct Renderer } - void draw(Texture tex, vec2 pos, vec2 size, vec4 coords, short depth = 0, uint color = uint.max, float angle = 0, uint material_id = 0, uint mesh_id = 0, uint thread_id = 0) + struct DrawData { - if(prepared_items >= MaxObjects)return; - __draw(this,tex,pos,size,coords,depth,color,angle,material_id,mesh_id,thread_id); + Texture texture; + vec2 position; + vec2 size; + vec4 coords; + short depth = 0; + uint color = uint.max; + float angle = 0; + uint material_id = 0; + uint mesh_id = 0; + uint thread_id = 0; } - private static void __draw_sdl(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) + //void draw(Texture tex, vec2 pos, vec2 size, vec4 coords, short depth = 0, uint color = uint.max, float angle = 0, uint material_id = 0, uint mesh_id = 0, uint thread_id = 0) + void draw(scope ref const(DrawData) data) + { + if(prepared_items >= MaxObjects)return; + __draw(this,data);//tex,pos,size,coords,depth,color,angle,material_id,mesh_id,thread_id); + } + + //private static void __draw_sdl(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) + private static void __draw_sdl(ref Renderer this_, scope ref const(DrawData) data) { /*with(this_) { @@ -456,22 +472,25 @@ struct Renderer }*/ } - private static void __draw_gl(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) + // private static void __draw_gl(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) + private static void __draw_gl(ref Renderer this_, scope ref const(DrawData) data) { //import core.stdc.string; with(this_) { //pos += view_pos; - size.x *= view_size.x; - size.y *= view_size.y; - pos.x = pos.x * view_size.x + view_pos.x; - pos.y = pos.y * view_size.y + view_pos.y;//*/ + vec2 pos = void; + vec2 size = void; + size.x = data.size.x * view_size.x; + size.y = data.size.y * view_size.y; + pos.x = data.position.x * view_size.x + view_pos.x; + pos.y = data.position.y * view_size.y + view_pos.y;//*/ /*version(ver6)void* ptr = ubos[0].mappedPointer() + data_index; else void* ptr = uniform_block.ptr + data_index;*/ if(data_ptr is null)return; void* ptr = data_ptr + data_index; - if(angle == 0) + if(data.angle == 0) { *cast(float*)ptr = size.x; *cast(float*)(ptr+4) = 0; @@ -481,8 +500,8 @@ struct Renderer else { //import core.stdc.math; - float sinn = sinf(angle); - float coss = cosf(angle); + float sinn = sinf(data.angle); + float coss = cosf(data.angle); *cast(float*)ptr = coss * size.x; *cast(float*)(ptr+4) = -sinn * size.y; *cast(float*)(ptr+8) = sinn * size.x; @@ -491,12 +510,12 @@ struct Renderer //memcpy(ptr,); memcpy(ptr+16,pos.data.ptr,8); - memcpy(ptr+32,coords.data.ptr,16); + memcpy(ptr+32,data.coords.data.ptr,16); //render_list[item_id] = RenderData(tex,material_id,mesh_id); - render_list[item_id].texture = tex; - render_list[item_id].material_id = material_id; - render_list[item_id].mesh_id = mesh_id; + render_list[item_id].texture = *cast(Texture*)&data.texture; + render_list[item_id].material_id = data.material_id; + render_list[item_id].mesh_id = data.mesh_id; data_index += data_offset; item_id++; @@ -504,39 +523,43 @@ struct Renderer } } - private static void __draw_gl_vbo_batch(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id = 0) + // private static void __draw_gl_vbo_batch(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id = 0) + private static void __draw_gl_vbo_batch(ref Renderer this_, scope ref const(DrawData) data) { import ecs_utils.gfx.config; //import core.stdc.string; with(this_) { + uint thread_id = data.thread_id; //if(item_id >= MaxObjects)return; //pos += view_pos; Thread* thread = &threads[thread_id]; VertexBlock* block; - assert(thread.blocks.length > material_id); - block = &thread.blocks[material_id]; + assert(thread.blocks.length > data.material_id); + block = &thread.blocks[data.material_id]; if(block.items == 0) { - thread.blocks[material_id] = getBlock(); - block = &thread.blocks[material_id]; - block.material_id = material_id; + thread.blocks[data.material_id] = getBlock(); + block = &thread.blocks[data.material_id]; + block.material_id = data.material_id; } else if(block.items >= VertexBlock.max_items) { //pushBlock(thread.block); prepared_items += block.items; thread.filled_blocks.add(*block); - thread.blocks[material_id] = getBlock(); - block = &thread.blocks[material_id]; - block.material_id = material_id; + thread.blocks[data.material_id] = getBlock(); + block = &thread.blocks[data.material_id]; + block.material_id = data.material_id; } - short[3] mem = [depth, *cast(short*)&color, *(cast(short*)&color + 1)]; + short[3] mem = [data.depth, *cast(short*)&data.color, *(cast(short*)&data.color + 1)]; - pos.x = pos.x * view_size.x + view_pos.x; - pos.y = pos.y * view_size.y + view_pos.y;//*/ + vec2 pos = void; + vec2 size = void; + pos.x = data.position.x * view_size.x + view_pos.x; + pos.y = data.position.y * view_size.y + view_pos.y;//*/ /*void* ptr = data_ptr + data_index; *cast(float*)ptr = size.x; @@ -550,10 +573,13 @@ struct Renderer short[] verts = cast(short[])block.batch_vertices; uint item_id = block.items; - if(angle == 0) + uint mesh_id = data.mesh_id; + vec4 coords = data.coords; + + if(data.angle == 0) { - size.x *= view_size.x; - size.y *= view_size.y; + size.x = data.size.x * view_size.x; + size.y = data.size.y * view_size.y; verts[item_id*28] = cast(short)((GfxConfig.meshes[mesh_id].vertices[0] * size.x + pos.x) * 8191); verts[item_id*28+1] = cast(short)((GfxConfig.meshes[mesh_id].vertices[1] * size.y + pos.y) * 8191); @@ -585,10 +611,11 @@ struct Renderer else { //import core.stdc.math; - float sinx = sinf(angle) * size.x * view_size.y; - float cosx = cosf(angle) * size.x * view_size.x; - float siny = sinf(angle) * size.y * view_size.x; - float cosy = cosf(angle) * size.y * view_size.y; + float angle = data.angle; + float sinx = sinf(angle) * data.size.x * view_size.y; + float cosx = cosf(angle) * data.size.x * view_size.x; + float siny = sinf(angle) * data.size.y * view_size.x; + float cosy = cosf(angle) * data.size.y * view_size.y; /*batch_vertices[item_id*28] = GfxConfig.meshes[mesh_id].vertices[0] * size.x; batch_vertices[item_id*28+1] = GfxConfig.meshes[mesh_id].vertices[1] * size.y; @@ -1088,7 +1115,8 @@ struct Renderer view_pos = (pos - size * 0.5) * view_size; } - __gshared void function(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) __draw; + // __gshared void function(ref Renderer this_, Texture tex, vec2 pos, vec2 size, vec4 coords, short depth, uint color, float angle, uint material_id, uint mesh_id, uint thread_id) __draw; + __gshared void function(ref Renderer this_, scope ref const(DrawData) data) __draw; __gshared void function(ref Renderer this_) __present; __gshared void function(ref Renderer this_) __clear; __gshared void function(ref Renderer this_) __initialize;