コード例 #1
0
static void extrawindow_do_reshape(ExtraWindow *ew) {
	GHOST_RectangleHandle bounds= GHOST_GetClientBounds(ew->win);

	GHOST_ActivateWindowDrawingContext(ew->win);

	ew->size[0]= GHOST_GetWidthRectangle(bounds);
	ew->size[1]= GHOST_GetHeightRectangle(bounds);
	
	glViewport(0, 0, ew->size[0], ew->size[1]);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, ew->size[0], 0, ew->size[1], -1, 1);
	glTranslatef(0.375, 0.375, 0.0);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
コード例 #2
0
ファイル: wm_init_exit.c プロジェクト: Ichthyostega/blender
bool WM_init_game(bContext *C)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	wmWindow *win;

	ScrArea *sa;
	ARegion *ar = NULL;

	Scene *scene = CTX_data_scene(C);

	if (!scene) {
		/* XXX, this should not be needed. */
		Main *bmain = CTX_data_main(C);
		scene = bmain->scene.first;
	}

	win = wm->windows.first;

	/* first to get a valid window */
	if (win)
		CTX_wm_window_set(C, win);

	sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
	ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);

	/* if we have a valid 3D view */
	if (sa && ar) {
		ARegion *arhide;

		CTX_wm_area_set(C, sa);
		CTX_wm_region_set(C, ar);

		/* disable quad view */
		if (ar->alignment == RGN_ALIGN_QSPLIT)
			WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);

		/* toolbox, properties panel and header are hidden */
		for (arhide = sa->regionbase.first; arhide; arhide = arhide->next) {
			if (arhide->regiontype != RGN_TYPE_WINDOW) {
				if (!(arhide->flag & RGN_FLAG_HIDDEN)) {
					ED_region_toggle_hidden(C, arhide);
				}
			}
		}

		/* full screen the area */
		if (!sa->full) {
			ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED);
		}

		/* Fullscreen */
		if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
			WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
			wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
			ar->winx = ar->winrct.xmax + 1;
			ar->winy = ar->winrct.ymax + 1;
		}
		else {
			GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin);
			ar->winrct.ymax = GHOST_GetHeightRectangle(rect);
			ar->winrct.xmax = GHOST_GetWidthRectangle(rect);
			ar->winx = ar->winrct.xmax + 1;
			ar->winy = ar->winrct.ymax + 1;
			GHOST_DisposeRectangle(rect);
		}

		WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);

		BKE_sound_exit();

		return true;
	}
	else {
		ReportTimerInfo *rti;

		BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found, game auto start is not possible");

		/* After adding the report to the global list, reset the report timer. */
		WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);

		/* Records time since last report was added */
		wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);

		rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
		wm->reports.reporttimer->customdata = rti;

		return false;
	}
}
コード例 #3
0
/* belongs to below */
static void wm_window_add_ghostwindow(wmWindowManager *wm, const char *title, wmWindow *win)
{
    GHOST_WindowHandle ghostwin;
    GHOST_GLSettings glSettings = {0};
    static int multisamples = -1;
    int scr_w, scr_h, posy;

    /* force setting multisamples only once, it requires restart - and you cannot
     * mix it, either all windows have it, or none (tested in OSX opengl) */
    if (multisamples == -1)
        multisamples = U.ogl_multisamples;

    glSettings.numOfAASamples = multisamples;

    /* a new window is created when pageflip mode is required for a window */
    if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP)
        glSettings.flags |= GHOST_glStereoVisual;

    if (G.debug & G_DEBUG_GPU) {
        glSettings.flags |= GHOST_glDebugContext;
    }

    if (!(U.uiflag2 & USER_OPENGL_NO_WARN_SUPPORT))
        glSettings.flags |= GHOST_glWarnSupport;

    wm_get_screensize(&scr_w, &scr_h);
    posy = (scr_h - win->posy - win->sizey);

    ghostwin = GHOST_CreateWindow(g_system, title,
                                  win->posx, posy, win->sizex, win->sizey,
                                  (GHOST_TWindowState)win->windowstate,
                                  GHOST_kDrawingContextTypeOpenGL,
                                  glSettings);

    if (ghostwin) {
        GHOST_RectangleHandle bounds;

        /* the new window has already been made drawable upon creation */
        wm->windrawable = win;

        /* needed so we can detect the graphics card below */
        GPU_init();

        win->ghostwin = ghostwin;
        GHOST_SetWindowUserData(ghostwin, win); /* pointer back */

        if (win->eventstate == NULL)
            win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");

#ifdef __APPLE__
        /* set the state here, else OSX would not recognize changed screen resolution */
        /* we agreed to not set any fullscreen or iconized state on startup */
        GHOST_SetWindowState(ghostwin, GHOST_kWindowStateNormal);
#endif
        /* store actual window size in blender window */
        bounds = GHOST_GetClientBounds(win->ghostwin);
        win->sizex = GHOST_GetWidthRectangle(bounds);
        win->sizey = GHOST_GetHeightRectangle(bounds);
        GHOST_DisposeRectangle(bounds);

#ifndef __APPLE__
        /* set the state here, so minimized state comes up correct on windows */
        GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
#endif
        /* until screens get drawn, make it nice gray */
        glClearColor(0.55, 0.55, 0.55, 0.0);
        /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
        if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
            glClear(GL_COLOR_BUFFER_BIT);
        }

        /* displays with larger native pixels, like Macbook. Used to scale dpi with */
        /* needed here, because it's used before it reads userdef */
        U.pixelsize = wm_window_pixelsize(win);
        BKE_userdef_state();

        wm_window_swap_buffers(win);

        //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);

        /* standard state vars for window */
        glEnable(GL_SCISSOR_TEST);
        GPU_state_init();
    }
}
コード例 #4
0
/* belongs to below */
static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
{
	GHOST_WindowHandle ghostwin;
	static int multisamples = -1;
	int scr_w, scr_h, posy;
	
	/* force setting multisamples only once, it requires restart - and you cannot 
	 * mix it, either all windows have it, or none (tested in OSX opengl) */
	if (multisamples == -1)
		multisamples = U.ogl_multisamples;
	
	wm_get_screensize(&scr_w, &scr_h);
	posy = (scr_h - win->posy - win->sizey);
	
	ghostwin = GHOST_CreateWindow(g_system, title,
	                              win->posx, posy, win->sizex, win->sizey,
	                              (GHOST_TWindowState)win->windowstate,
	                              GHOST_kDrawingContextTypeOpenGL,
	                              0 /* no stereo */,
	                              multisamples /* AA */);
	
	if (ghostwin) {
		GHOST_RectangleHandle bounds;
		
		/* needed so we can detect the graphics card below */
		GPU_extensions_init();
		
		win->ghostwin = ghostwin;
		GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
		
		if (win->eventstate == NULL)
			win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
		
		/* set the state */
		GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);

		/* until screens get drawn, make it nice gray */
		glClearColor(0.55, 0.55, 0.55, 0.0);
		/* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
		if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
			glClear(GL_COLOR_BUFFER_BIT);
		}
		
		/* displays with larger native pixels, like Macbook. Used to scale dpi with */
		/* needed here, because it's used before it reads userdef */
		U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin);
		BKE_userdef_state();
		
		/* store actual window size in blender window */
		bounds = GHOST_GetClientBounds(win->ghostwin);
		win->sizex = GHOST_GetWidthRectangle(bounds);
		win->sizey = GHOST_GetHeightRectangle(bounds);
		GHOST_DisposeRectangle(bounds);

		
		wm_window_swap_buffers(win);
		
		//GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified);
		
		/* standard state vars for window */
		glEnable(GL_SCISSOR_TEST);
		GPU_state_init();
	}
}