main() { int gr_mkmx, gr_mkmy; int gr_mkmstate, gr_mkkstate; int tmpx, tmpy; int tmpx1, tmpy1; int tmpx2, tmpy2; int index, rgb_in[3]; int draw; appl_init(); phys_handle = graf_handle(&gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox); wind_get(0, WF_WORKXYWH, &xdesk, &ydesk, &wdesk, &hdesk); open_vwork(); wi_handle = wind_create(0x0040&0x0080, xdesk, ydesk, wdesk, hdesk); graf_mouse(3, 0x0L); vswr_mode(handle, 3); graf_mkstate(&gr_mkmx, &gr_mkmy, &gr_mkmstate, &gr_mkkstate); while(!(0x0002&gr_mkmstate)) { graf_mkstate(&gr_mkmx, &gr_mkmy, &gr_mkmstate, &gr_mkkstate); if (0x0001&gr_mkmstate) { tmpy = gr_mkmy; tmpx = gr_mkmx; graf_mkstate(&gr_mkmx, &gr_mkmy, &gr_mkmstate, &gr_mkkstate); graf_mouse(M_OFF, 0x0L); tmpy1 = gr_mkmy; tmpx1 = gr_mkmx; drawframe(tmpx, tmpy, tmpx1, tmpy1); graf_mouse(M_ON, 0x0L); while (0x0001&gr_mkmstate) { graf_mkstate(&gr_mkmx, &gr_mkmy, &gr_mkmstate, &gr_mkkstate); if (((tmpx1 != gr_mkmx) || (tmpy1 != gr_mkmy)) && (0x0001&gr_mkmstate)) { graf_mouse(M_OFF, 0x0L); drawframe(tmpx, tmpy, tmpx1, tmpy1); drawframe(tmpx, tmpy, gr_mkmx, gr_mkmy); graf_mouse(M_ON, 0x0L); tmpy1 = gr_mkmy; tmpx1 = gr_mkmx; } } graf_mouse(M_OFF, 0x0L); drawframe(tmpx, tmpy, tmpx1, tmpy1); graf_mouse(M_ON, 0x0L); } } wind_delete(wi_handle); v_clsvwk(handle); appl_exit(); }
void resizecb(GLFWwindow* window, int width, int height) { // Update and render NSVG_NOTUSED(width); NSVG_NOTUSED(height); drawframe(window); }
void drawinputdlg (char *title1, char *title2, char *msg1, int textwidth) { int left, top, width, height, tleft, ttop, twidth, theight; int shadowx = 2, shadowy = 1; int swidth = 80, sheight = 25; twidth = textwidth + 2; theight = 3; width = twidth + 4; height = theight + 7; left = (swidth - (width + shadowx) + 1) / 2; top = (sheight - 2 - (height + shadowy) + 1) / 2 + 2; tleft = left + 2; ttop = top + 2; call0x10 (3, 0, 0, 0); /* set mode */ fillchar (0x13, ' ', 0, 0, swidth, sheight); /* paint blue */ printstr (0x1B, title1, 1, 0); /* title */ fillchar (0x1B, 0xC4, 1, 1, swidth - 2, 1); /* line */ drawdlgframe (left, top, width, height); /* frame */ printstr (0x79, title2, left + (width - strlen (title2)) / 2, top); printstr (0x74, msg1, left + 2, top + 1); drawframe (0x70, 0x7F, tleft, ttop, twidth, theight); printstr (0x1F, "< >", left + (width - 8) / 2, top + height - 2); printstr (0x1F, "O", left + (width - 8) / 2 + 3, top + height - 2); printstr (0x1E, "K", left + (width - 8) / 2 + 4, top + height - 2); printstr (0x70, " ", tleft + 1, ttop + 1); }
void draw(int dopts, int dovb) { register i, j; fprint(1, "open\n"); fprint(1, "range %d %d %d %d\n", b.prect.min.x-INCH, b.prect.min.y-INCH, b.prect.max.x+INCH, b.prect.max.y+INCH); fprint(1, ".color FCW\n"); fprint(1, ".color P6\n"); if (ruled) { drawrule(); drawalign(); } if (framed) drawframe(); symtraverse(S_CHIP, drawchip); if(dopts) pintraverse(drawpin); if(dovb) for(i = 0; i < 6; i++) for(j = 0; j < b.v[i].npins; j++) drawvbpin(&b.v[i].pins[j], i); fprint(1, "close\n"); }
byte * ANIM_DrawFrame (int32 framenumber) { int32 cnt; CheckAnimStarted ( "DrawFrame" ); if ((anim->currentframe != -1) && (anim->currentframe<=framenumber)) { for (cnt = anim->currentframe; cnt < framenumber; cnt++) drawframe (cnt); } else { for (cnt = 0; cnt < framenumber; cnt++) drawframe (cnt); } anim->currentframe = framenumber; return anim->imagebuffer; }
// 表示開始 // std::string CWindows::startdialog(bool frame) { m_this = newwin(m_winh, adjx(m_winw), m_winy, adjx(m_winx)); refresh(); if (frame) drawframe(); drawwin(); keyloop(); return (m_returnstr); }
// 表示開始 // int CWindows::startwin(bool frame) { m_this = newwin(m_winh, adjx(m_winw), m_winy, adjx(m_winx)); refresh(); if (frame) drawframe(); drawwin(); keyloop(); return (m_return); }
void drawdlgframe (int left, int top, int width, int height) { int right = left + width - 1; int bottom = top + height - 1; fillchar (0x00, ' ', left + 2, top + 1, width, height); fillchar (0x70, ' ', left, top, width, height); drawframe (0x7F, 0x70, left, top, width, height); fillchar (0x7F, 0xC3, left, bottom - 2, 1, 1); fillchar (0x7F, 0xC4, left + 1, bottom - 2, width - 2, 1); fillchar (0x70, 0xB4, right, bottom - 2, 1, 1); }
uint8_t * ANIM_DrawFrame(int32_t framenumber) { int32_t cnt = anim->currentframe; // handle first play and looping or rewinding if (cnt < 0 || cnt > framenumber) cnt = 0; do drawframe(cnt++); while (cnt < framenumber); anim->currentframe = framenumber; return anim->imagebuffer; }
int main() { GLFWwindow* window; const GLFWvidmode* mode; if (!glfwInit()) return -1; mode = glfwGetVideoMode(glfwGetPrimaryMonitor()); window = glfwCreateWindow(mode->width - 40, mode->height - 80, "Nano SVG", NULL, NULL); if (!window) { printf("Could not open window\n"); glfwTerminate(); return -1; } glfwSetFramebufferSizeCallback(window, resizecb); glfwMakeContextCurrent(window); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); g_image = nsvgParseFromFile("../example/nano.svg", "px", 96.0f); if (g_image == NULL) { printf("Could not open SVG image.\n"); glfwTerminate(); return -1; } while (!glfwWindowShouldClose(window)) { drawframe(window); glfwPollEvents(); } nsvgDelete(g_image); glfwTerminate(); return 0; }
/* * gameloop -- main loop of game * Called by gameproc; runs in gameThread. * Parameter: rsp_static_addr, the R4300 address where the * rsp_static segment was loaded */ static void gameloop(char *rsp_static_addr) { int oddframe = 0; /* Odd or even rendered frame? Start with even. */ int firstframe = 1; /* First frame? */ dynamic_stuff *generate; /* Dynamic info we're generating now */ Gfx *glistp0; /* Start of this frame's dynamic display list */ Gfx *glistp; /* Current position in dynamic display list */ OSTask *gentask; /* Task we're generating */ float t; /* Weight of 1st set of morph verticies */ int dir; /* Direction in which we're morphing */ int pausecnt; /* Countdown for "stickiness" at morph extremes */ t = 0.0; dir = 1; pausecnt = 0; while (1) { /* Start task on RSP, built in previous iteration of loop. */ if (!firstframe) osSpTaskStart(gentask); /* * Set up pointers to dynamic stuff. We're always generating one set * of dynamic data and drawing another. */ generate = &(dynamic[(oddframe ? 0 : 1)]); /* glist portion of generated dynamic data */ glistp0 = &(generate->glist[0]); glistp = glistp0; /* This one will be incremented as list is built */ /* * Tell RSP where each segment is */ gSPSegment(glistp++, 0, 0x0); /* Physical address segment */ /* Static segment (mapping never changes) */ gSPSegment(glistp++, STATIC_SEG, OS_K0_TO_PHYSICAL(rsp_static_addr)); /* Dynamic segment (mapping changes every frame) */ gSPSegment(glistp++, DYNAMIC_SEG, OS_K0_TO_PHYSICAL(generate)); /* RSP and RDP setup, and screen clear */ gSPDisplayList(glistp++, rspinit_dl); gSPDisplayList(glistp++, rdpinit_dl); #ifdef FB32BIT gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, OS_K0_TO_PHYSICAL(oddframe ? cfb_A : cfb_B)); #else gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, OS_K0_TO_PHYSICAL(oddframe ? cfb_A : cfb_B)); #endif gSPDisplayList(glistp++, scrnclr_dl); /* Must set color image again after zbuffer clear */ #ifdef FB32BIT gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, OS_K0_TO_PHYSICAL(oddframe ? cfb_A : cfb_B)); #else gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, OS_K0_TO_PHYSICAL(oddframe ? cfb_A : cfb_B)); #endif /* Set Z-buffer */ gDPSetDepthImage(glistp++, OS_K0_TO_PHYSICAL(zbuffer)); /* * Matrix setup, and call display list that does real work */ drawframe(generate, &glistp, t); /* * Put an END on the top-level display list, and check that we * haven't overflowed the buffer. */ gDPFullSync(glistp++); /* Only need this if you want 'accurate' SP done? */ gSPEndDisplayList(glistp++); #ifdef DEBUG if ((int)(glistp - glistp0) > GLIST_SIZE) { /* does this check work?? */ osSyncPrintf("*** GLIST OVERFLOW ***\n"); /* Could quit here or something */ } #endif /* Update morph parameter t */ if (pausecnt == 0) { t += dir*(1.0/60.0); /* A full 60 frames to do the morph */ if (t < 0.0) {t = 0.0; dir = 1; pausecnt = 60;} if (t > 1.0) {t = 1.0; dir = -1; pausecnt = 60;} } else { pausecnt--; } /* * Build graphics task * Note that all addresses are KSEG0, even if used by the RSP. * Conversion is done by the task routines. */ gentask = &(task[oddframe ? 0 : 1]); gentask->t.type = M_GFXTASK; gentask->t.flags = 0x0; gentask->t.ucode_boot = (u64*) rspbootTextStart; gentask->t.ucode_boot_size = ((int)rspbootTextEnd - (int)rspbootTextStart); gentask->t.ucode = (u64*) gspF3DEX2_xbusTextStart; /* use XBUS */ gentask->t.ucode_data = (u64*) gspF3DEX2_xbusDataStart; gentask->t.ucode_size = 4096; gentask->t.ucode_data_size = 2048; gentask->t.dram_stack = (u64*) dram_stack; gentask->t.dram_stack_size = SP_DRAM_STACK_SIZE64; gentask->t.output_buff = (u64*) NULL; gentask->t.output_buff_size= (u64*) NULL; gentask->t.yield_data_ptr = (u64*) NULL; /* Graphics only - no yielding */ gentask->t.yield_data_size = 0x0; gentask->t.data_ptr = (u64*) glistp0; gentask->t.data_size = ((int) glistp - (int) glistp0); /* * Flush the whole cache. Should just do parts of it. */ osWritebackDCacheAll(); if (!firstframe) { /* Wait for task completion (message from RDP) */ osRecvMesg(&RDPDoneMessageQ, NULL, OS_MESG_BLOCK); /* * Specify frame buffer to be displayed starting at next retrace. * We display the one that we've just finished rendering. */ osViSwapBuffer(oddframe ? cfb_B : cfb_A); } /* * Wait for the retrace before rendering next frame * (otherwise we might overwrite the frame which is being displayed). * But first, make sure that the retrace queue is empty in case we * took too long to render the last frame. */ if (MQ_IS_FULL(&RetraceMessageQ)) osRecvMesg(&RetraceMessageQ, NULL, OS_MESG_NOBLOCK); osRecvMesg(&RetraceMessageQ, NULL, OS_MESG_BLOCK); /* Switch to our other set of variables */ oddframe ^= 1; /* No longer the first frame */ firstframe = 0; } /* while(1) */ } /* gameloop */
// ウィンドゥ内部をクリアする(罫線は残す) // void CWindows::clearwin() { werase(m_this); drawframe(); }