void player_draw(){ //need to add other equipment entity_draw(player,player->position.x,player->position.y); player_draw_equip(); hud_draw(graphics_get_player_cam(),player->health, player->maxhealth, player->stamina, player->stamina); }
void view_loop_draw(int tick) { if (tick<view.time.draw_tick) return; view.time.draw_tick=tick+view.time.draw_time; // texture setup map_setup_animated_textures(&map,tick); map_mesh_poly_run_shifts(&map,tick); // start frame if (!fog_solid_on()) { gl_frame_start(NULL); } else { gl_frame_start(&map.fog.col); // is obscuring fog on, then background = fog color } // draw frame view_draw(tick); hud_draw(tick); radar_draw(tick); network_draw(tick); gl_frame_end(); view.fps.count++; }
/** * Swap front and back color buffers and have winsys display front buffer. * If there's no front color buffer no swap actually occurs. */ PUBLIC void XMesaSwapBuffers( XMesaBuffer b ) { XMesaContext xmctx = XMesaGetCurrentContext(); /* Need to draw HUD before flushing */ if (xmctx && xmctx->hud) { struct pipe_resource *back = xmesa_get_framebuffer_resource(b->stfb, ST_ATTACHMENT_BACK_LEFT); hud_draw(xmctx->hud, back); } if (xmctx && xmctx->xm_buffer == b) { xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL); } xmesa_swap_st_framebuffer(b->stfb); }
BOOL APIENTRY DrvSwapBuffers(HDC hdc) { struct stw_context *ctx; struct stw_framebuffer *fb; if (!stw_dev) return FALSE; fb = stw_framebuffer_from_hdc( hdc ); if (fb == NULL) return FALSE; if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) { stw_framebuffer_unlock(fb); return TRUE; } ctx = stw_current_context(); if (ctx) { if (ctx->hud) { /* Display the HUD */ struct pipe_resource *back = stw_get_framebuffer_resource(fb->stfb, ST_ATTACHMENT_BACK_LEFT); if (back) { hud_draw(ctx->hud, back); } } if (ctx->current_framebuffer == fb) { /* flush current context */ ctx->st->flush(ctx->st, ST_FLUSH_END_OF_FRAME, NULL); } } if (stw_dev->swap_interval != 0) { wait_swap_interval(fb); } return stw_st_swap_framebuffer_locked(hdc, fb->stfb); }
void draw() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); world_draw(my_world); hud_draw(my_hud); }
/** * DRI2 flush extension, the flush_with_flags function. * * \param context the context * \param drawable the drawable to flush * \param flags a combination of _DRI2_FLUSH_xxx flags * \param throttle_reason the reason for throttling, 0 = no throttling */ void dri_flush(__DRIcontext *cPriv, __DRIdrawable *dPriv, unsigned flags, enum __DRI2throttleReason reason) { struct dri_context *ctx = dri_context(cPriv); struct dri_drawable *drawable = dri_drawable(dPriv); unsigned flush_flags; boolean swap_msaa_buffers = FALSE; if (!ctx) { assert(0); return; } if (drawable) { /* prevent recursion */ if (drawable->flushing) return; drawable->flushing = TRUE; } else { flags &= ~__DRI2_FLUSH_DRAWABLE; } /* Flush the drawable. */ if ((flags & __DRI2_FLUSH_DRAWABLE) && drawable->textures[ST_ATTACHMENT_BACK_LEFT]) { struct pipe_context *pipe = ctx->st->pipe; if (drawable->stvis.samples > 1 && reason == __DRI2_THROTTLE_SWAPBUFFER) { /* Resolve the MSAA back buffer. */ dri_pipe_blit(ctx->st->pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT], drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]); if (drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT] && drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]) { swap_msaa_buffers = TRUE; } /* FRONT_LEFT is resolved in drawable->flush_frontbuffer. */ } dri_postprocessing(ctx, drawable, ST_ATTACHMENT_BACK_LEFT); if (ctx->hud) { hud_draw(ctx->hud, drawable->textures[ST_ATTACHMENT_BACK_LEFT]); } pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]); } flush_flags = 0; if (flags & __DRI2_FLUSH_CONTEXT) flush_flags |= ST_FLUSH_FRONT; if (reason == __DRI2_THROTTLE_SWAPBUFFER) flush_flags |= ST_FLUSH_END_OF_FRAME; /* Flush the context and throttle if needed. */ if (dri_screen(ctx->sPriv)->throttling_enabled && drawable && (reason == __DRI2_THROTTLE_SWAPBUFFER || reason == __DRI2_THROTTLE_FLUSHFRONT)) { /* Throttle. * * This pulls a fence off the throttling queue and waits for it if the * number of fences on the throttling queue has reached the desired * number. * * Then flushes to insert a fence at the current rendering position, and * pushes that fence on the queue. This requires that the st_context_iface * flush method returns a fence even if there are no commands to flush. */ struct pipe_screen *screen = drawable->screen->base.screen; struct pipe_fence_handle *fence; fence = swap_fences_pop_front(drawable); if (fence) { (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); screen->fence_reference(screen, &fence, NULL); } ctx->st->flush(ctx->st, flush_flags, &fence); if (fence) { swap_fences_push_back(drawable, fence); screen->fence_reference(screen, &fence, NULL); } } else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) { ctx->st->flush(ctx->st, flush_flags, NULL); } if (drawable) { drawable->flushing = FALSE; } /* Swap the MSAA front and back buffers, so that reading * from the front buffer after SwapBuffers returns what was * in the back buffer. */ if (swap_msaa_buffers) { struct pipe_resource *tmp = drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT]; drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT] = drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]; drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT] = tmp; /* Now that we have swapped the buffers, this tells the state * tracker to revalidate the framebuffer. */ p_atomic_inc(&drawable->base.stamp); } }
static INLINE HRESULT present( struct NineSwapChain9 *This, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion, DWORD dwFlags ) { struct NineDevice9 *device = This->base.device; struct pipe_resource *resource; HRESULT hr; RGNDATA *rgndata; RECT rect; struct pipe_blit_info blit; /* get a real backbuffer handle from the windowing system */ hr = This->actx->resource_from_present(This->actx, This->screen, This->present, hDestWindowOverride, pDestRect, &rect, &rgndata, &resource); if (FAILED(hr)) { return hr; } else if (hr == D3DOK_WINDOW_OCCLUDED) { /* if we present, nothing will show, so don't present */ return D3D_OK; } DBG(">>>\npresent: This=%p pSourceRect=%p pDestRect=%p " "pDirtyRegion=%p rgndata=%p\n", This, pSourceRect, pDestRect, pDirtyRegion, rgndata); if (pSourceRect) DBG("pSourceRect = (%u..%u)x(%u..%u)\n", pSourceRect->left, pSourceRect->right, pSourceRect->top, pSourceRect->bottom); if (pDestRect) DBG("pDestRect = (%u..%u)x(%u..%u)\n", pDestRect->left, pDestRect->right, pDestRect->top, pDestRect->bottom); if (rgndata) { /* TODO */ blit.dst.resource = NULL; } else { struct pipe_surface *suf = NineSurface9_GetSurface(This->buffers[0], 0); blit.dst.resource = resource; blit.dst.level = 0; blit.dst.format = resource->format; blit.dst.box.z = 0; blit.dst.box.depth = 1; if (pDestRect) { rect_to_pipe_box_xy_only(&blit.dst.box, pDestRect); blit.dst.box.x += rect.left; blit.dst.box.y += rect.top; if (u_box_clip_2d(&blit.dst.box, &blit.dst.box, rect.right, rect.bottom) > 0) { DBG("Dest region clipped.\n"); return D3D_OK; } } else { rect_to_pipe_box_xy_only(&blit.dst.box, &rect); } blit.src.resource = suf->texture; blit.src.level = This->buffers[0]->level; blit.src.format = blit.src.resource->format; blit.src.box.z = 0; blit.src.box.depth = 1; if (pSourceRect) { rect_to_pipe_box_xy_only(&blit.src.box, pSourceRect); u_box_clip_2d(&blit.src.box, &blit.src.box, suf->width, suf->height); } else { blit.src.box.x = 0; blit.src.box.y = 0; blit.src.box.width = suf->width; blit.src.box.height = suf->height; } blit.mask = PIPE_MASK_RGBA; blit.filter = PIPE_TEX_FILTER_NEAREST; blit.scissor_enable = FALSE; blit.alpha_blend = FALSE; /* blit (and possibly stretch/convert) pixels from This->buffers[0] to * emusurf using u_blit. Windows appears to use NEAREST */ DBG("Blitting (%u..%u)x(%u..%u) to (%u..%u)x(%u..%u).\n", blit.src.box.x, blit.src.box.x + blit.src.box.width, blit.src.box.y, blit.src.box.y + blit.src.box.height, blit.dst.box.x, blit.dst.box.x + blit.dst.box.width, blit.dst.box.y, blit.dst.box.y + blit.dst.box.height); This->pipe->blit(This->pipe, &blit); } if (device->cursor.software && device->cursor.visible && device->cursor.w && blit.dst.resource) { blit.src.resource = device->cursor.image; blit.src.level = 0; blit.src.format = device->cursor.image->format; blit.src.box.x = 0; blit.src.box.y = 0; blit.src.box.width = device->cursor.w; blit.src.box.height = device->cursor.h; ID3DPresent_GetCursorPos(This->present, &device->cursor.pos); /* NOTE: blit messes up when box.x + box.width < 0, fix driver */ blit.dst.box.x = MAX2(device->cursor.pos.x, 0) - device->cursor.hotspot.x; blit.dst.box.y = MAX2(device->cursor.pos.y, 0) - device->cursor.hotspot.y; blit.dst.box.width = blit.src.box.width; blit.dst.box.height = blit.src.box.height; DBG("Blitting cursor(%ux%u) to (%i,%i).\n", blit.src.box.width, blit.src.box.height, blit.dst.box.x, blit.dst.box.y); blit.alpha_blend = TRUE; This->pipe->blit(This->pipe, &blit); } if (device->hud && resource) { hud_draw(device->hud, resource); /* XXX: no offset */ /* HUD doesn't clobber stipple */ NineDevice9_RestoreNonCSOState(device, ~0x2); } This->pipe->flush(This->pipe, NULL, PIPE_FLUSH_END_OF_FRAME); /* really present the frame */ hr = ID3DPresent_Present(This->present, dwFlags); pipe_resource_reference(&resource, NULL); if (FAILED(hr)) { return hr; } return D3D_OK; }