Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WorldSegment::drawAllBlocks()
- {
- // x,y,z print pricess
- ALLEGRO_BITMAP * temp = al_get_target_bitmap();
- int32_t vsxmax = viewedSegment->sizex-1;
- int32_t vsymax = viewedSegment->sizey-1;
- int32_t vszmax = viewedSegment->sizez-1; // grabbing one tile +z more than we should for tile rules
- //al_hold_bitmap_drawing(true);
- int op, src, dst, alpha_op, alpha_src, alpha_dst;
- ALLEGRO_COLOR color;
- al_get_separate_blender(&op, &src, &dst, &alpha_op, &alpha_src, &alpha_dst);
- al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb)); //Flicker Fix
- //al_flip_display(); //Anti Flicker for Slow Debug Drawing
- //al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb)); // Same as above
- for(int32_t vsz=0; vsz < vszmax; vsz++)
- {
- if(config.showRenderStatus)
- SetTitle("Stonesense - Drawing Terrain, Level %d/%d", (vsz+1), vszmax);
- if(config.fogenable && config.foga)
- {
- if(!fog)
- {
- fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp));
- al_set_target_bitmap(fog);
- al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb));
- al_set_target_bitmap(temp);
- }
- if(!((al_get_bitmap_width(fog) == al_get_bitmap_width(temp)) && (al_get_bitmap_height(fog) == al_get_bitmap_height(temp))))
- {
- al_destroy_bitmap(fog);
- fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp));
- al_set_target_bitmap(fog);
- al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb));
- al_set_target_bitmap(temp);
- }
- al_draw_tinted_bitmap(fog, al_map_rgba(255, 255, 255, config.foga), 0, 0, 0);
- }
- if(vsz == vszmax-1)
- {
- if(config.show_osd) DrawCurrentLevelOutline(true);
- }
- if(config.dayNightCycle)
- al_hold_bitmap_drawing(true);
- for(int32_t vsx=1; vsx < vsxmax; vsx++)
- {
- for(int32_t vsy=1; vsy < vsymax; vsy++)
- {
- Block *b = getBlockLocal(vsx,vsy,vsz);
- if(b==NULL || (b->floorType == 0 && b->ramp.type == 0 && b->wallType == 0))
- {
- Block* bLow = getBlockLocal(vsx,vsy,vsz-1);
- if(bLow != NULL)
- {
- bLow->DrawRamptops();
- }
- }
- if(b)
- {
- Block *frontleft = getBlockLocal(vsx,vsy+1,vsz);
- Block *frontright = getBlockLocal(vsx+1,vsy,vsz);
- Block *top = getBlockLocal(vsx,vsy,vsz+1);
- Block *topleft = getBlockLocal(vsx,vsy+1,vsz+1);
- Block *topright = getBlockLocal(vsx+1,vsy,vsz+1);
- Block *topfront = getBlockLocal(vsx+1,vsy+1,vsz+1);
- bool drawtl=false;
- bool drawtr=false;
- bool drawtf=false;
- bool drawt=false;
- if(topleft!=NULL)
- drawtl = topleft->wallType||topleft->floorType||topleft->ramp.type; // Is Top Left beeing drawn
- if(topright!=NULL)
- drawtr = topright->wallType||topright->floorType||topright->ramp.type; // Is Top Right beeing drawn
- if(topfront!=NULL)
- drawtf = topfront->wallType||topfront->floorType||topfront->ramp.type; // Is Top Front beeing drawn
- if(top!=NULL)
- drawt = top->wallType||top->floorType||top->ramp.type; // Is Top beeing drawn
- if(vsx<vsxmax-1&&vsy<vsymax-1&&vsz<vszmax-1) // Draw empty blocks on map edge and on top
- {
- if(!(b->wallType||b->floorType||b->ramp.type||b->stairType)) // Nothing to draw, moving on
- continue;
- if(!(topleft==NULL||topright==NULL||top==NULL||topfront==NULL)&&(drawtl&&drawtr&&drawtf&&drawt)) //Block is totally covered from above, moving on
- continue;
- if(((frontleft!=NULL&&frontleft->wallType)&&(frontright!=NULL&&frontright->wallType)&&(top!=NULL&&(top->wallType||top->floorType)))) //Block is covered by sides and top, moving on
- continue;
- }
- b->Draw();
- /*al_flip_display(); // Slow Debug drawing: You can see every Block as its beeing drawn very useful =)
- b->Draw();
- al_flip_display();*/
- }
- }
- }
- al_hold_bitmap_drawing(false);
- al_hold_bitmap_drawing(true);
- for(int32_t vsx=1; vsx < vsxmax; vsx++)
- {
- for(int32_t vsy=1; vsy < vsymax; vsy++)
- {
- Block *b = getBlockLocal(vsx,vsy,vsz);
- if(b)
- {
- b->Drawcreaturetext();
- //while(!key[KEY_SPACE]) ;
- //rest(100);
- }
- }
- }
- al_hold_bitmap_drawing(false);
- }
- if(config.showRenderStatus)
- SetTitle("Stonesense");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement