void ofxFenster::move(int x, int y) {
	ofPoint p = getWindowPosition();
	int nx, ny;
	//win->screenToClient(p.x+x, p.y+y, nx, ny);
	nx = p.x + x;
	ny = p.y + y;
	setWindowPosition(nx, ny);
}
Exemplo n.º 2
0
void NativeWindow::setPosition(int x, int y)
{
	_x = x;
	_y = y;

	int returnCode = setWindowPosition(_x, _y);
	if (returnCode) {
		perror("window position");
	}
}
Exemplo n.º 3
0
void Waveform::audioPositionChanged(qint64 position)
{
    WAVEFORM_DEBUG << "Waveform::audioPositionChanged"
                   << "audioPosition" << position
                   << "bufferPosition" << m_bufferPosition
                   << "bufferLength" << m_bufferLength;

    if (position >= m_bufferPosition) {
        if (position + m_windowLength > m_bufferPosition + m_bufferLength)
            position = qMax(qint64(0), m_bufferPosition + m_bufferLength - m_windowLength);
        m_audioPosition = position;
        setWindowPosition(position);
    }
}
Exemplo n.º 4
0
BOOL CDirectionDlg::OnInitDialog() {
  __super::OnInitDialog();
  int selectedButton = IDCANCEL;

  switch(m_dir) {
  case S : selectedButton = IDC_BUTTONS ; break;
  case E : selectedButton = IDC_BUTTONE ; break;
  case N : selectedButton = IDC_BUTTONN ; break;
  case W : selectedButton = IDC_BUTTONW ; break;
  }

  GetDlgItem(selectedButton)->SetFocus();
  setWindowText(this, IDC_STATICMSG, format(_T("Is start direction %s Ok?"), directionName[m_dir]));
  setWindowPosition(this, CPoint(700,100));
  return FALSE;
}
Exemplo n.º 5
0
/**
 * Constructor
 */
SelectFileScreen::SelectFileScreen() {

	state = ENTERING_SCREEN;

	deletePromptActive = false;
	selectedFile = 0;
	yesDeleteBox = new hgeRect();
	noDeleteBox = new hgeRect();
	difficultyPrompt = new DifficultyPrompt();

	//Buttons
	buttons[SFS_BACK_BUTTON] = new Button(0, 0, "Back");
	buttons[SFS_DELETE_BUTTON] = new Button(0, 0, "Delete");
	buttons[SFS_START_BUTTON] = new Button(0, 0, "Start");

	for (int i = 0; i < 4; i++) {
		saveBoxes[i].collisionBox = new hgeRect();
	}
	
	setWindowPosition(182.0, -512.0);
}
Exemplo n.º 6
0
/**
 * Updates the load screen
 */
