///////////////////////////////////////////////////////////////// // initialize // Initialize this application when it starts. Disable firmware, // set the video mode and colours, and initialize map and cursor. // void initialize() { u8 *pmem; // Disable firmware to prevent it from restoring video mode or // interfering with our drawString functions cpct_disableFirmware(); // Set the video Mode to 1 (320x200, 4 colours) cpct_setVideoMode(1); // Use default colours except for palette index 0 (background). // Default colours are (Blue, Yellow, Cyan, Red), let's use // (Black, Yellow, Cyan, Red). Change only colour 0 and border. cpct_setPALColour(0, 0x14); cpct_setBorder(0x14); // Initialize Base Pointer of the map in video memory. This is // the place where the map will start to be drawn (0,0). This // location is (MAP_START_X, MAP_START_Y) with respect to CPCT_VMEM_START. pmem = cpct_getScreenPtr(CPCT_VMEM_START, MAP_START_X, MAP_START_Y); map_setBaseMem(pmem); // Set cursor at the top-left corner of the screen cursor_setLocation(0, 0); // Draw messages with instructions, the map and the cursor drawMessages(); map_draw(); cursor_draw(); }
static void draw_cursor(struct duplicator_capture *capture) { cursor_draw(&capture->cursor_data, -capture->x, -capture->y, 1.0f, 1.0f, capture->rot % 180 == 0 ? capture->width : capture->height, capture->rot % 180 == 0 ? capture->height : capture->width); }
static void ShutdownPs() { SAFE_DELETE(g_GUI); UnloadHotkeys(); // disable the special Windows cursor, or free textures for OGL cursors cursor_draw(g_VFS, 0, g_mouse_x, g_yres-g_mouse_y, false); }
static void keyboard_move (gint dx, gint dy) { if (kb_visible) cursor_erase (); kb_visible = TRUE; kb_xloc += dx; kb_yloc += dy; kb_xloc = (kb_xloc + board_width) % board_width; kb_yloc = (kb_yloc + board_height) % board_height; cursor_draw (kb_xloc, kb_yloc); select_cells (); }
///////////////////////////////////////////////////////////////// // checkUserInputAndPerformActions // scans the keyboard and checks whether the user has pressed // any action key or not. When the user presses an action key, // the corresponding action is performed. // void checkUserInputAndPerformActions() { // Scan the keyboard for user keypresses cpct_scanKeyboard(); // Perform checks only when the user has // pressed at least one key if(cpct_isAnyKeyPressed()) { // Get current (x,y) coordinates of the cursor u8 x = cursor_getX(); u8 y = cursor_getY(); // Check if the key pressed is one of the valid keys and // if sanity conditions are met // CURSOR_UP or CURSOR_DOWN (Only one at a time) // Perform required action, if the cursor is not at the // edge of the map already. if (cpct_isKeyPressed(Key_CursorUp) && y > 0) cursor_move(DIR_UP); else if (cpct_isKeyPressed(Key_CursorDown) && y < MAP_HEIGHT-1) cursor_move(DIR_DOWN); // CURSOR_LEFT or CURSOR_RIGHT (Only one at a time) // Perform required action, if the cursor is not at the // edge of the map already. if (cpct_isKeyPressed(Key_CursorLeft) && x > 0) cursor_move(DIR_LEFT); else if (cpct_isKeyPressed(Key_CursorRight) && x < MAP_WIDTH-1) cursor_move(DIR_RIGHT); // SPACE (change tile) or ESCAPE (clear map) // Perform one of these actions if corresponding key is pressed if (cpct_isKeyPressed(Key_Space)) map_changeTile(x, y); else if (cpct_isKeyPressed(Key_Esc)) map_clear(); // Always redraw the cursor after any of the above actions cursor_draw(); } }
void Render() { PROFILE3("render"); if (g_SoundManager) g_SoundManager->IdleTask(); ogl_WarnIfError(); g_Profiler2.RecordGPUFrameStart(); ogl_WarnIfError(); // prepare before starting the renderer frame if (g_Game && g_Game->IsGameStarted()) g_Game->GetView()->BeginFrame(); if (g_Game) g_Renderer.SetSimulation(g_Game->GetSimulation2()); // start new frame g_Renderer.BeginFrame(); ogl_WarnIfError(); if (g_Game && g_Game->IsGameStarted()) g_Game->GetView()->Render(); ogl_WarnIfError(); g_Renderer.RenderTextOverlays(); if (g_DoRenderGui) g_GUI->Draw(); ogl_WarnIfError(); // If we're in Atlas game view, render special overlays (e.g. editor bandbox) if (g_AtlasGameLoop && g_AtlasGameLoop->view) { g_AtlasGameLoop->view->DrawOverlays(); ogl_WarnIfError(); } // Text: glDisable(GL_DEPTH_TEST); g_Console->Render(); ogl_WarnIfError(); if (g_DoRenderLogger) g_Logger->Render(); ogl_WarnIfError(); // Profile information g_ProfileViewer.RenderProfile(); ogl_WarnIfError(); // Draw the cursor (or set the Windows cursor, on Windows) if (g_DoRenderCursor) { PROFILE3_GPU("cursor"); CStrW cursorName = g_CursorName; if (cursorName.empty()) { cursor_draw(g_VFS, NULL, g_mouse_x, g_yres-g_mouse_y, false); } else { bool forceGL = false; CFG_GET_VAL("nohwcursor", forceGL); #if CONFIG2_GLES #warning TODO: implement cursors for GLES #else // set up transform for GL cursor glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); CMatrix3D transform; transform.SetOrtho(0.f, (float)g_xres, 0.f, (float)g_yres, -1.f, 1000.f); glLoadMatrixf(&transform._11); #endif #if OS_ANDROID #warning TODO: cursors for Android #else if (cursor_draw(g_VFS, cursorName.c_str(), g_mouse_x, g_yres-g_mouse_y, forceGL) < 0) LOGWARNING("Failed to draw cursor '%s'", utf8_from_wstring(cursorName)); #endif #if CONFIG2_GLES #warning TODO: implement cursors for GLES #else // restore transform glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); #endif } } glEnable(GL_DEPTH_TEST); g_Renderer.EndFrame(); PROFILE2_ATTR("draw calls: %d", (int)g_Renderer.GetStats().m_DrawCalls); PROFILE2_ATTR("terrain tris: %d", (int)g_Renderer.GetStats().m_TerrainTris); PROFILE2_ATTR("water tris: %d", (int)g_Renderer.GetStats().m_WaterTris); PROFILE2_ATTR("model tris: %d", (int)g_Renderer.GetStats().m_ModelTris); PROFILE2_ATTR("overlay tris: %d", (int)g_Renderer.GetStats().m_OverlayTris); PROFILE2_ATTR("blend splats: %d", (int)g_Renderer.GetStats().m_BlendSplats); PROFILE2_ATTR("particles: %d", (int)g_Renderer.GetStats().m_Particles); ogl_WarnIfError(); g_Profiler2.RecordGPUFrameEnd(); ogl_WarnIfError(); }
void _motionnotify(XEvent *ev) { #ifdef module_cursor XMotionEvent *e = &ev->xmotion; cursor_draw(e->x, e->y); #endif }
int render_pdf_page(int pdf, int pg, Window win, bool fixed) { if (pg >= _pdf[pdf].npage) return 1; cairo_t *ctx; cairo_surface_t *s, *img; double pdfw, pdfh, scx, scy; int ig; unsigned int uig, ww, wh; /* get page size and scale to window */ PopplerPage *page = poppler_document_get_page(_pdf[pdf].doc, pg); poppler_page_get_size(page, &pdfw, &pdfh); XGetGeometry(dpy, win, (Window *) &ig, &ig, &ig, &ww, &wh, &uig, &uig); scx = ww / pdfw; scy = wh / pdfh; //if (pdf == 0) { _ww = ww; _wh = wh; } if (fixed) { /* adjust window size for fixed aspect ratio */ scx = (scx < scy ? (scy=scx) : scy); ww = scx * pdfw + 0.5; wh = scy * pdfh + 0.5; XResizeWindow(dpy, win, ww, wh); } /* create background pixmap and render page to it */ Pixmap pix = XCreatePixmap(dpy, win, ww, wh, DefaultDepth(dpy,scr)); s = cairo_xlib_surface_create(dpy, pix, DefaultVisual(dpy,scr), ww, wh); ctx = cairo_create(s); cairo_surface_destroy(s); cairo_scale(ctx, scx, scy); cairo_set_source_rgb(ctx, 1, 1, 1); cairo_paint(ctx); poppler_page_render(page, ctx); cairo_destroy(ctx); /* if this is the fader window, fade in */ if (win == _fade_win) { /* hide cursor for fade transitions */ #ifdef module_cursor bool pre = cursor_visible(query); cursor_visible(false); #endif /* get image, set up context, and render page */ img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ww, wh); ctx = cairo_create(img); cairo_scale(ctx, scx, scy); cairo_set_source_rgb(ctx, 1, 1, 1); cairo_paint(ctx); poppler_page_render(page, ctx); cairo_destroy(ctx); /* get window surface, reset context to draw img to window */ s = cairo_xlib_surface_create(dpy, win, DefaultVisual(dpy,scr), ww, wh); ctx = cairo_create(s); cairo_surface_destroy(s); cairo_set_source_surface(ctx, img, 0, 0); // memory leak?! /* fade in */ for (ig = _fade_steps; ig; --ig) { cairo_paint_with_alpha(ctx, 1 / (float) ig); // memory leak?! //XFlush(dpy); usleep(200); } /* clean up */ cairo_destroy(ctx); cairo_surface_destroy(img); #ifdef module_cursor cursor_visible(pre); #endif } g_object_unref(page); /* set the pixmap to be the window background */ XSetWindowBackgroundPixmap(dpy, win, pix); XFreePixmap(dpy, pix); XClearWindow(dpy, win); #ifdef module_cursor if (pdf == 0) cursor_draw(-1, -1); #endif return 0; }