int main(int argc, char **argv) { if (!glfwInit()) { printf("Failed to init GLFW."); return -1; } glfwSetErrorCallback(errorcb); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1); GLFWwindow* window = glfwCreateWindow(1024, 768, "scanner", NULL, NULL); if (!window) { glfwTerminate(); return -1; } glfwSetKeyCallback(window, key); glfwSetCharCallback(window, charevent); glfwSetCursorPosCallback(window, cursorpos); glfwSetMouseButtonCallback(window, mousebutton); glfwSetScrollCallback(window, scrollevent); glfwMakeContextCurrent(window); glfwSwapInterval(1); // vsync glewExperimental = GL_TRUE; if(glewInit() != GLEW_OK) { printf("Could not init glew.\n"); return -1; } glGetError(); // GLEW generates GL error because it calls glGetString(GL_EXTENSIONS). struct NVGcontext* vg = nvgCreateGL2(NVG_ANTIALIAS); if (vg == NULL) { printf("Could not init nanovg.\n"); return -1; } UIcontext *uictx = uiCreateContext(4096, 1 << 20); uiMakeCurrent(uictx); uiSetHandler(ui_handler); uiInit(vg, "oui-blendish/DejaVuSans.ttf", "oui-blendish/blender_icons16.png"); gui_init(vg); glfwSetTime(0); while (!glfwWindowShouldClose(window)) { double mx, my; glfwGetCursorPos(window, &mx, &my); int winWidth, winHeight; glfwGetWindowSize(window, &winWidth, &winHeight); int fbWidth, fbHeight; glfwGetFramebufferSize(window, &fbWidth, &fbHeight); float pxRatio = (float)fbWidth / (float)winWidth; gui_frame(vg, winWidth, winHeight, pxRatio, glfwGetTime()); glfwSwapBuffers(window); glfwPollEvents(); } gui_quit(vg); uiDestroyContext(uictx); nvgDeleteGL2(vg); glfwTerminate(); return 0; }
bool WabbitemuApp::OnInit() { wxImage::AddHandler(new wxPNGHandler); //stolen from the windows version ParseCommandLineArgs(); memset(frames, 0, sizeof(frames)); LPCALC lpCalc = calc_slot_new(); LoadSettings(lpCalc); WabbitemuFrame *frame; int result = rom_load(lpCalc, lpCalc->rom_path); if (result == TRUE) { frame = gui_frame(lpCalc); } else { calc_slot_free(lpCalc); BOOL loadedRom = FALSE; if (parsedArgs.num_rom_files > 0) { for (int i = 0; i < parsedArgs.num_rom_files; i++) { if (rom_load(lpCalc, parsedArgs.rom_files[i])) { gui_frame(lpCalc); loadedRom = TRUE; break; } } } if (!loadedRom) { bool success = DoRomWizard(); if (!success) { return FALSE; } } } LoadCommandlineFiles((INT_PTR) lpCalc, LoadToLPCALC); timer = new wxTimer(); timer->Connect(wxEVT_TIMER, (wxObjectEventFunction) &WabbitemuApp::OnTimer); timer->Start(TPF, false); return TRUE; }
int combat_frame() { if (!combat_mode) return 0; if (active_character->action != CHARACTER_STAY) { character_frame(active_character); map_display(0, 0); goto end_combat_frame; } if (gui_mode() == DIALOG_MESSAGE) { gui_frame(); if (gui_mode() != DIALOG_MESSAGE) { if (combat_who_attacked->life <= 0 && game_in_party(combat_who_attacked)) gui_player_dead(combat_who_attacked, 0); combat_character_finished(); } goto end_combat_frame; } if (combat_attack_animation) { combat_attack_animation = 0; /* message switches to next player */ gui_message(combat_result_text, 1); goto end_combat_frame; } if (game_in_party(active_character)) { if (gui_frame() != MAIN_MENU) goto end_combat_frame; if (game_get_moving()) combat_player_move(); } else { combat_enemy_move(); if (active_character->x < 0) goto end_combat_frame; } if (!combat_attack_animation && active_character->ap <= 0) combat_character_finished(); map_display(0, 0); end_combat_frame: map_animate_frame(); return combat_mode; }