bool SelectFileScreen::update(float dt, float mouseX, float mouseY) {

	if (difficultyPrompt->visible) {
		int result = difficultyPrompt->update(dt);
		if (result == -1) {
			return false;
		} else {
			smh->saveManager->difficulty = result;
		}
	}

	if (state == ENTERING_SCREEN) {
		setWindowPosition(windowX, windowY + 1800.0 * dt);
		if (windowY >= 138.0) {
			state = IN_SCREEN;
			windowY = 138.0;
			setWindowPosition(windowX, windowY);
		}
	} else if (state == EXITING_SCREEN) {
		setWindowPosition(windowX, windowY - 1800.0 * dt);
		if (windowY <= -512.0) {
			//Done exiting screen - perform action based on what button was clicked
			switch (clickedButton) {
				case SFS_BACK_BUTTON:
					smh->menu->setScreen(MenuScreens::TITLE_SCREEN);
					return false;
				case SFS_START_BUTTON:
					smh->menu->openLoadScreen(selectedFile, true);
					return false;
			}
		}
	}

	//Set "start" button text based on whether or not an empty file is selected
	buttons[SFS_START_BUTTON]->setText(smh->saveManager->isFileEmpty(selectedFile) ? "Start" : "Continue");
	
	//Update buttons
	for (int i = 0; i < SFS_NUM_BUTTONS; i++) {
		buttons[i]->update(dt);
		if (buttons[i]->isClicked() && i != SFS_DELETE_BUTTON) {
			clickedButton = i;
			state = EXITING_SCREEN;
			if (i == SFS_START_BUTTON && smh->saveManager->isFileEmpty(selectedFile)) {
				difficultyPrompt->visible = true;
			}
		}
	}

	//Click delete button
	if (buttons[SFS_DELETE_BUTTON]->isClicked()) {
		if (!smh->saveManager->isFileEmpty(selectedFile)) {
			deletePromptActive = true;
		}
	}

	//Update save box selection
	if (!deletePromptActive) {
		for (int i = 0; i < 4; i++) {
			if ((smh->hge->Input_KeyDown(HGEK_LBUTTON) || smh->input->keyPressed(INPUT_ATTACK)) && saveBoxes[i].collisionBox->TestPoint(mouseX, mouseY)) {
				selectedFile = i;
			}
		}
	}

	//Listen for response to delete prompt
	if (deletePromptActive) {

		yesDeleteBox->Set(saveBoxes[selectedFile].x + 100.0,		saveBoxes[selectedFile].y + 60.0, 
						  saveBoxes[selectedFile].x + 100.0 + 50.0,	saveBoxes[selectedFile].y + 60.0 + 35.0);
		noDeleteBox->Set( saveBoxes[selectedFile].x + 180.0,		saveBoxes[selectedFile].y + 60.0, 
						  saveBoxes[selectedFile].x + 180.0 + 50.0,	saveBoxes[selectedFile].y + 60.0 + 35.0);

		mouseOverYes = yesDeleteBox->TestPoint(smh->input->getMouseX(), smh->input->getMouseY());
		mouseOverNo = noDeleteBox->TestPoint(smh->input->getMouseX(), smh->input->getMouseY());

		if (mouseOverYes && smh->hge->Input_KeyDown(HGEK_LBUTTON)) {
			smh->saveManager->deleteFile(selectedFile);
			deletePromptActive = false;
		}
		if (mouseOverNo && smh->hge->Input_KeyDown(HGEK_LBUTTON)) {
			deletePromptActive = false;
		}
	}

	//Move the Smiley selector towards the selected file
	if (smileyY > saveBoxes[selectedFile].y + 45.0) {
		smileyY -= 750.0 * dt;
		if (smileyY < saveBoxes[selectedFile].y + 45.0) {
			smileyY = saveBoxes[selectedFile].y + 45.0;
		}
	} else if (smileyY < saveBoxes[selectedFile].y + 45.0) {
		smileyY += 750.0 * dt;
		if (smileyY > saveBoxes[selectedFile].y + 45.0) {
			smileyY = saveBoxes[selectedFile].y + 45.0;
		}
	}
	
	return false;
}
int OpenGLView::regenerate() {
	int returnCode;
	EGLBoolean status;
	EGLint interval = 1;

	OpenGLView::m_renderMutex.lock();

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_WIDTH, &m_surface_width);
	if (status != EGL_TRUE) {
		perror("query surface width");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_HEIGHT, &m_surface_height);
	if (status != EGL_TRUE) {
		perror("query surface height");
		return EXIT_FAILURE;
	}

