//---------- void ofxSplashScreen::begin(float minimumDuration) { if (!this->image.isAllocated()) { ofLogError("ofxSplashScreen") << "Cannot show splash screen since no image has been loaded"; return; } this->endTime = ofGetElapsedTimef() + minimumDuration; this->appWindow = glfwGetCurrentContext(); glfwHideWindow(this->appWindow); glfwWindowHint(GLFW_DECORATED, GL_FALSE); this->splashScreenWindow = glfwCreateWindow(this->image.getWidth(), this->image.getHeight(), "ofxSplashScreen", NULL, this->appWindow); glfwSetWindowPos(this->splashScreenWindow, (ofGetScreenWidth() - this->image.getWidth()) / 2.0f, (ofGetScreenHeight() - this->image.getHeight()) / 2.0f); glfwWindowHint(GLFW_DECORATED, GL_TRUE); glfwMakeContextCurrent(this->splashScreenWindow); //set the drawing matrices to normalised coordinates ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadIdentityMatrix(); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadIdentityMatrix(); //draw the images ofClear(0,0,0); this->image.update(); this->image.draw(-1,-1,2,2); glfwSwapBuffers(this->splashScreenWindow); glFlush(); //set the context back to main for rest of setup glfwMakeContextCurrent(this->appWindow); ofSetupScreen(); }
static void WIN_Quit( DaoProcess *proc, DaoValue *p[], int N ) { DaoxWindow *self = (DaoxWindow*) p[0]; self->visible = 0; glfwHideWindow( self->handle ); DaoxContext_Clear( self->context ); }
void Window::SetVisibility(const bool visible) { if (visible) { glfwShowWindow(window); } else { glfwHideWindow(window); } }
// -------------------------------------------------------------------------------------------------------------------- void window::hide() { if (is_open()) { glfwHideWindow(_internal->_window); } }
void AlloyContext::setOffScreenVisible(bool vis) { if (vis) { glfwShowWindow(offscreenWindow); } else { glfwHideWindow(offscreenWindow); } }
void app_window_hide() { ASSERT(g_app); ASSERT(g_app->wnd); glfwHideWindow(g_app->wnd); }
void Window::hide() { if (!m_window) return; glfwHideWindow(m_window); }
int GlfwApplication::Run() { CHECK_STATE(glfwInit() != -1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if (minimized) { window = glfwCreateWindow(kMinimizedWidth, kMinimizedHeight, title.c_str(), nullptr, nullptr); } else { window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); } CHECK_STATE(window != nullptr); glfwSetKeyCallback(window, HandleKeyboard); glfwSetMouseButtonCallback(window, HandleMouseButton); glfwSetFramebufferSizeCallback(window, HandleReshape); glfwMakeContextCurrent(window); glfwSwapInterval(1); std::cout << glGetString(GL_VERSION) << std::endl; std::cout << glfwGetJoystickName(GLFW_JOYSTICK_1) << std::endl; renderer.Create(); int framebuffer_width, framebuffer_height; glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height); HandleReshape(window, framebuffer_width, framebuffer_height); controller.Setup(); while (!glfwWindowShouldClose(window)) { if (keyboard.GetKeyVelocity(GLFW_KEY_TAB) > 0) { if (minimized) { glfwSetWindowSize(window, width, height); glfwShowWindow(window); } else { glfwHideWindow(window); glfwSetWindowSize(window, kMinimizedWidth, kMinimizedHeight); } minimized = !minimized; } if (minimized) { glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } else { renderer.Render(); } controller.Update(); keyboard.Update(); mouse.Update(); double x, y; glfwGetCursorPos(window, &x, &y); mouse.OnCursorMove(glm::vec2(x, y)); joystick.Update(); input.Update(); glfwSwapBuffers(window); glfwPollEvents(); if (minimized) { usleep(16666); } } glfwTerminate(); return 0; }
void platform_video_minimize() { if (screen_hidden) glfwShowWindow(screen); else glfwHideWindow(screen); screen_hidden = !screen_hidden; }
JNIEXPORT void JNICALL Java_com_badlogic_jglfw_Glfw_glfwHideWindow(JNIEnv* env, jclass clazz, jlong window) { //@line:784 glfwHideWindow((GLFWwindow*)window); }
void Screen::setVisible(bool visible) { if (mVisible != visible) { mVisible = visible; if (visible) glfwShowWindow(mGLFWWindow); else glfwHideWindow(mGLFWWindow); } }
Impl(That* that) : that(that) , mainWindow(0) , sharingWindow(0) { if (!glfwInit()) { uplink_log_error("Failed to initialize GLFW."); abort(); } mainWindow = glfwCreateWindow( initialWindowWidth, initialWindowHeight, "Uplink", 0, 0 ); // Create a sharing context with a hidden window in order to allow other threads to upload data independently from the rendering thread. sharingWindow = glfwCreateWindow( 1, 1, "", 0, mainWindow ); glfwHideWindow(sharingWindow); glfwSetWindowUserPointer(mainWindow, this); glfwSetWindowSizeCallback(mainWindow, resize_callback); glfwSetKeyCallback(mainWindow, key_callback); glfwSwapInterval(1); glfwSetTime(0.0); glfwMakeContextCurrent(mainWindow); glGenTextures(1, &colorTextureId); glGenTextures(1, &depthTextureId); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0., 0., 0., 0.); glfwMakeContextCurrent(0); }
static void windowCloseCallback(GLFWwindow* window) { if (APPLICATION.getCurrentScene()->sceneEnded()) { glfwSetWindowShouldClose(window, GL_TRUE); } else { glfwSetWindowShouldClose(window, GL_FALSE); glfwHideWindow(window); } }
void Window:: onClose(GLFWwindow* handle) { Window* window = main_window_.get(); if (window != nullptr) { if (window->controller_ != nullptr) { window->controller_ ->windowControlDidStop(window->shared_from_this()); } if (window->view_ != nullptr) { window->view_->windowViewDidStop(window->shared_from_this()); } glfwHideWindow(window->glfw_handle_); } }
static void WIN_New( DaoProcess *proc, DaoValue *p[], int N ) { DaoxWindow *self = DaoxWindow_New(); DString_Assign( self->title, p[2]->xString.value ); self->width = self->context->deviceWidth = p[0]->xInteger.value; self->height = self->context->deviceHeight = p[1]->xInteger.value; self->handle = glfwCreateWindow( self->width, self->height, self->title->chars, NULL, NULL); if( self->handle == NULL ){ DaoProcess_RaiseError( proc, NULL, "Failed to create window" ); return; } glfwSetWindowUserPointer( self->handle, self ); glfwSetWindowCloseCallback( self->handle, DaoxWindow_CloseCallback ); glfwHideWindow( self->handle ); glfwMakeContextCurrent( self->handle ); DaoProcess_PutValue( proc, (DaoValue*) self ); }
AlloyContext::AlloyContext(int width, int height, const std::string& title, const Theme& theme) : nvgContext(nullptr), window(nullptr), theme(theme) { threadId = std::this_thread::get_id(); if (glfwInit() != GL_TRUE) { throw std::runtime_error("Could not initialize GLFW."); } glfwSetErrorCallback( [](int error, const char* desc) { std::cout << "GLFW Error [" << error << "] " << desc << std::endl; }); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1); glfwWindowHint(GLFW_VISIBLE, 0); window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL); if (!window) { glfwTerminate(); throw std::runtime_error("Could not create window."); } glfwMakeContextCurrent(window); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { throw std::runtime_error("Could not initialize GLEW."); } glGetError(); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); viewSize = int2(width, height); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1); glfwWindowHint(GLFW_VISIBLE, 0); offscreenWindow = glfwCreateWindow(width, height, "Offscreen", NULL, NULL); if (!offscreenWindow) { glfwTerminate(); throw std::runtime_error("Could not create window."); } glfwMakeContextCurrent(offscreenWindow); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { throw std::runtime_error("Could not initialize GLEW."); } glGetError(); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, width, height); glfwMakeContextCurrent(window); nvgContext = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES); const float2 TextureCoords[6] = { float2(1.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 1.0f), float2(0.0f, 1.0f), float2(1.0f, 1.0f), float2( 1.0f, 0.0f) }; const float3 PositionCoords[6] = { float3(1.0f, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.0f), float3(0.0f, 0.0f, 0.0f), float3(0.0f, 0.0f, 0.0f), float3(1.0f, 0.0f, 0.0f), float3(1.0f, 1.0f, 0.0f) }; glGenVertexArrays(1, &vaoImageOnScreen.vao); glBindVertexArray(vaoImageOnScreen.vao); glGenBuffers(1, &vaoImageOnScreen.positionBuffer); glBindBuffer(GL_ARRAY_BUFFER, vaoImageOnScreen.positionBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * 6, PositionCoords, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &vaoImageOnScreen.uvBuffer); glBindBuffer(GL_ARRAY_BUFFER, vaoImageOnScreen.uvBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 2 * 6, TextureCoords, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glfwHideWindow(offscreenWindow); glfwMakeContextCurrent(offscreenWindow); glGenVertexArrays(1, &vaoImageOffScreen.vao); glBindVertexArray(vaoImageOffScreen.vao); glGenBuffers(1, &vaoImageOffScreen.positionBuffer); glBindBuffer(GL_ARRAY_BUFFER, vaoImageOffScreen.positionBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * 6, PositionCoords, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &vaoImageOffScreen.uvBuffer); glBindBuffer(GL_ARRAY_BUFFER, vaoImageOffScreen.uvBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 2 * 6, TextureCoords, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glfwMakeContextCurrent(window); int widthMM, heightMM; GLFWmonitor* monitor = glfwGetPrimaryMonitor(); if (monitor == nullptr) throw std::runtime_error("Could not find monitor."); const GLFWvidmode* mode = glfwGetVideoMode(monitor); if (mode == nullptr) throw std::runtime_error("Could not find video monitor."); glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); dpmm = double2(mode->width / (double) widthMM, mode->height / (double) heightMM); int winWidth, winHeight, fbWidth, fbHeight; glfwGetWindowSize(window, &winWidth, &winHeight); glfwGetFramebufferSize(window, &fbWidth, &fbHeight); // Calculate pixel ration for hi-dpi devices. screenSize = int2(winWidth,winHeight); viewSize = int2(fbWidth,fbHeight); pixelRatio = pixel((float) fbWidth / (float) winWidth); lastAnimateTime = std::chrono::steady_clock::now(); lastCursorTime = std::chrono::steady_clock::now(); lastUpdateTime = std::chrono::steady_clock::now(); cursor = &Cursor::Normal; }
// -------------------------------------------------------------------------------------------------------------------- void GfxApiOpenGLBase::Deactivate() { assert(mWnd); glfwMakeContextCurrent(nullptr); glfwHideWindow(mWnd); }
int main(int argc,char**argv) { double atStart,now,remain; /// Initialize GLFW glfwInit(); // Open registers OpenGL window if( !(windows[REGISTER_WINDOW]=glfwCreateWindow( REGISTER_WIDTH, REGISTER_HEIGHT, "cpu",NULL,NULL)) ) { glfwTerminate(); return 1; } glfwSetWindowPos(windows[REGISTER_WINDOW],600,740); glfwMakeContextCurrent(windows[REGISTER_WINDOW]); setupGL(REGISTER_WINDOW,REGISTER_WIDTH,REGISTER_HEIGHT); // Open timing OpenGL window if( !(windows[TIMING_WINDOW]=glfwCreateWindow( TIMING_WIDTH, TIMING_HEIGHT, "timing",NULL,NULL)) ) { glfwTerminate(); return 1; } glfwSetWindowPos(windows[TIMING_WINDOW],600,300); glfwMakeContextCurrent(windows[TIMING_WINDOW]); setupGL(TIMING_WINDOW,TIMING_WIDTH,TIMING_HEIGHT); // Open invaders OpenGL window if( !(windows[MAIN_WINDOW]=glfwCreateWindow( WIDTH, HEIGHT, "invaders",NULL,NULL)) ) { glfwTerminate(); return 1; } glfwSetWindowPos(windows[MAIN_WINDOW],300,300); glfwMakeContextCurrent(windows[MAIN_WINDOW]); setupGL(MAIN_WINDOW,WIDTH,HEIGHT); glfwSwapInterval(0); // Disable VSYNC glfwSetKeyCallback(windows[MAIN_WINDOW],kbHandler); glfwSetScrollCallback(windows[TIMING_WINDOW],mwHandler); atStart=glfwGetTime(); ////////////////// if (InitialiseMemory()) return -1; PinSetRESET(1); PIN_BUFFER_RESET=1; PinSetO1(1); // Run with reset high for a few cycles to perform a full cpu reset PinSetO1(0); PinSetO2(1); PinSetO2(0); PinSetO1(1); PinSetO1(0); PinSetO2(1); PinSetO2(0); PinSetO1(1); PinSetO1(0); PinSetO2(1); PinSetO2(0); PinSetRESET(0); // RESET CPU PIN_BUFFER_RESET=0; //dumpInstruction=100000; int stopTheClock=0; while (!glfwGetKey(windows[MAIN_WINDOW],GLFW_KEY_ESCAPE)) { if (!stopTheClock) { masterClock++; if ((masterClock%4)==0) pixelClock++; if ((masterClock%10)==0) { // I8080 emulation works off positive edge trigger. So we need to supply the same sort of // clock. PIN_BUFFER_O2=0; PIN_BUFFER_O1=1; PinSetO1(1); // Execute a cpu step if (bTimingEnabled) RecordPins(); PIN_BUFFER_O1=0; PinSetO1(0); if (bTimingEnabled) RecordPins(); PIN_BUFFER_O2=1; PinSetO2(1); if (bTimingEnabled) RecordPins(); PIN_BUFFER_O2=0; PinSetO2(0); if (!MEM_Handler()) { stopTheClock=1; } if (bTimingEnabled) RecordPins(); PinSetINT(0); // clear interrupt state PIN_BUFFER_INT=0; cpuClock++; } if (pixelClock==30432+10161) // Based on 19968000 Mhz master clock + mame notes { NEXTINT=0xCF; PinSetINT(1); PIN_BUFFER_INT=1; } if (pixelClock==71008+10161) { NEXTINT=0xD7; PinSetINT(1); PIN_BUFFER_INT=1; } } if (pixelClock>=83200 || stopTheClock) { if (pixelClock>=83200) pixelClock=0; if (glfwWindowShouldClose(windows[TIMING_WINDOW])) { bTimingEnabled=0; glfwHideWindow(windows[TIMING_WINDOW]); } if (glfwWindowShouldClose(windows[REGISTER_WINDOW])) { bRegisterEnabled=0; glfwHideWindow(windows[REGISTER_WINDOW]); } glfwMakeContextCurrent(windows[MAIN_WINDOW]); ShowScreen(MAIN_WINDOW,WIDTH,HEIGHT); glfwSwapBuffers(windows[MAIN_WINDOW]); if (bTimingEnabled) { glfwMakeContextCurrent(windows[TIMING_WINDOW]); DrawTiming(videoMemory[TIMING_WINDOW],TIMING_WIDTH); ShowScreen(TIMING_WINDOW,TIMING_WIDTH,TIMING_HEIGHT); glfwSwapBuffers(windows[TIMING_WINDOW]); } if (bRegisterEnabled) { glfwMakeContextCurrent(windows[REGISTER_WINDOW]); DrawRegister(videoMemory[REGISTER_WINDOW],REGISTER_WIDTH); ShowScreen(REGISTER_WINDOW,REGISTER_WIDTH,REGISTER_HEIGHT); glfwSwapBuffers(windows[REGISTER_WINDOW]); } glfwPollEvents(); g_traceStep=0; if (CheckKey(GLFW_KEY_PAUSE)) { g_instructionStep^=1; if (stopTheClock && !g_instructionStep) stopTheClock=0; ClearKey(GLFW_KEY_PAUSE); } if (stopTheClock && CheckKey('S')) { stopTheClock=0; ClearKey('S'); } if (stopTheClock && CheckKey('T')) { stopTheClock=0; g_traceStep=1; ClearKey('T'); } now=glfwGetTime(); remain = now-atStart; while ((remain<0.02f)) { now=glfwGetTime(); remain = now-atStart; } atStart=glfwGetTime(); } } return 0; }
bool Window::CreateOffscreen() { bool status = Create(1,1,"Hidden"); glfwHideWindow(window); return status; }
int main(void) { int i, result; Thread threads[] = { { NULL, "Red", 1.f, 0.f, 0.f, 0 }, { NULL, "Green", 0.f, 1.f, 0.f, 0 }, { NULL, "Blue", 0.f, 0.f, 1.f, 0 } }; const int count = sizeof(threads) / sizeof(Thread); glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); for (i = 0; i < count; i++) { threads[i].window = glfwCreateWindow(200, 200, threads[i].title, NULL, NULL); if (!threads[i].window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); glfwShowWindow(threads[i].window); } glfwMakeContextCurrent(threads[0].window); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); glfwMakeContextCurrent(NULL); for (i = 0; i < count; i++) { if (thrd_create(&threads[i].id, thread_main, threads + i) != thrd_success) { fprintf(stderr, "Failed to create secondary thread\n"); glfwTerminate(); exit(EXIT_FAILURE); } } while (running) { glfwWaitEvents(); for (i = 0; i < count; i++) { if (glfwWindowShouldClose(threads[i].window)) running = GLFW_FALSE; } } for (i = 0; i < count; i++) glfwHideWindow(threads[i].window); for (i = 0; i < count; i++) thrd_join(threads[i].id, &result); exit(EXIT_SUCCESS); }
void kit::Window::hide() { glfwHideWindow(this->m_glfwHandle); }
static int Lwin_hide(lua_State *L) { GLFWwindow *win = (GLFWwindow*)lbind_check(L, 1, &lbT_Window); glfwHideWindow(win); lbind_returnself(L); }
static void WIN_Show( DaoProcess *proc, DaoValue *p[], int N ) { DaoxWindow *self = (DaoxWindow*) p[0]; DaoxCanvas *canvas = (DaoxCanvas*) DaoValue_CastCstruct( p[1], daox_type_canvas ); DaoxScene *scene = (DaoxScene*) DaoValue_CastCstruct( p[1], daox_type_scene ); DaoxFont *font = DaoxFont_GetDefault(); int fpsLimit = p[2]->xInteger.value; int fpsTest = p[3]->xBoolean.value; double fpsTestTime = 0.0; double timeInterval = 0.0; double lastFrameStart = 0.0; float currentFPS = 0.0; size_t fpsCount = 0; char chars[32]; if( fpsTest && self->widget == NULL ){ char *fpsText = "FPS: "; DaoxColor bgcolor = {0.0,0.0,0.0,0.0}; DaoxBrush *brush; self->widget = DaoxCanvas_New( NULL ); self->widget->viewport.right = self->width; self->widget->viewport.top = self->height; DaoGC_IncRC( (DaoValue*) self->widget ); DaoxCanvas_SetBackground( self->widget, bgcolor ); brush = DaoxCanvas_PushBrush( self->widget, 0 ); brush->strokeColor.blue = 1.0; brush->fillColor.blue = 1.0; brush->fillColor.alpha = 1.0; brush->fontSize = 20; self->fpsLabel = DaoxCanvas_AddText( self->widget, fpsText, 10, self->height - 20, 0 ); } if( self->painter == NULL && (canvas != NULL || self->widget != NULL) ){ self->painter = DaoxPainter_New( self->context ); DaoGC_IncRC( (DaoValue*) self->painter ); } if( self->renderer == NULL && scene != NULL ){ self->renderer = DaoxRenderer_New( self->context ); DaoGC_IncRC( (DaoValue*) self->renderer ); } if( canvas != NULL ){ float dm = sqrt(self->width*self->width + self->height*self->height ); float cx = 0.5*(canvas->viewport.left + canvas->viewport.right); float cy = 0.5*(canvas->viewport.top + canvas->viewport.bottom); float w = canvas->viewport.right - canvas->viewport.left; float h = canvas->viewport.top - canvas->viewport.bottom; float d = sqrt(w*w + h*h); w = 0.5 * self->width * d / dm; h = 0.5 * self->height * d / dm; canvas->viewport.left = cx - w; canvas->viewport.right = cx + w; canvas->viewport.bottom = cy - h; canvas->viewport.top = cy + h; } GC_Assign( & self->model, p[1] ); self->visible = 1; glfwShowWindow( self->handle ); glfwMakeContextCurrent( self->handle ); glfwSetKeyCallback( self->handle, DaoxWindow_KeyCallback ); glfwSetCursorPosCallback( self->handle, DaoxWindow_CursorMoveCallback ); glfwSetCursorEnterCallback( self->handle, DaoxWindow_CursorEnterCallback ); glfwSetWindowFocusCallback( self->handle, DaoxWindow_FocusCallback ); #ifdef SAVE_RENDERED_SCENE char name[50]; int frame = 1; DaoxImage *image = DaoxImage_New(); image->depth = DAOX_IMAGE_BIT32; DaoxImage_Resize( image, self->width, self->height ); #endif while( self->visible && ! glfwWindowShouldClose( self->handle ) ){ double frameStartTime = 0.0; double frameEndTime = 0.0; frameStartTime = glfwGetTime(); if( canvas ) DaoxPainter_Paint( self->painter, canvas, canvas->viewport ); if( scene ){ #ifdef SAVE_RENDERED_SCENE DaoxScene_Update( scene, 1.0/30.0 ); glReadBuffer( GL_BACK ); glPixelStorei( GL_UNPACK_ALIGNMENT, 4 ); glPixelStorei( GL_PACK_ROW_LENGTH, image->width ); DaoxRenderer_Render( self->renderer, scene, scene->camera ); glReadPixels( 0, 0, self->width, self->height, GL_RGBA, GL_UNSIGNED_BYTE, image->imageData ); sprintf( name, "rama_attack_frame_%03i.png", frame ); DaoxImage_SavePNG( image, name ); frame += 1; if( frame > 155 ) break; #else DaoxScene_Update( scene, frameStartTime - lastFrameStart ); DaoxRenderer_Render( self->renderer, scene, scene->camera ); #endif } lastFrameStart = frameStartTime; if( fpsTest ){ if( fpsCount % 10 == 0 ){ int i, n = sprintf( chars, "%.1f", currentFPS ); for(i=0; i<n; ++i){ DaoxGlyph *glyph = DaoxFont_GetGlyph( font, chars[i] ); DaoxCanvasNode *chnode = self->fpsLabel->children->items.pCanvasNode[i+5]; DaoxPath *path = DaoxPathCache_FindPath( self->widget->pathCache, glyph->shape ); GC_Assign( & chnode->path, path ); DaoxCanvasNode_MarkDataChanged( chnode ); } } DaoxPainter_Paint( self->painter, self->widget, self->widget->viewport ); } glfwSwapBuffers( self->handle ); glfwPollEvents(); if( fpsTest == 0 ) continue; frameEndTime = glfwGetTime(); timeInterval = frameEndTime - frameStartTime; if( timeInterval < 1.0/fpsLimit ) usleep( 1000000 * (1.0/fpsLimit - timeInterval) ); fpsCount += 1; currentFPS = fpsCount / (frameEndTime - fpsTestTime); if( frameEndTime > (fpsTestTime + 3) ){ fpsTestTime = frameEndTime - 1.0; fpsCount = currentFPS; /* Frame count estimation in the past second; */ } } glfwHideWindow( self->handle ); }
void j_close_window(J_Context_Shared_t i_context){ glfwHideWindow(i_context->M_window); }
J_Context::~J_Context(){ glfwHideWindow(M_window); delete M_context; glfwDestroyWindow(M_window); }
static void WIN_Hide( DaoProcess *proc, DaoValue *p[], int N ) { DaoxWindow *self = (DaoxWindow*) p[0]; self->visible = 0; glfwHideWindow( self->handle ); }
void Hide() override { assert(this->_window != NULL); this->_visible = false; glfwHideWindow(this->_window); }
void veViewerDesktop::hide() { glfwHideWindow(_hwnd); }
void CanvasGLFW::hide() { if (glfwGetWindowAttrib(glWindow_, GLFW_VISIBLE)) { glfwWindowCount_--; glfwHideWindow(glWindow_); } }
void AnalyzeSet_GLSL(std::shared_ptr<DatasetUtils::Segm::Image::Set> pCurrSet) { srand(0); // for now, assures that two consecutive runs on the same data return the same results //srand((unsigned int)time(NULL)); size_t nCurrImageIdx = 0; size_t nNextImageIdx = nCurrImageIdx+1; bool bGPUContextInitialized = false; try { glfwSetErrorCallback(GLFWErrorCallback); CV_Assert(pCurrSet.get() && pCurrSet->GetTotalImageCount()>0); if(pCurrSet->m_pEvaluator==nullptr && EVALUATE_OUTPUT) throw std::runtime_error(cv::format("Missing evaluation impl for image segmentation dataset '%s'",g_pDatasetInfo->m_sDatasetName.c_str())); const std::string sCurrSetName = pCurrSet->m_sName.size()>12?pCurrSet->m_sName.substr(0,12):pCurrSet->m_sName; const size_t nImageCount = pCurrSet->GetTotalImageCount(); cv::Mat oCurrInputImage = pCurrSet->GetInputFromIndex(nCurrImageIdx).clone(); CV_Assert(!oCurrInputImage.empty()); CV_Assert(oCurrInputImage.isContinuous()); #if NEED_GT_MASK cv::Mat oCurrGTMask = pCurrSet->GetGTFromIndex(nCurrImageIdx).clone(); CV_Assert(!oCurrGTMask.empty() && oCurrGTMask.isContinuous()); #endif //NEED_GT_MASK #if DISPLAY_OUTPUT cv::Mat oLastInputImage = oCurrInputImage.clone(); #endif //DISPLAY_OUTPUT cv::Mat oNextInputImage = pCurrSet->GetInputFromIndex(nNextImageIdx); #if NEED_GT_MASK #if NEED_LAST_GT_MASK cv::Mat oLastGTMask = oCurrGTMask.clone(); #endif // NEED_LAST_GT_MASK cv::Mat oNextGTMask = pCurrSet->GetGTFromIndex(nNextImageIdx); #endif //NEED_GT_MASK #if NEED_EDGES_MASK cv::Mat oLastEdgeMask(oCurrInputImage.size(),CV_8UC1,cv::Scalar_<uchar>(0)); #endif //NEED_EDGES_MASK glAssert(oCurrInputImage.channels()==1 || oCurrInputImage.channels()==4); cv::Size oWindowSize = pCurrSet->GetMaxImageSize(); // note: never construct GL classes before context initialization if(glfwInit()==GL_FALSE) glError("Failed to init GLFW"); bGPUContextInitialized = true; glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,TARGET_GL_VER_MAJOR); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,TARGET_GL_VER_MINOR); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); #if !DISPLAY_OUTPUT glfwWindowHint(GLFW_VISIBLE,GL_FALSE); #endif //!DISPLAY_OUTPUT std::unique_ptr<GLFWwindow,void(*)(GLFWwindow*)> pWindow(glfwCreateWindow(oWindowSize.width,oWindowSize.height,(pCurrSet->m_sRelativePath+" [GPU]").c_str(),nullptr,nullptr),glfwDestroyWindow); if(!pWindow) glError("Failed to create window via GLFW"); glfwMakeContextCurrent(pWindow.get()); glewInitErrorCheck; #if USE_CANNY #error "Missing glsl impl." // ... @@@@@ std::shared_ptr<BackgroundSubtractorLOBSTER_GLSL> pAlgo(new BackgroundSubtractorLOBSTER_GLSL()); #elif USE_LBSP #error "Missing glsl impl." // ... @@@@@ std::shared_ptr<BackgroundSubtractorSuBSENSE_GLSL> pAlgo(new BackgroundSubtractorSuBSENSE_GLSL()); #endif //USE_... #if DISPLAY_OUTPUT bool bContinuousUpdates = false; std::string sDisplayName = pCurrSet->m_sRelativePath; cv::namedWindow(sDisplayName); #endif //DISPLAY_OUTPUT std::shared_ptr<GLImageProcAlgo> pGLSLAlgo = std::dynamic_pointer_cast<GLImageProcAlgo>(pAlgo); if(pGLSLAlgo==nullptr) glError("Segmentation algorithm has no GLImageProcAlgo interface"); pGLSLAlgo->setOutputFetching(NEED_EDGES_MASK); if(!pGLSLAlgo->getIsUsingDisplay() && DISPLAY_OUTPUT) // @@@@ determine in advance to hint window to hide? or just always hide, and show when needed? glfwHideWindow(pWindow.get()); #if USE_GLSL_EVALUATION std::shared_ptr<DatasetUtils::EvaluatorBase::GLEvaluatorBase> pGLSLAlgoEvaluator; if(pCurrSet->m_pEvaluator!=nullptr) pGLSLAlgoEvaluator = std::dynamic_pointer_cast<DatasetUtils::EvaluatorBase::GLEvaluatorBase>(pCurrSet->m_pEvaluator->CreateGLEvaluator(pGLSLAlgo,nImageCount)); if(pGLSLAlgoEvaluator==nullptr) glError("Segmentation evaluation algorithm has no GLSegmEvaluator interface"); pGLSLAlgoEvaluator->initialize(oCurrGTMask,cv::Mat(oCurrInputImage.size(),CV_8UC1,cv::Scalar_<uchar>(255))); oWindowSize.width *= pGLSLAlgoEvaluator->m_nSxSDisplayCount; #else //!USE_GLSL_EVALUATION oWindowSize.width *= pGLSLAlgo->m_nSxSDisplayCount; #endif //!USE_GLSL_EVALUATION glfwSetWindowSize(pWindow.get(),oWindowSize.width,oWindowSize.height); glViewport(0,0,oWindowSize.width,oWindowSize.height); TIMER_TIC(MainLoop); while(nNextImageIdx<=nImageCount) { //if(!((nCurrImageIdx+1)%100)) std::cout << "\t\t" << std::setfill(' ') << std::setw(12) << sCurrSetName << " @ F:" << std::setfill('0') << std::setw(PlatformUtils::decimal_integer_digit_count((int)nImageCount)) << nCurrImageIdx+1 << "/" << nImageCount << " [GPU]" << std::endl; TIMER_INTERNAL_TIC(OverallLoop); TIMER_INTERNAL_TIC(PipelineUpdate); pAlgo->apply_async(oNextInputImage); TIMER_INTERNAL_TOC(PipelineUpdate); #if USE_GLSL_EVALUATION pGLSLAlgoEvaluator->apply_async(oNextGTMask); #endif //USE_GLSL_EVALUATION TIMER_INTERNAL_TIC(ImageQuery); #if DISPLAY_OUTPUT oCurrInputImage.copyTo(oLastInputImage); oNextInputImage.copyTo(oCurrInputImage); #endif //DISPLAY_OUTPUT if(++nNextImageIdx<nImageCount) oNextInputImage = pCurrSet->GetInputFromIndex(nNextImageIdx); #if NEED_GT_MASK #if NEED_LAST_GT_MASK oCurrGTMask.copyTo(oLastGTMask); oNextGTMask.copyTo(oCurrGTMask); #endif //NEED_LAST_GT_MASK if(nNextImageIdx<nImageCount) oNextGTMask = pCurrSet->GetGTFromIndex(nNextImageIdx); #endif //NEED_GT_MASK TIMER_INTERNAL_TOC(ImageQuery); glErrorCheck; if(glfwWindowShouldClose(pWindow.get())) break; glfwPollEvents(); #if DISPLAY_OUTPUT if(glfwGetKey(pWindow.get(),GLFW_KEY_ESCAPE) || glfwGetKey(pWindow.get(),GLFW_KEY_Q)) break; glfwSwapBuffers(pWindow.get()); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); #endif //DISPLAY_OUTPUT #if NEED_EDGES_MASK pAlgo->getLatestEdgeMask(oLastEdgeMask); #endif //NEED_EDGES_MASK #if DISPLAY_OUTPUT @@@ update via copy of non-parallel impl cv::Mat oDisplayImage = DatasetUtils::GetDisplayImage(oLastInputImage,oLastEdgeMask,pCurrSet->m_pEvaluator?pCurrSet->m_pEvaluator->GetColoredSegmMaskFromResult(oLastEdgeMask,oLastGTMask,cv::Mat()):oLastEdgeMask,nCurrImageIdx); cv::Mat oDisplayImageResized; if(oDisplayImage.cols>1920 || oDisplayImage.rows>1080) cv::resize(oDisplayImage,oDisplayImageResized,cv::Size(oDisplayImage.cols/2,oDisplayImage.rows/2)); else oDisplayImageResized = oDisplayImage; cv::imshow(sDisplayName,oDisplayImageResized); int nKeyPressed; if(bContinuousUpdates) nKeyPressed = cv::waitKey(1); else nKeyPressed = cv::waitKey(0); if(nKeyPressed!=-1) nKeyPressed %= (UCHAR_MAX+1); // fixes return val bug in some opencv versions if(nKeyPressed==' ') bContinuousUpdates = !bContinuousUpdates; else if(nKeyPressed==(int)'q') break; #endif //DISPLAY_OUTPUT #if WRITE_IMG_OUTPUT pCurrSet->WriteResult(nCurrImageIdx,oLastEdgeMask); #endif //WRITE_IMG_OUTPUT #if (EVALUATE_OUTPUT && (!USE_GLSL_EVALUATION || VALIDATE_GPU_EVALUATION)) if(pCurrSet->m_pEvaluator) pCurrSet->m_pEvaluator->AccumulateMetricsFromResult(oCurrEdgeMask,oCurrGTMask,cv::Mat()); #endif //(EVALUATE_OUTPUT && (!USE_GLSL_EVALUATION || VALIDATE_GPU_EVALUATION)) TIMER_INTERNAL_TOC(OverallLoop); #if DISPLAY_TIMERS std::cout << "ImageQuery=" << TIMER_INTERNAL_ELAPSED_MS(ImageQuery) << "ms, " << "PipelineUpdate=" << TIMER_INTERNAL_ELAPSED_MS(PipelineUpdate) << "ms, " << "OverallLoop=" << TIMER_INTERNAL_ELAPSED_MS(OverallLoop) << "ms" << std::endl; #endif //ENABLE_INTERNAL_TIMERS ++nCurrImageIdx; } TIMER_TOC(MainLoop); const double dTimeElapsed = TIMER_ELAPSED_MS(MainLoop)/1000; const double dAvgFPS = (double)nCurrImageIdx/dTimeElapsed; std::cout << "\t\t" << std::setfill(' ') << std::setw(12) << sCurrSetName << " @ end, " << int(dTimeElapsed) << " sec in-thread (" << (int)floor(dAvgFPS+0.5) << " FPS)" << std::endl; #if EVALUATE_OUTPUT if(pCurrSet->m_pEvaluator) { #if USE_GLSL_EVALUATION #if VALIDATE_GPU_EVALUATION printf("cpu eval:\n\tnTP=%" PRIu64 ", nTN=%" PRIu64 ", nFP=%" PRIu64 ", nFN=%" PRIu64 ", nSE=%" PRIu64 ", tot=%" PRIu64 "\n",pCurrSet->m_pEvaluator->m_oBasicMetrics.nTP,pCurrSet->m_pEvaluator->m_oBasicMetrics.nTN,pCurrSet->m_pEvaluator->m_oBasicMetrics.nFP,pCurrSet->m_pEvaluator->m_oBasicMetrics.nFN,pCurrSet->m_pEvaluator->m_oBasicMetrics.nSE,pCurrSet->m_pEvaluator->m_oBasicMetrics.nTP+pCurrSet->m_pEvaluator->m_oBasicMetrics.nTN+pCurrSet->m_pEvaluator->m_oBasicMetrics.nFP+pCurrSet->m_pEvaluator->m_oBasicMetrics.nFN); #endif //VALIDATE_USE_GLSL_EVALUATION pCurrSet->m_pEvaluator->FetchGLEvaluationResults(pGLSLAlgoEvaluator); #if VALIDATE_GPU_EVALUATION printf("gpu eval:\n\tnTP=%" PRIu64 ", nTN=%" PRIu64 ", nFP=%" PRIu64 ", nFN=%" PRIu64 ", nSE=%" PRIu64 ", tot=%" PRIu64 "\n",pCurrSet->m_pEvaluator->m_oBasicMetrics.nTP,pCurrSet->m_pEvaluator->m_oBasicMetrics.nTN,pCurrSet->m_pEvaluator->m_oBasicMetrics.nFP,pCurrSet->m_pEvaluator->m_oBasicMetrics.nFN,pCurrSet->m_pEvaluator->m_oBasicMetrics.nSE,pCurrSet->m_pEvaluator->m_oBasicMetrics.nTP+pCurrSet->m_pEvaluator->m_oBasicMetrics.nTN+pCurrSet->m_pEvaluator->m_oBasicMetrics.nFP+pCurrSet->m_pEvaluator->m_oBasicMetrics.nFN); #endif //VALIDATE_USE_GLSL_EVALUATION #endif //USE_GLSL_EVALUATION pCurrSet->m_pEvaluator->dTimeElapsed_sec = dTimeElapsed; } #endif //EVALUATE_OUTPUT #if DISPLAY_OUTPUT cv::destroyWindow(sDisplayName); #endif //DISPLAY_OUTPUT } catch(const CxxUtils::Exception& e) { std::cout << "\nAnalyzeSequence caught Exception:\n" << e.what(); if(!g_sLatestGLFWErrorMessage.empty()) { std::cout << " (" << g_sLatestGLFWErrorMessage << ")" << "\n" << std::endl; g_sLatestGLFWErrorMessage = std::string(); } else std::cout << "\n" << std::endl; } catch(const cv::Exception& e) {std::cout << "\nAnalyzeSequence caught cv::Exception:\n" << e.what() << "\n" << std::endl;} catch(const std::exception& e) {std::cout << "\nAnalyzeSequence caught std::exception:\n" << e.what() << "\n" << std::endl;} catch(...) {std::cout << "\nAnalyzeSequence caught unhandled exception\n" << std::endl;} if(bGPUContextInitialized) glfwTerminate(); if(pCurrSet.get()) { #if DATASET_PRECACHING pCurrSet->StopPrecaching(); #endif //DATASET_PRECACHING pCurrSet->m_nImagesProcessed.set_value(nCurrImageIdx); } }