static void CharFunc(GLFWwindow* window, int c) { GLWindow* glwnd = (GLWindow*)glfwGetWindowUserPointer(window); input::KeyEventArgs args; args.key = c; args.state = input::Press; args.isIME = true; args.flag = g_key_flag; glwnd->onKeyEvent().raise(glwnd, args); }
void Display::upCB(Fl_Button* w, Display* d) { Map* m = d->getMap(); GLWindow* win = d->getGWin(); //std::cout << d->tile_x <<d->tile_y<< std::endl; if (d->tile_y == 0) d->tile_y = m->getRow()-1; else d->tile_y--; win->setColor(d->tile_x, d->tile_y); win->redraw(); }
void Display::createCB(Fl_Button* w, Display* c){ Map* m = c->getMap(); c->tile_x = c->tile_y = 0; m->setSize(c->r,c->c,c->x,c->y); //std::cout << c->max << std::endl; m->setRange(c->max, c->min); m->createMap(); GLWindow* win = c->getGWin(); win->setColor(c->tile_x, c->tile_y); win->setMap(m); win->redraw(); }
void Display::rightCB(Fl_Button* w, Display* d) { Map* m = d->getMap(); GLWindow* win = d->getGWin(); //std::cout << d->tile_x <<d->tile_y<< std::endl; if (d->tile_x == m->getCol() - 1) d->tile_x = 0; else d->tile_x++; win->setColor(d->tile_x, d->tile_y); win->redraw(); }
void frameDraw(const uint32_t id) { eq::Channel::frameDraw(id); GLWindow* glwindow = dynamic_cast<GLWindow*> (getWindow()->getOSWindow()); if (glwindow) glwindow->getWidget()->paintGL(); else Widget::static_draw(this); }
static void MousePosFunc(GLFWwindow* window, int x, int y) { GLWindow* glwnd = (GLWindow*)glfwGetWindowUserPointer(window); input::MouseEventArgs args; args.button = input::Nothing; args.state = input::Move; args.flag = g_key_flag; args.x = x; args.y = y; glwnd->onMouseEvent().raise(glwnd, args); }
static void MouseButtonFunc(GLFWwindow* window, int btn, int state) { GLWindow* glwnd = (GLWindow*)glfwGetWindowUserPointer(window); input::MouseEventArgs args; args.button = glfw_to_ukn_mouse(btn); args.state = glfw_to_ukn_mouse_state(state); args.flag = g_key_flag; // retrieve mouse pos glfwGetCursorPos(window, &args.x, &args.y); glwnd->onMouseEvent().raise(glwnd, args); }
static void ScrollFunc(GLFWwindow* window, double a, double b) { GLWindow* glwnd = (GLWindow*)glfwGetWindowUserPointer(window); input::MouseEventArgs args; args.button = input::Nothing; args.state = input::Wheel; args.flag = g_key_flag; args.x = a; args.y = b; args.wheel = 0; glwnd->onMouseEvent().raise(glwnd, args); }
static gint expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) { GLWindow *wnd = (GLWindow*)data; #ifndef _WIN32 if (event->count > 0) return TRUE; #endif if (!g_pParentWnd->IsSleeping ()) wnd->OnExpose (); return TRUE; }
int main(int argc, char** argv) { GLWindow window; ShaderInfo shadersText[] = { {GL_VERTEX_SHADER, "Source/GLSLShaders/text.vert" }, {GL_FRAGMENT_SHADER, "Source/GLSLShaders/text.frag" }}; SDL_Color textCol; textCol.r = 36; textCol.g = 133; textCol.b = 12; textCol.a = 255; window.RegisterTextRenderer(shadersText, 2, "Source/Resources/Fonts/helvetica.ttf", 14, textCol); glm::vec3 eye(0.0f, -15.0f, 15.0f); glm::vec3 center(0.0f, 0.0f, 0.0f); glm::vec3 up(0.0f, 15.0f, 15.0f); std::shared_ptr<Camera> cam(new Camera(eye, center, up, 45.0f, (float)WIDTH/ (float)HEIGHT, 1.0f, 100.0f)); std::shared_ptr<CameraKeyMoveHandler> cameraKeyMoveHandler(new CameraKeyMoveHandler(cam.get())); window.RegisterEventHandler(cameraKeyMoveHandler.get()); window.RegisterRenderHandler(cameraKeyMoveHandler.get()); std::shared_ptr<CameraMouseMoveHandler> cameraMouseMoveHandler(new CameraMouseMoveHandler(cam.get(), glm::vec3(0.0f, 0.0f, 0.0f))); window.RegisterEventHandler(cameraMouseMoveHandler.get()); std::shared_ptr<ShaderProgramManager> shaderManager(new ShaderProgramManager(window, cam.get())); window.RegisterEventHandler(shaderManager.get()); window.RegisterRenderHandler(shaderManager.get()); window.MainLoop(); return 0; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat fmt; fmt.setDepthBufferSize(24); // fmt.setVersion(3, 3); // fmt.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(fmt); GLWindow w; w.show(); return a.exec(); }
// workaround for issue seen on Windows 7 with NVIDIA void triggerStereo() { // attributes for an OpenGL stereo window GLWindow::Attributes attributes; attributes[WGL_STEREO_ARB] = GL_TRUE; // create and destroy a small stereo window: this is here to work around // an issue with windows failing to switch to quad-buffer mode (although // the window is successfully created and reports a stereo pixel format) // note: the window is invisible (not shown) but typically causes the // windows desktop to flash briefly (first run only) as stereo activates GLWindow window; window.create( 0, "", 0, 0, 0, 8, 8, 0, 0, DefWindowProc, 0, attributes ); window.destroy(); }
LRESULT CALLBACK WndProc( HWND hWnd, // Дескриптор нужного окна UINT uMsg, // Сообщение для этого окна WPARAM wParam, // Дополнительная информация LPARAM lParam) // Дополнительная информация { switch (uMsg) // Проверка сообщения для окна { case WM_ACTIVATE: // Проверка сообщения активности окна { if( !HIWORD( wParam ) ) // Проверить состояние минимизации { glwWnd.active = true; // Программа активна } else { glwWnd.active = false; // Программа теперь не активна } return 0; // Возвращаемся в цикл обработки сообщений } case WM_SYSCOMMAND: // Перехватываем системную команду { switch ( wParam ) // Останавливаем системный вызов { case SC_SCREENSAVE: // Пытается ли запустится скринсейвер? case SC_MONITORPOWER: // Пытается ли монитор перейти в режим сбережения энергии? return 0; // Предотвращаем это } break; // Выход } case WM_CLOSE: // Мы получили сообщение о закрытие? { PostQuitMessage( 0 ); // Отправить сообщение о выходе return 0; // Вернуться назад } case WM_KEYDOWN: // Была ли нажата кнопка? { glwWnd.keys[wParam] = true; // Если так, мы присваиваем этой ячейке true return 0; // Возвращаемся } case WM_KEYUP: // Была ли отпущена клавиша? { glwWnd.keys[wParam] = false; // Если так, мы присваиваем этой ячейке false return 0; // Возвращаемся } case WM_SIZE: // Изменены размеры OpenGL окна { glwWnd.ReSizeGLScene( LOWORD(lParam), HIWORD(lParam) ); // Младшее слово=Width, старшее слово=Height return 0; // Возвращаемся } } // пересылаем все необработанные сообщения DefWindowProc return DefWindowProc( hWnd, uMsg, wParam, lParam ); }
int main(int argc, char** argv) { auto glversion = gl::getAvailableVersion(); auto major = GL_GET_MAJOR_VERSION(glversion); auto minor = GL_GET_MINOR_VERSION(glversion); if (glversion < GL_MAKE_VERSION(4, 1)) { MessageBoxA(nullptr, "Interface requires OpenGL 4.1 or higher", "Unsupported", MB_OK); return 0; } QGuiApplication app(argc, argv); bool quitting = false; // FIXME need to handle window closing message so that we can stop the timer GLWindow* window = new GLWindow(); window->create(); window->show(); window->setSurfaceType(QSurface::OpenGLSurface); window->setFormat(getDefaultOpenGLSurfaceFormat()); bool contextCreated = false; QTimer* timer = new QTimer(); QObject::connect(timer, &QTimer::timeout, [&] { if (quitting) { return; } if (!contextCreated) { window->createContext(); contextCreated = true; } if (!window->makeCurrent()) { throw std::runtime_error("Failed"); } glClearColor(1.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); window->swapBuffers(); window->doneCurrent(); }); // FIXME need to handle window closing message so that we can stop the timer QObject::connect(&app, &QCoreApplication::aboutToQuit, [&] { quitting = true; QObject::disconnect(timer, &QTimer::timeout, nullptr, nullptr); timer->stop(); timer->deleteLater(); }); timer->setInterval(15); timer->setSingleShot(false); timer->start(); app.exec(); return 0; }
/* Main Method */ int CALLBACK WinMain(HINSTANCE current_instance_handle,HINSTANCE previous_instance_handle,LPSTR arguments,int show_command) { std::ofstream log; GLWindow window; log.open("./Debug/output.log",std::ofstream::ate); std::cout.rdbuf(log.rdbuf()); /* Initialize the window and run it's message loop. */ if(!window.init()) { return 1; } window.setBackgroundColour(Strixa::Graphics::Colour(0,0,0,100)); window.maximize(); return window(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); #if defined(Q_WS_X11) XInitThreads(); #endif GLWindow *glwindow = new GLWindow(); glwindow->create(); glwindow->setWindowState(Qt::WindowNoState); glwindow->showFullScreen(); glwindow->resume(); int result = a.exec(); glwindow->destroy(); delete glwindow; //QCoreApplication::setAttribute(Qt::AA_NativeWindows, true); //QCoreApplication::setAttribute(Qt::AA_ImmediateWidgetCreation, true); //return a.exec(); return result; }
int main(int argc, char** argv) { Magick::InitializeMagick(argv[0]); GLWindow *win = new GLWindow("tut", 100, 100, 1024, 960, false); win->RegDisplayFunc(RenderScene); Engine *eng = new Engine(argc, argv, 0, win); eng->Initilize(); GLuint ShaderProgram = glCreateProgram(); GLuint ShaderObj = glCreateShader(GL_VERTEX_SHADER); GLuint ShaderObj2 = glCreateShader(GL_FRAGMENT_SHADER); loadShader("./Shaders/Fragment.fs", GL_FRAGMENT_SHADER, ShaderObj2, ShaderProgram); loadShader("./Shaders/Vertices.vs", GL_VERTEX_SHADER, ShaderObj, ShaderProgram); glBindAttribLocation(ShaderProgram, 0, "Position"); glLinkProgram(ShaderProgram); std::cout << glGetAttribLocation(ShaderProgram, "Position") << std::endl; std::cout << glGetAttribLocation(ShaderProgram, "TexCoord") << std::endl; std::cout << glGetAttribLocation(ShaderProgram, "Normal") << std::endl; GLint success; GLchar ErrorLog[1024]; glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &success); if (success == 0) { glGetProgramInfoLog(ShaderProgram, sizeof(ErrorLog), NULL, ErrorLog); fprintf(stderr, "Error linking shader program: '%s'\n", ErrorLog); } else std::cout << "Linking shader program success" << endl; glValidateProgram(ShaderProgram); glUseProgram(ShaderProgram); GLuint gWorldLocation = glGetUniformLocation(ShaderProgram, "gWorld"); assert(gWorldLocation != 0xFFFFFFFF); eng->Start(); return 0; }
void P_run() { if(window.isActive) { double elapsed_time; double current_time = T_GetCurrentTime(); if(movesize_time < 0.05f) movesize_time = 0.0f; elapsed_time = (current_time - last_game_time - movesize_time) + remaining_game_time ; movesize_time = 0.0f; while (elapsed_time >= S_PER_GAME_UPDATE*fps_mult) { G_update(elapsed_time); elapsed_time -= S_PER_GAME_UPDATE*fps_mult; } remaining_game_time = elapsed_time; last_game_time = current_time; P_computeFPS(); R_draw(window.hDC); if(btogglefullscreen || bmodechange) { last_movesize_time = T_GetCurrentTime(); if(btogglefullscreen) { P_cleanup(); window.createGLWindow(true); btogglefullscreen = false; GL_initializeGLObjects(); } else { window.createGLWindow(false); bmodechange = false; } movesize_time = T_GetCurrentTime() - last_movesize_time; } } }
static void motion (GtkWidget *widget, GdkEventMotion *event, gpointer data) { GLWindow *wnd = (GLWindow*)data; guint32 flags = 0; if ((event->state & GDK_BUTTON1_MASK) != 0) flags |= MK_LBUTTON; if ((event->state & GDK_BUTTON2_MASK) != 0) flags |= MK_MBUTTON; if ((event->state & GDK_BUTTON3_MASK) != 0) flags |= MK_RBUTTON; if ((event->state & GDK_CONTROL_MASK) != 0) flags |= MK_CONTROL; if ((event->state & GDK_SHIFT_MASK) != 0) flags |= MK_SHIFT; wnd->OnMouseMove (flags, (int)event->x, (int)event->y); }
bool updateModule(){ static int userLastStatus[MAX_USERS] = {-1}; for(int userID = 0; userID < MAX_USERS; userID++){ if(userLastStatus[userID] != _kinect->getSkeletonState(userID)){ userLastStatus[userID] = _kinect->getSkeletonState(userID); printf("USER %d HAS STATUS %d\n",userID,userLastStatus[userID]); } Matrix skeletonOrientation[TOTAL_JOINTS]; Vector skeletonPosition[TOTAL_JOINTS]; double confPosition[TOTAL_JOINTS], confOrientation[TOTAL_JOINTS]; if(!_kinect->getSkeletonOrientation(skeletonOrientation,confOrientation,userID)) continue; _kinect->getSkeletonPosition(skeletonPosition,confPosition,userID); _glWindow->setData(userID,userLastStatus[userID],skeletonOrientation, confPosition,skeletonPosition,confOrientation); _glWindow->redraw(); } ImageOf<PixelInt> img = _kinect->getDepthMap(); imgPort.prepare() = img; imgPort.write(); return true; };
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { MSG msg; BOOL quit = FALSE; G_initializeGame(); window.createGLWindow("Level Editor", WndProc); GL_initializeGLObjects(); ShowWindow(window.hWnd,SW_SHOW); last_game_time = T_GetCurrentTime(); while ( !quit ) { if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { if ( msg.message == WM_QUIT ) { quit = TRUE; } else { TranslateMessage( &msg ); DispatchMessage( &msg ); } } else { P_run(); } } P_cleanup(); window.destroyGLWindow(); return msg.wParam; }
static void button_release (GtkWidget *widget, GdkEventButton *event, gpointer data) { GLWindow *wnd = (GLWindow*)data; guint32 flags = 0; gdk_pointer_ungrab (GDK_CURRENT_TIME); if ((event->state & GDK_CONTROL_MASK) != 0) flags |= MK_CONTROL; if ((event->state & GDK_SHIFT_MASK) != 0) flags |= MK_SHIFT; switch (event->button) { case 1: wnd->OnLButtonUp (flags, (int)event->x, (int)event->y); break; case 2: wnd->OnMButtonUp (flags, (int)event->x, (int)event->y); break; case 3: wnd->OnRButtonUp (flags, (int)event->x, (int)event->y); break; } }
int main(int argc, char* argv[]) { Settings *settings = Settings::Instance(); settings->doCommandLineOptions(argc,argv); if ( settings->getCVar("headless") ) { Headless headless; headless.create(); Evolution* mainscene = new Evolution(); headless.runGLScene(mainscene); delete mainscene; } else { GLWindow glwindow; glwindow.create("Critterding beta12", 800, 600); Evolution* mainscene = new Evolution(); glwindow.runGLScene(mainscene); delete mainscene; } }
void shader_fireball( GLWindow& window, GLRenderer& renderer ) { auto camera = PerspectiveCamera::create( 40, (float)renderer.width() / renderer.height(), 1, 3000 ); camera->position().z = 4; auto scene = Scene::create(); float time = 1; auto material = ShaderMaterial::create( vertexShader, fragmentShader, Uniforms().add("time", Uniform( THREE::f, time )) .add("scale", Uniform( THREE::f, 1.5f )) ); // Geometries auto mesh = Mesh::create( SphereGeometry::create( 0.75f, 64, 32 ), material ); scene->add( mesh ); renderer.setClearColor( Color(0x050505), 0 ); ///////////////////////////////////////////////////////////////////////// window.animate( [&]( float dt ) -> bool { time += dt; material->uniforms[ "time" ].value = time; mesh->rotation().x += 0.1f * dt; mesh->rotation().y += 0.5f * dt; renderer.render( *scene, *camera ); return true; } ); }
static void MoveCamera(FPSCamera &cam, GLWindow &window, float speed) { if(window.Key(Key_lshift)) speed *= 5.f; if(window.MouseKey(0)) { window.GrabMouse(1); float dx = window.MouseMove().x; float dy = window.MouseMove().y; if(dx) cam.Rotate(dx * 0.005); if(dy) cam.RotateY(dy * 0.005); } else window.GrabMouse(0); Vec3f move(0, 0, 0); Camera tcam = (Camera)cam; if(window.Key('W')) move += tcam.front; if(window.Key('S')) move -= tcam.front; if(window.Key('A')) move += tcam.right; if(window.Key('D')) move -= tcam.right; if(window.Key('R')) move += tcam.up; if(window.Key('F')) move -= tcam.up; cam.Move(move * speed); }
static void button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) { GLWindow *wnd = (GLWindow*)data; guint32 flags = 0; gdk_pointer_grab (widget->window, FALSE, (GdkEventMask)(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), NULL, NULL, GDK_CURRENT_TIME); gtk_window_set_focus (GTK_WINDOW (g_pParentWnd->m_pWidget), widget); switch (event->button) { case 1: flags |= MK_LBUTTON; break; case 2: flags |= MK_MBUTTON; break; case 3: flags |= MK_RBUTTON; break; #if !GTK_CHECK_VERSION (1,3,0) case 4: wnd->OnMouseWheel(true); break; case 5: wnd->OnMouseWheel(false); break; #endif } if ((event->state & GDK_CONTROL_MASK) != 0) flags |= MK_CONTROL; if ((event->state & GDK_SHIFT_MASK) != 0) flags |= MK_SHIFT; if (event->type == GDK_BUTTON_PRESS) { switch (event->button) { case 1: wnd->OnLButtonDown (flags, (int)event->x, (int)event->y); break; case 2: wnd->OnMButtonDown (flags, (int)event->x, (int)event->y); break; case 3: wnd->OnRButtonDown (flags, (int)event->x, (int)event->y); break; } } else if (event->type == GDK_2BUTTON_PRESS) { // do nothing } }
void GLFramebuffer::showAttachmentContent(GLWindow &window, const string &attachment, uint16_t x, uint16_t y, uint16_t w, uint16_t h) { GLFramebuffer::bind(*this, READ); GLint textureUnit = 0; for(const auto &a : m_attachments) { if(a.second.name == attachment) { // Determine texture unit textureUnit = a.second.attachmentSlot; // FBO attachment ID if(textureUnit == GL_DEPTH_ATTACHMENT) textureUnit = m_colorAttachmentCount; // Depth attachment else textureUnit -= GL_COLOR_ATTACHMENT0; // Color attachment break; } } glPushAttrib(GL_VIEWPORT_BIT); glViewport(x, y, w, h); m_blitShader->use(); m_blitShader->getUniform("uTextureUnit").set(textureUnit); window.renderFullscreenQuad(); glPopAttrib(); }
int WINAPI WinMain( HINSTANCE hInstance, // Дескриптор приложения HINSTANCE hPrevInstance, // Дескриптор родительского приложения LPSTR lpCmdLine, // Параметры командной строки int nCmdShow ) // Состояние отображения окна { MSG msg; // Структура для хранения сообщения Windows BOOL done = false; // Логическая переменная для выхода из цикла glwWnd.fullscreen = false; // Оконный режим // Создать наше OpenGL окно if( !glwWnd.CreateGLWindow("Photon", 400, 400, 32) ) { return 0; // Выйти, если окно не может быть создано } srand(time(NULL)); randNumGen = gsl_rng_alloc(gsl_rng_mt19937); glwWnd.Resolution = vpViewport.Resolution; vpViewport.SceneInit(); ImageSensor &isSensor_a = vpViewport.oWorld.isSensor; while( !done ) // Цикл продолжается, пока done не равно true { if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) // Есть ли в очереди какое-нибудь сообщение? { if( msg.message == WM_QUIT ) // Мы поучили сообщение о выходе? { done = true; // Если так, done=true } else // Если нет, обрабатывает сообщения { TranslateMessage( &msg ); // Переводим сообщение DispatchMessage( &msg ); // Отсылаем сообщение } } else // Если нет сообщений { // Прорисовываем сцену. if( glwWnd.active ) // Активна ли программа? { if(glwWnd.keys[VK_ESCAPE]) // Было ли нажата клавиша ESC? { done = true; // ESC говорит об останове выполнения программы } else // Не время для выхода, обновим экран. { vpViewport.OneStep(); glwWnd.DrawGLScene(isSensor_a); // Рисуем сцену isSensor_a.Clear(); double cng = 1.01; double nng = 0.1; if(glwWnd.keys[107] == true){ vpViewport.oWorld.lLens.x+=nng;} //vpViewport.oWorld.lLens.Focus*=cng;} if(glwWnd.keys[109] == true){ vpViewport.oWorld.lLens.x-=nng;} //vpViewport.oWorld.lLens.Focus/=cng;} if(glwWnd.keys[32] == true){ vpViewport.oWorld.isSensor.ClearMode = SENSOR_ONE_CLEAR;} SwapBuffers( glwWnd.hDC ); // Меняем буфер (двойная буферизация) } } } } glwWnd.KillGLWindow(); // Разрушаем окно return ( msg.wParam ); // Выходим из программы }
/* This function currently always performs occlusion detection to minimize paint regions. OpenGL precision requirements are no good enough to guarantee that the results from using occlusion detection is the same as without. It's likely not possible to see any difference with most hardware but occlusion detection in the transformed screen case should be made optional for those who do see a difference. */ void PrivateGLScreen::paintOutputRegion (const GLMatrix &transform, const CompRegion ®ion, CompOutput *output, unsigned int mask) { CompRegion tmpRegion (region); CompWindow *w; GLWindow *gw; int windowMask, odMask; bool status, unredirectFS; bool withOffset = false; GLMatrix vTransform; CompPoint offXY; std::set<CompWindow*> unredirected; CompWindowList pl; CompWindowList::reverse_iterator rit; unredirectFS = CompositeScreen::get (screen)-> getOption ("unredirect_fullscreen_windows")->value ().b (); const CompMatch &unredirectable = CompositeScreen::get (screen)-> getOption ("unredirect_match")->value ().match (); const CompString &blacklist = getOption ("unredirect_driver_blacklist")->value ().s (); bool blacklisted = driverIsBlacklisted (blacklist.c_str ()); if (mask & PAINT_SCREEN_TRANSFORMED_MASK) { windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK; } else { windowMask = 0; } /* * We need to COPY the PaintList for now because there seem to be some * odd cases where the master list might change during the below loops. * (LP: #958540) */ pl = cScreen->getWindowPaintList (); if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) { FullscreenRegion fs (*output, screen->region ()); /* detect occlusions */ for (rit = pl.rbegin (); rit != pl.rend (); ++rit) { w = (*rit); gw = GLWindow::get (w); if (w->destroyed ()) continue; if (!w->shaded ()) { /* Non-damaged windows don't have valid pixmap * contents and we aren't displaying them yet * so don't factor them into occlusion detection */ if (!gw->priv->cWindow->damaged ()) { gw->priv->clip = region; continue; } if (!w->isViewable ()) continue; } /* copy region */ gw->priv->clip = tmpRegion; odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK; if ((cScreen->windowPaintOffset ().x () != 0 || cScreen->windowPaintOffset ().y () != 0) && !w->onAllViewports ()) { withOffset = true; offXY = w->getMovementForOffset (cScreen->windowPaintOffset ()); vTransform = transform; vTransform.translate (offXY.x (), offXY.y (), 0); gw->priv->clip.translate (-offXY.x (), -offXY. y ()); odMask |= PAINT_WINDOW_WITH_OFFSET_MASK; status = gw->glPaint (gw->paintAttrib (), vTransform, tmpRegion, odMask); } else { withOffset = false; status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion, odMask); } if (status) { if (withOffset) { tmpRegion -= w->region ().translated (offXY); } else tmpRegion -= w->region (); } FullscreenRegion::WinFlags flags = 0; if (w->type () & CompWindowTypeDesktopMask) flags |= FullscreenRegion::Desktop; if (w->alpha ()) flags |= FullscreenRegion::Alpha; /* Anything which was not occlusion detected is not a suitable * candidate for unredirection either */ if (!status) flags |= FullscreenRegion::NoOcclusionDetection; CompositeWindow *cw = CompositeWindow::get (w); /* * Windows with alpha channels can partially occlude windows * beneath them and so neither should be unredirected in that case. * * Performance note: unredirectable.evaluate is SLOW because it * involves regex matching. Too slow to do on every window for * every frame. So we only call it if a window is redirected AND * potentially needs unredirecting. This means changes to * unredirect_match while a window is unredirected already may not * take effect until it is un-fullscreened again. But that's better * than the high price of regex matching on every frame. */ if (unredirectFS && !blacklisted && !(mask & PAINT_SCREEN_TRANSFORMED_MASK) && !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) && fs.isCoveredBy (w->region (), flags) && (!cw->redirected () || unredirectable.evaluate (w))) { unredirected.insert (w); } else { if (!cw->redirected ()) { if (fs.allowRedirection (w->region ())) { // 1. GLWindow::release to force gw->priv->needsRebind gw->release (); // 2. GLWindow::bind, which redirects the window, // rebinds the pixmap, and then rebinds the pixmap // to a texture. gw->bind (); // 3. Your window is now redirected again with the // latest pixmap contents. } else { unredirected.insert (w); } } } } } /* Unredirect any redirected fullscreen windows */ foreach (CompWindow *fullscreenWindow, unredirected) CompositeWindow::get (fullscreenWindow)->unredirect (); if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK)) paintBackground (transform, tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK)); /* paint all windows from bottom to top */ foreach (w, pl) { if (w->destroyed ()) continue; gw = GLWindow::get (w); /* Release any queued ConfigureWindow requests now */ gw->priv->configureLock->release (); if (unredirected.find (w) != unredirected.end ()) continue; if (!w->shaded ()) { if (!w->isViewable ()) continue; } const CompRegion &clip = (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ? gw->clip () : region; if ((cScreen->windowPaintOffset ().x () != 0 || cScreen->windowPaintOffset ().y () != 0) && !w->onAllViewports ()) { offXY = w->getMovementForOffset (cScreen->windowPaintOffset ()); vTransform = transform; vTransform.translate (offXY.x (), offXY.y (), 0); gw->glPaint (gw->paintAttrib (), vTransform, clip, windowMask | PAINT_WINDOW_WITH_OFFSET_MASK); } else { gw->glPaint (gw->paintAttrib (), transform, clip, windowMask); } } }
LRESULT CALLBACK GLWindow::WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { GLWindow* instance = (GLWindow*) GetWindowLongPtr(hwnd, GWL_USERDATA); switch (msg) { case WM_CREATE: { CREATESTRUCT* create = (CREATESTRUCT*) lParam; instance = (GLWindow*) create->lpCreateParams; SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR) instance); return 0; } case WM_SIZE: instance->OnResize(LOWORD(lParam), HIWORD(lParam)); return 0; case WM_CLOSE: DestroyWindow(hwnd); case WM_DESTROY: PostQuitMessage(0); return 0; case WM_KEYDOWN: instance->OnKeyDown(wParam); return 0; case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: SetCapture(hwnd); instance->OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_RBUTTONUP: case WM_LBUTTONUP: ReleaseCapture(); instance->OnMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEMOVE: instance->OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_ERASEBKGND: return 1; case WM_PAINT: if (GetUpdateRect(hwnd, NULL, FALSE)) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); instance->OnRender(); SwapBuffers(hdc); EndPaint(hwnd, &ps); } return 0; default: return DefWindowProc(hwnd, msg, wParam, lParam); } }