/*
	rc = screen_get_window_property_iv(m_screen_win, SCREEN_PROPERTY_ROTATION, &rotation);
	if (rc) {
		perror("screen_set_window_property_iv");
		return EXIT_FAILURE;
	}

	rc = screen_get_window_property_iv(m_screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
	if (rc) {
		perror("screen_set_window_property_iv");
		return EXIT_FAILURE;
	}

	switch (angle - rotation) {
		case -270:
		case -90:
		case 90:
		case 270:
			temp = size[0];
			size[0] = size[1];
			size[1] = temp;
			skip = 0;
			break;
	}
*/

	status = eglMakeCurrent(m_egl_disp, NULL, NULL, NULL);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglMakeCurrent");
		return EXIT_FAILURE;
	}

	status = eglDestroySurface(m_egl_disp, m_egl_surf);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglMakeCurrent");
		return EXIT_FAILURE;
	}

	returnCode = setWindowPosition(m_x, m_y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(m_width, m_height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}
/*
	setWindowAngle(m_angle);
	if (returnCode) {
		perror("window angle");
		return EXIT_FAILURE;
	}
*/
	returnCode = setWindowSourceSize(m_width, m_height);
	if (returnCode) {
		perror("unable to set window source size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowBufferSize(m_width, m_height);
	if (returnCode) {
		perror("buffer size");
		return EXIT_FAILURE;
	}

	m_egl_surf = eglCreateWindowSurface(m_egl_disp, m_egl_conf, m_screen_win, NULL);
	if (m_egl_surf == EGL_NO_SURFACE) {
		OpenGLThread::eglPrintError("eglCreateWindowSurface");
		return EXIT_FAILURE;
	}

	getGLContext();

    status = eglSwapInterval(m_egl_disp, interval);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglSwapInterval");
		return EXIT_FAILURE;
	}

	OpenGLView::m_renderMutex.unlock();

	setAltered(false);

	setStale(true);

	return EXIT_SUCCESS;
}
int OpenGLView::initGL()
{
    int numberDisplays;
    int numberModes;
    int returnCode;
    EGLBoolean status;
    int type;
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
                            EGL_NONE};

    // try this first as it will fail if an HDMI display is not attached
    if (m_api == GL_ES_2) {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, attributes);
    } else {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, NULL);
    }
    if (m_egl_ctx == EGL_NO_CONTEXT) {
        perror("eglCreateContext");
        return EXIT_FAILURE;
    }

	screen_get_context_property_iv(m_screen_ctx, SCREEN_PROPERTY_DISPLAY_COUNT, &numberDisplays);

	m_screen_dpy = (screen_display_t *)calloc(numberDisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(m_screen_ctx, SCREEN_PROPERTY_DISPLAYS, (void **)m_screen_dpy);


	for (int index = 0; index < numberDisplays; index++) {
		int displayID;

        returnCode = screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_ID,  (int *)&displayID);
    	if (returnCode) {
    		perror("display ID");
    		return EXIT_FAILURE;
    	} else {
			if (displayID == m_display) {
			    screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_TYPE,  &type);
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
			    	returnCode = screen_create_window(&m_screen_win, m_screen_ctx);
			    	if (returnCode) {
			            perror("screen_create_window");
			            return EXIT_FAILURE;
			        }
			    } else {
			    	returnCode = screen_create_window_type(&m_screen_win, m_screen_ctx, SCREEN_CHILD_WINDOW);
			    	if (returnCode) {
			            perror("screen_create_window (child window)");
			            return EXIT_FAILURE;
			        }
			    }
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
					returnCode = screen_set_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&(m_screen_dpy[index]));
					if (returnCode) {
						perror("window display");
						return EXIT_FAILURE;
					}
		        }
			}
        }
	}

	qDebug()  << "OpenGLView::initialize: "<< m_screen_ctx << ":" << m_egl_disp << ":" << m_egl_conf << ":" << m_egl_ctx << ":" << m_screen_win;


	int format = SCREEN_FORMAT_RGBA8888;
	returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_FORMAT, &format);
	if (returnCode) {
		perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return EXIT_FAILURE;
	}

	if (m_transparency > 0) {
		returnCode = setWindowTransparency(m_transparency);
		if (returnCode) {
			perror("transparency");
			return EXIT_FAILURE;
		}
	}

	returnCode = screen_get_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&m_screen_disp);
	if (returnCode) {
		perror("screen_get_window_property_pv");
		return EXIT_FAILURE;
	}

	int angle = atoi(getenv("ORIENTATION"));

	screen_get_display_property_iv(m_screen_disp, SCREEN_PROPERTY_MODE_COUNT, &numberModes);

	m_screen_modes = (screen_display_mode_t *)calloc(numberModes, sizeof(screen_display_mode_t));
	returnCode = screen_get_display_property_pv(m_screen_disp, SCREEN_PROPERTY_MODE, (void**)m_screen_modes);
	if (returnCode) {
		perror("screen modes");
		return EXIT_FAILURE;
	}

    int dpi = calculateDPI();
    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowPosition(m_x, m_y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(m_width, m_height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowZ(m_z);
	if (returnCode) {
		perror("z order");
		return EXIT_FAILURE;
	}

	returnCode = setWindowBufferSize(m_width, m_height);
	if (returnCode) {
		perror("buffer size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowAngle(m_angle);
	if (returnCode) {
		perror("angle");
		return EXIT_FAILURE;
	}

	returnCode = screen_create_window_buffers(m_screen_win, m_nbuffers);
	if (returnCode) {
		perror("screen_create_window_buffers");
		return EXIT_FAILURE;
	}


    if (m_api == GL_ES_1) {
        m_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
    } else if (m_api == GL_ES_2) {
    	attrib_list[9] = EGL_OPENGL_ES2_BIT;
    	m_usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
    } else if (m_api == VG) {
    	attrib_list[9] = EGL_OPENVG_BIT;
    	m_usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
    } else {
        fprintf(stderr, "invalid api setting\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowUsage(m_usage);
	if (returnCode) {
		perror("screen_set_window_property_iv(window usage)");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL:eglCreateContext "<< m_egl_ctx;
	m_egl_surf = eglCreateWindowSurface(m_egl_disp, m_egl_conf, m_screen_win, NULL);
	if (m_egl_surf == EGL_NO_SURFACE) {
		OpenGLThread::eglPrintError("eglCreateWindowSurface");
		return EXIT_FAILURE;
	}

	getGLContext();

    EGLint interval = 1;
    status = eglSwapInterval(m_egl_disp, interval);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglSwapInterval");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_WIDTH, &m_surface_width);
	if (status != EGL_TRUE) {
		perror("query surface width");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_HEIGHT, &m_surface_height);
	if (status != EGL_TRUE) {
		perror("query surface height");
		return EXIT_FAILURE;
	}

	returnCode = joinWindowGroup(m_group);
	if (returnCode) {
		perror("window group");
		return EXIT_FAILURE;
	}

	returnCode = setScreenWindowID(m_id);
	if (returnCode) {
		perror("window ID");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL: "<< angle << ":" << numberModes << ":" << m_screen_modes[0].width << ":" << m_screen_modes[0].height << ":" << m_egl_disp << ":" << dpi;

	setInitialized(true);

	return EXIT_SUCCESS;
}
Exemplo n.º 9
0
// Actually put us in windowed or full screen mode.  Pass true the first time this is used, false subsequently.
// This has the unfortunate side-effect of triggering a mouse move event.
void VideoSystem::actualizeScreenMode(GameSettings *settings, bool changingInterfaces, bool currentUIUsesEditorScreenMode)
{
   DisplayMode displayMode = settings->getSetting<DisplayMode>(IniKey::WindowMode);

   DisplayManager::getScreenInfo()->resetGameCanvasSize();     // Set GameCanvasSize vars back to their default values
   DisplayManager::getScreenInfo()->setActualized();


   // If old display mode is windowed or current is windowed but we change interfaces,
   // save the window position
   if(settings->getIniSettings()->oldDisplayMode == DISPLAY_MODE_WINDOWED ||
         (changingInterfaces && displayMode == DISPLAY_MODE_WINDOWED))
   {
      settings->setWindowPosition(VideoSystem::getWindowPositionX(), VideoSystem::getWindowPositionY());
   }

   // When we're in the editor, let's take advantage of the entire screen unstretched
   // We might want to disallow this when we're in split screen mode?
   if(currentUIUsesEditorScreenMode &&
         (displayMode == DISPLAY_MODE_FULL_SCREEN_STRETCHED || displayMode == DISPLAY_MODE_FULL_SCREEN_UNSTRETCHED))
   {
      // Smaller values give bigger magnification; makes small things easier to see on full screen
      F32 magFactor = 0.85f;

      // For screens smaller than normal, we need to readjust magFactor to make sure we get the full canvas height crammed onto
      // the screen; otherwise our dock will break.  Since this mode is only used in the editor, we don't really care about
      // screen width; tall skinny screens will work just fine.
      magFactor = max(magFactor, (F32)DisplayManager::getScreenInfo()->getGameCanvasHeight() / (F32)DisplayManager::getScreenInfo()->getPhysicalScreenHeight());

      DisplayManager::getScreenInfo()->setGameCanvasSize(S32(DisplayManager::getScreenInfo()->getPhysicalScreenWidth() * magFactor), S32(DisplayManager::getScreenInfo()->getPhysicalScreenHeight() * magFactor));

      displayMode = DISPLAY_MODE_FULL_SCREEN_STRETCHED;
   }


   // Set up video/window flags amd parameters and get ready to change the window
   S32 sdlWindowWidth, sdlWindowHeight;
   F64 orthoLeft, orthoRight, orthoTop, orthoBottom;

   getWindowParameters(settings, displayMode, sdlWindowWidth, sdlWindowHeight, orthoLeft, orthoRight, orthoTop, orthoBottom);

   // Change video modes based on selected display mode
   // Note:  going into fullscreen you have to do in order:
   //  - SDL_SetWindowSize()
   //  - SDL_SetWindowFullscreen()
   //
   // However, coming out of fullscreen mode you must do the reverse
   switch (displayMode)
   {
   case DISPLAY_MODE_FULL_SCREEN_STRETCHED:
      SDL_SetWindowSize(DisplayManager::getScreenInfo()->sdlWindow, sdlWindowWidth, sdlWindowHeight);
      SDL_SetWindowFullscreen(DisplayManager::getScreenInfo()->sdlWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);

      break;

   case DISPLAY_MODE_FULL_SCREEN_UNSTRETCHED:
      SDL_SetWindowSize(DisplayManager::getScreenInfo()->sdlWindow, sdlWindowWidth, sdlWindowHeight);
      SDL_SetWindowFullscreen(DisplayManager::getScreenInfo()->sdlWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);

      break;

   case DISPLAY_MODE_WINDOWED:
   default:
      // Reverse order, leave fullscreen before setting size
      SDL_SetWindowFullscreen(DisplayManager::getScreenInfo()->sdlWindow, 0);
      SDL_SetWindowSize(DisplayManager::getScreenInfo()->sdlWindow, sdlWindowWidth, sdlWindowHeight);
      break;
   }

   if(settings->getSetting<YesNo>(IniKey::DisableScreenSaver))
      SDL_DisableScreenSaver();
   else
      SDL_EnableScreenSaver();

   // Flush window events because SDL_SetWindowSize triggers a SDL_WINDOWEVENT_RESIZED 
   // event (which in turn triggers another SDL_SetWindowSize)
   SDL_FlushEvent(SDL_WINDOWEVENT);

   SDL_GL_SetSwapInterval(settings->getSetting<YesNo>(IniKey::Vsync) ? 1 : 0);

   // Now save the new window dimensions in ScreenInfo
   DisplayManager::getScreenInfo()->setWindowSize(sdlWindowWidth, sdlWindowHeight);

   mGL->glClearColor(0, 0, 0, 0);

   mGL->glViewport(0, 0, sdlWindowWidth, sdlWindowHeight);

   mGL->glMatrixMode(GLOPT::Projection);
   mGL->glLoadIdentity();

   // The best understanding I can get for glOrtho is that these are the coordinates you want to appear at the four corners of the
   // physical screen. If you want a "black border" down one side of the screen, you need to make left negative, so that 0 would
   // appear some distance in from the left edge of the physical screen.  The same applies to the other coordinates as well.
   mGL->glOrtho(orthoLeft, orthoRight, orthoBottom, orthoTop, 0, 1);

   mGL->glMatrixMode(GLOPT::Modelview);
   mGL->glLoadIdentity();

   // Do the scissoring
   if(displayMode == DISPLAY_MODE_FULL_SCREEN_UNSTRETCHED)
   {
      mGL->glScissor(DisplayManager::getScreenInfo()->getHorizPhysicalMargin(),    // x
                DisplayManager::getScreenInfo()->getVertPhysicalMargin(),     // y
                DisplayManager::getScreenInfo()->getDrawAreaWidth(),          // width
                DisplayManager::getScreenInfo()->getDrawAreaHeight());        // height
   }
   else
   {
      // Enabling scissor appears to fix crashing problem switching screen mode
      // in linux and "Mobile 945GME Express Integrated Graphics Controller",
      // probably due to lines and points was not being clipped,
      // causing some lines to wrap around the screen, or by writing other
      // parts of RAM that can crash Bitfighter, graphics driver, or the entire computer.
      // This is probably a bug in the Linux Intel graphics driver.
      mGL->glScissor(0, 0, DisplayManager::getScreenInfo()->getWindowWidth(), DisplayManager::getScreenInfo()->getWindowHeight());
   }

   mGL->glEnable(GLOPT::ScissorTest);    // Turn on clipping

   mGL->setDefaultBlendFunction();
   mGL->glLineWidth(RenderUtils::DEFAULT_LINE_WIDTH);

   // Enable Line smoothing everywhere!  Make sure to disable temporarily for filled polygons and such
   if(settings->getSetting<YesNo>(IniKey::LineSmoothing))
   {
      mGL->glEnable(GLOPT::LineSmooth);
      //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
   }

   mGL->glEnable(GLOPT::Blend);

   // Now set the window position
   if(displayMode == DISPLAY_MODE_WINDOWED)
   {
      // Sometimes it happens to be (0,0) hiding the top title bar preventing ability to
      // move the window, in this case we are not moving it unless it is not (0,0).
      // Note that ini config file will default to (0,0).
      if(settings->getWindowPositionX() != 0 || settings->getWindowPositionY() != 0)
         setWindowPosition(settings->getWindowPositionX(), settings->getWindowPositionY());
   }
   else
      setWindowPosition(0, 0);

   // Notify all active UIs that the screen has changed mode.  This will likely need some work to not do something
   // horrible in split-screen mode.
   const Vector<ClientGame *> *clientGames = GameManager::getClientGames();
   for(S32 i = 0; i < clientGames->size(); i++)
      if(clientGames->get(i)->getUIManager()->getCurrentUI())
         clientGames->get(i)->getUIManager()->getCurrentUI()->onDisplayModeChange();

   // Re-initialize our fonts because OpenGL textures can be lost upon screen change
   FontManager::reinitialize(settings);

   // This needs to happen after font re-initialization because I think fontstash interferes
   // with the oglconsole font somehow...
   GameManager::gameConsole->onScreenModeChanged();
}
Exemplo n.º 10
0
void ofAppGLFWWindow::setupOpenGL(int w, int h, int screenMode){

	requestedWidth = w;
	requestedHeight = h;
	

	if(!glfwInit( )){
		ofLog(OF_LOG_ERROR,"cannot init GLFW");
		return;
	}

	printf("WINDOW MODE IS %i", screenMode);

	windowMode = screenMode;

	glfwOpenWindowHint( GLFW_FSAA_SAMPLES, samples );
	// targets					default
	// GLFW_REFRESH_RATE			0
	// GLFW_ACCUM_RED_BITS;			0
	// GLFW_ACCUM_GREEN_BITS;		0
	// GLFW_ACCUM_BLUE_BITS;		0
	// GLFW_ACCUM_ALPHA_BITS;		0
	// GLFW_AUX_BUFFERS;			0
	// GLFW_STEREO;					0
	// GLFW_WINDOW_NO_RESIZE;		0
	// GLFW_FSAA_SAMPLES;			0

	int result;
	if (windowMode == OF_WINDOW){
		result = glfwOpenWindow(
		          w, h,          // Width and height of window
		          8, 8, 8,           // Number of red, green, and blue bits for color buffer
		          8,                 // Number of bits for alpha buffer
		          32,                // Number of bits for depth buffer (Z-buffer)
		          0,                 // Number of bits for stencil buffer
		          GLFW_WINDOW        // We want a desktop window (could be GLFW_FULLSCREEN)
		      );
	}else if(windowMode == OF_FULLSCREEN){
		result = glfwOpenWindow(
				  getScreenSize().x, getScreenSize().y,          // Width and height of window
				  8, 8, 8,           // Number of red, green, and blue bits for color buffer
				  8,                 // Number of bits for alpha buffer
				  32,                // Number of bits for depth buffer (Z-buffer)
				  0,                 // Number of bits for stencil buffer
				  GLFW_FULLSCREEN        // We want a desktop window (could be GLFW_FULLSCREEN)
			  );
		showCursor();
	}else if(windowMode == OF_GAME_MODE){
		result = glfwOpenWindow(
				  w, h,          // Width and height of window
				  8, 8, 8,           // Number of red, green, and blue bits for color buffer
				  8,                 // Number of bits for alpha buffer
				  32,                // Number of bits for depth buffer (Z-buffer)
				  0,                 // Number of bits for stencil buffer
				  GLFW_FULLSCREEN        // We want a desktop window (could be GLFW_FULLSCREEN)
			  );
		showCursor();
	}
	else
	{
		printf("**** invalid windowMode\n");
	}
	
	if ( result != GL_TRUE )
	{
		printf("**** failed to open glfw window\n");
	}
	else
		printf("*--- opened glfw window\n");

	setVerticalSync(false);
	// Set window title
	glfwSetWindowTitle( " " );

	glfwEnable( GLFW_KEY_REPEAT );

	// ofBackground(200,200,200);		// default bg color
	// ofSetColor(0xFFFFFF); 			// default draw color
	// used to be black, but
	// black + texture = black
	// so maybe grey bg
	// and "white" fg color
	// as default works the best...

	requestedHeight = requestedHeight < 1 ? 1 : requestedHeight;
	glfwGetWindowSize( &requestedWidth, &requestedHeight );
	
	

	nonFullScreenW = ofGetWidth();
	nonFullScreenH = ofGetHeight();
	
	

	glfwGetWindowSize( &windowW, &windowH );
		
    setWindowPosition(50, 50);
	
}
Exemplo n.º 11
0
/*! \brief parse the parameters received from the main container in QstringList form
    \param params the parameter list
*/
bool QtYARPScope::parseParameters(QStringList params)
{
    //YARP network initialization
    if (!yarp.checkNetwork()) {
        qCritical("Cannot connect to yarp network");
        return false;
    }
    else
    {
        connect(plotManager,SIGNAL(requestRepaint()),this,SLOT(onRepaint()),Qt::QueuedConnection);
    }
    // Setup resource finder
    yarp::os::ResourceFinder rf;
    rf.setVerbose();
    // TODO Read default values from yarpscope.ini
    rf.setDefaultConfigFile("yarpscope.ini");
    rf.setDefaultContext("yarpscope"); 

    // Transform Qt Params array in standard argc & argv
    int c = params.count();
    char **v;
    v = (char**)malloc(sizeof(char*) * c);
    for(int i=0;i<params.count();i++){
        v[i] = strdup(params.at(i).toLatin1().data());
    }

    if(!rf.configure(c, v)){
        usage();
        for(int i=0;i<params.count();i++) {
            free(v[i]);
        }
        free(v);
        return false;
    }

    qDebug("%s",rf.toString().data());

    if (rf.check("help")) {
        usage();
        for(int i=0;i<params.count();i++) {
            free(v[i]);
        }
        free(v);
        return false;
    }

    for(int i=0;i<params.count();i++) {
        free(v[i]);
    }
    free(v);

//********************** Deprecated options
    // local
    if (rf.check("local")) {
        qWarning() << "--local option is deprecated. YARPScope now uses \"${YARP_PORT_PREFIX}/YARPScope/${REMOTE_PORT_NAME}\"";
    }

    // rows
    if (rf.check("rows")) {
        qWarning() << "--rows option is deprecated. Use XML mode if you need more than one plot in a single window\"";
    }

    // cols
    if (rf.check("cols")) {
        qWarning() << "--cols option is deprecated. Use XML mode if you need more than one plot in a single window\"";
    }
//********************************************
//************************* Generic options
    int interval;
    // title
    if (rf.find("title").isString()) {
        emit setWindowTitle(QString("%1").arg(rf.find("title").asString().data()));
    }
    // position
    if (rf.find("x").isInt32() && rf.find("y").isInt32()) {
        emit setWindowPosition(rf.find("x").asInt32(), rf.find("y").asInt32());
    }
    // size
    if (rf.find("dx").isInt32() && rf.find("dy").isInt32()) {
        emit setWindowSize(rf.find("dx").asInt32(), rf.find("dy").asInt32());
    }
    // interval
    if (rf.find("interval").isInt32()) {
        interval = rf.find("interval").asInt32();
    }else{
        interval = 50;
    }
//*******************************************

    bool ok;
    if (rf.check("xml")) {
// XML Mode Options
        const std::string &filename = rf.findFile("xml");
        QString f = QString("%1").arg(filename.data());
        loader = new XmlLoader(f,plotManager,this);
        qDebug("Loading file %s",filename.c_str());
    } else {
// Command Line Mode Options
        qDebug("Loading from command line");
        loader = new SimpleLoader(&rf,plotManager, &ok,this);
        if (!ok) {
            usage();
            exit(1);
        }
    }
    plotManager->setInterval(interval);
    emit intervalLoaded(interval);


    updateCustomPlotSize();

    return true;
}
Exemplo n.º 12
0
int NativeWindow::initialize(bool _createFullWindow)
{
    int returnCode;
    int numberModes;
	screen_display_mode_t* screenModes;
    int type;

    if (_createFullWindow) {
    	returnCode = screen_create_window(&_screenWindow, _screenContext);
    	qDebug()  << "NativeWindow::initialize: _screenWindow (full window): " << ":" << _screenWindow << ":" << _screenContext << ":" << returnCode;

    	if (returnCode) {
            perror("screen_create_window");
            return EXIT_FAILURE;
        }

    } else {
    	returnCode = screen_create_window_type(&_screenWindow, _screenContext, SCREEN_CHILD_WINDOW);
    	qDebug()  << "NativeWindow::initialize: _screenWindow (child window): " << _screenWindow << ":" << returnCode;

    	if (returnCode) {
            perror("screen_create_window (child window)");
            return EXIT_FAILURE;
        }

    }

    _displaysMutex.lock();

    if (_screenDisplays) {
    	free (_screenDisplays);
    }

	// try this first as it will fail if an HDMI display is not attached
	screen_get_context_property_iv(_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &_numberDisplays);

	_screenDisplays = (screen_display_t *)calloc(_numberDisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)_screenDisplays);

	for (int index = 0; index < _numberDisplays; index++) {
		int displayID;

        returnCode = screen_get_display_property_iv(_screenDisplays[index], SCREEN_PROPERTY_ID,  (int *)&displayID);
    	qDebug()  << "NativeWindow::initialize: display: " << ":" << index << ":" << displayID << ":" << _display << ":" << _screenDisplays[index];

    	if (returnCode) {
    		perror("display ID");
    		return EXIT_FAILURE;
    	} else {
			if (displayID == _display) {
			    screen_get_display_property_iv(_screenDisplays[index], SCREEN_PROPERTY_TYPE,  &type);
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
					returnCode = screen_set_window_property_pv(_screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&(_screenDisplays[index]));

					if (returnCode) {
						perror("window display");
						return EXIT_FAILURE;
					}
		        }
			}
        }
	}

    _displaysMutex.unlock();


	qDebug()  << "NativeWindow::initialize: "<< _screenContext << ":" << _screenWindow;


    returnCode = setWindowFormat(_format);
	if (returnCode) {
		perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return EXIT_FAILURE;
	}

	returnCode = setWindowTransparency(_transparency);
	if (returnCode) {
		perror("transparency");
		return EXIT_FAILURE;
	}

	returnCode = screen_get_window_property_pv(_screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&_screenDisplay);
	if (returnCode) {
		perror("screenDisplay");
		return EXIT_FAILURE;
	}

	int angle = atoi(getenv("ORIENTATION"));

	screen_get_display_property_iv(_screenDisplay, SCREEN_PROPERTY_MODE_COUNT, &numberModes);

	screenModes = (screen_display_mode_t *)calloc(numberModes, sizeof(screen_display_mode_t));
	returnCode = screen_get_display_property_pv(_screenDisplay, SCREEN_PROPERTY_MODE, (void**)screenModes);
	if (returnCode) {
		perror("screen modes");
		return EXIT_FAILURE;
	}

    int dpi = calculateDPI();
    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowPosition(_x, _y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(_width, _height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowZ(_z);
	if (returnCode) {
		perror("z order");
		return EXIT_FAILURE;
	}

	if (_sourceWidth > 0) {
        returnCode = setWindowSourcePosition(_sourceX, _sourceY);
        if (returnCode) {
            perror("source size");
            return EXIT_FAILURE;
        }

        returnCode = setWindowSourceSize(_sourceWidth, _sourceHeight);
        if (returnCode) {
            perror("source size");
            return EXIT_FAILURE;
        }
	}

    if (_bufferWidth > 0) {
        returnCode = setWindowBufferSize(_bufferWidth, _bufferHeight);
        if (returnCode) {
            perror("buffer size");
            return EXIT_FAILURE;
        }
    }

	returnCode = setWindowAngle(_angle);
	if (returnCode) {
		perror("angle");
		return EXIT_FAILURE;
	}

	returnCode = screen_create_window_buffers(_screenWindow, _nbuffers);
	if (returnCode) {
		perror("screen_create_window_buffers");
		return EXIT_FAILURE;
	}

	_usage = Graphics::getNativeWindowUsage();
    // enable this in case we need any native API access to this window
    _usage |= SCREEN_USAGE_NATIVE;

	returnCode = setWindowUsage(_usage);
	if (returnCode) {
		perror("screen_set_window_property_iv(window usage)");
		return EXIT_FAILURE;
	}

	returnCode = joinWindowGroup(_group);
	if (returnCode) {
		perror("window group");
		return EXIT_FAILURE;
	}

	returnCode = setScreenWindowID(_id);
	if (returnCode) {
		perror("window ID");
		return EXIT_FAILURE;
	}

	qDebug()  << "NativeWindow::initialize: "<< angle << ":" << numberModes << ":" << screenModes[0].width << ":" << screenModes[0].height << ":" << dpi;

	if (screenModes != NULL) {
		free(screenModes);
	}

	return EXIT_SUCCESS;
}