Ejemplo n.º 1
0
void VID_Init(unsigned char *palette) {

	vid.colormap = host_colormap;

	Check_Gamma(palette);
	VID_SetPalette(palette);

	VID_RegisterLatchCvars();

	if (!host_initialized) {
		VID_RegisterCvars();
		VID_RegisterCommands();
		VID_ParseCmdLine();
	}

	VID_SDL_Init();

	// print info
	if (!host_initialized || r_verbose.integer) {
		GfxInfo_f();
	}

	VID_UpdateConRes();

	GL_Init(); // Real OpenGL stuff, vid_common_gl.c
}
Ejemplo n.º 2
0
void main(void)
{
    int cdc_in;
    int uart_in;
    volatile UINT8 u8Error;

    hw_init();
    MCU_init();
    GL_Init(
        GL_FD_HORIZONTAL | GL_FD_TOUCH_BEEP_ON,
        GLF_65K_COLORS,
        GLF_16M_COLORS,
        &OnDrawScreenBackground
    );
    win_main_font = (GL_HFONT) & Arial_16px;
    GL_Screen_Activate((GL_HSCREEN) &screen);
    SPI_Init();
    if ((u8Error = SD_Init()) != INIT_FAILS) {
        FAT_Read_Master_Block();
        loadFiles();
        redraw();
        SD_LOADED_BEEP();
    } else {
        NO_SD_BEEP();
    }

    EnableInterrupts;
    while (1) {
        // handle touch (FIXME typo in GL lib (HaDNle))
        GL_TS_HadnleActions();
    }
}
Ejemplo n.º 3
0
qboolean RPI_Init (rendererstate_t *info, unsigned char *palette)
{
	static EGL_DISPMANX_WINDOW_T nativewindow;

	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;
	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
	int rw, rh;

	if (!EGL_LoadLibrary(info->subrenderer))
	{
		Con_Printf("couldn't load EGL library\n");
		return false;
	}
	bcm_host_init();

	graphics_get_display_size(0 /* LCD */, &rw, &rh);
	Con_Printf("Screen size is actually %i*%i\n", rw, rh);

	if (info->width < 64 || info->height < 64)
	{
		info->width = rw;
		info->height = rh;
	}
	dispman_display = vc_dispmanx_display_open(0 /* LCD */);
	dispman_update = vc_dispmanx_update_start(0);


	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width = info->width;
	dst_rect.height = info->height;
	  
	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width = info->width << 16;
	src_rect.height = info->height << 16; 

	vid.pixelwidth = info->width;
	vid.pixelheight = info->height;
	 
	dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
  
	nativewindow.element = dispman_element;
	nativewindow.width = info->width;
	nativewindow.height = info->height;
	vc_dispmanx_update_submit_sync(dispman_update);


	if (!EGL_Init(info, palette, &nativewindow, EGL_DEFAULT_DISPLAY))
	{
		Con_Printf("couldn't initialise EGL context\n");
		return false;
	}
	GL_Init(&EGL_Proc);
	return true;
}
Ejemplo n.º 4
0
bool WindowsHost::InitGraphics(std::string *error_message) {
	switch (g_Config.iGPUBackend) {
	case GPU_BACKEND_OPENGL:
		return GL_Init(displayWindow_, error_message);
	case GPU_BACKEND_DIRECT3D9:
		return D3D9_Init(displayWindow_, true, error_message);
	default:
		return false;
	}
}
Ejemplo n.º 5
0
extern void cyg_start(void)
{
    //CYG_TEST_INIT();
    //CYG_TEST_NA("Kernel C API layer disabled");
    GL_Status_t res;

    diag_printf("GSL test beginning\n");

    GL_Init();

    res = GL_QueueCreate("queue1", 511, 10, 5, &queue_id1);
    CHECK_RES((res == GL_SUCCESS)) res = GL_TaskCreate("Task1", entry1, NULL, 12, 4 * 1024, true, &task1);
    CHECK_RES((res == GL_SUCCESS)) res = GL_TaskCreate("Task2", entry2, NULL, 12, 4 * 1024, true, &task2);
    CHECK_RES((res == GL_SUCCESS)) res = GL_TaskCreate("Task3", entry3, NULL, 12, 4 * 1024, true, &task3);
    CHECK_RES((res == GL_SUCCESS)) cyg_scheduler_start();
}
Ejemplo n.º 6
0
void VID_Init (unsigned char *palette) {

	vid.colormap = host_colormap;

	Check_Gamma(palette);
	VID_SetPalette(palette);

	RE_Init();

#ifdef GLSL
	SHD_Init();
#endif

	VID_zzz();

	GL_Init();
}
Ejemplo n.º 7
0
//initializes an OpenGL rendering context and window
void	GL_SDL_StartGL ()
{
	SDL_GrabMode mode;

	//grab our input here
	mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
	//fixme: re-enable grabbing of input
    //if ( mode != SDL_GRAB_ON ) {
    if ( mode != SDL_GRAB_OFF ) {
	    mode = SDL_WM_GrabInput(SDL_GRAB_OFF);
	}

	SDL_ShowCursor(false);
		
	gl_initialized = true;
	
	GL_Init();
}
Ejemplo n.º 8
0
/*
===================
VID_Init
===================
*/
void	VID_Init (void)
{
	static char vid_center[] = "SDL_VIDEO_CENTERED=center";
	const SDL_VideoInfo *info;
	int		width, height, bpp;
	qboolean	fullscreen;
	const char	*read_vars[] = { "vid_fullscreen",
					 "vid_width",
					 "vid_height",
					 "vid_bpp",
					 "vid_vsync" };
#define num_readvars	( sizeof(read_vars)/sizeof(read_vars[0]) )

	Cvar_RegisterVariable (&vid_fullscreen); //johnfitz
	Cvar_RegisterVariable (&vid_width); //johnfitz
	Cvar_RegisterVariable (&vid_height); //johnfitz
	Cvar_RegisterVariable (&vid_bpp); //johnfitz
	Cvar_RegisterVariable (&vid_vsync); //johnfitz
	Cvar_SetCallback (&vid_fullscreen, VID_Changed_f);
	Cvar_SetCallback (&vid_width, VID_Changed_f);
	Cvar_SetCallback (&vid_height, VID_Changed_f);
	Cvar_SetCallback (&vid_bpp, VID_Changed_f);
	Cvar_SetCallback (&vid_vsync, VID_Changed_f);

	Cmd_AddCommand ("vid_unlock", VID_Unlock); //johnfitz
	Cmd_AddCommand ("vid_restart", VID_Restart); //johnfitz
	Cmd_AddCommand ("vid_test", VID_Test); //johnfitz
	Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);
	Cmd_AddCommand ("vid_describemodes", VID_DescribeModes_f);

	putenv (vid_center);	/* SDL_putenv is problematic in versions <= 1.2.9 */

	if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
		Sys_Error("Could not initialize SDL Video");

	info = SDL_GetVideoInfo();
	Cvar_SetValueQuick (&vid_bpp, (float)info->vfmt->BitsPerPixel);

	if (CFG_OpenConfig("config.cfg") == 0)
	{
		CFG_ReadCvars(read_vars, num_readvars);
		CFG_CloseConfig();
	}
	CFG_ReadCvarOverrides(read_vars, num_readvars);

	VID_InitModelist();

	width = (int)vid_width.value;
	height = (int)vid_height.value;
	bpp = (int)vid_bpp.value;
	fullscreen = (int)vid_fullscreen.value;

	if (COM_CheckParm("-current"))
	{
		width = info->current_w;
		height = info->current_h;
		bpp = info->vfmt->BitsPerPixel;
		fullscreen = true;
	}
	else
	{
		int p;

		p = COM_CheckParm("-width");
		if (p && p < com_argc-1)
		{
			width = Q_atoi(com_argv[p+1]);

			if(!COM_CheckParm("-height"))
				height = width * 3 / 4;
		}

		p = COM_CheckParm("-height");
		if (p && p < com_argc-1)
		{
			height = Q_atoi(com_argv[p+1]);

			if(!COM_CheckParm("-width"))
				width = height * 4 / 3;
		}

		p = COM_CheckParm("-bpp");
		if (p && p < com_argc-1)
			bpp = Q_atoi(com_argv[p+1]);

		if (COM_CheckParm("-window") || COM_CheckParm("-w"))
			fullscreen = false;
		else if (COM_CheckParm("-fullscreen") || COM_CheckParm("-f"))
			fullscreen = true;
	}

	if (!VID_ValidMode(width, height, bpp, fullscreen))
	{
		width = (int)vid_width.value;
		height = (int)vid_height.value;
		bpp = (int)vid_bpp.value;
		fullscreen = (int)vid_fullscreen.value;
	}

	if (!VID_ValidMode(width, height, bpp, fullscreen))
	{
		width = 640;
		height = 480;
		bpp = info->vfmt->BitsPerPixel;
		fullscreen = false;
	}

	vid_initialized = true;

	vid.maxwarpwidth = WARP_WIDTH;
	vid.maxwarpheight = WARP_HEIGHT;
	vid.colormap = host_colormap;
	vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));

	// set window icon
	PL_SetWindowIcon();

	VID_SetMode (width, height, bpp, fullscreen);

	GL_Init ();
	GL_SetupState ();
	Cmd_AddCommand ("gl_info", GL_Info_f); //johnfitz

	//johnfitz -- removed code creating "glquake" subdirectory

	vid_menucmdfn = VID_Menu_f; //johnfitz
	vid_menudrawfn = VID_MenuDraw;
	vid_menukeyfn = VID_MenuKey;

	VID_Gamma_Init(); //johnfitz
	VID_Menu_Init(); //johnfitz

	//QuakeSpasm: current vid settings should override config file settings.
	//so we have to lock the vid mode from now until after all config files are read.
	vid_locked = true;
}
Ejemplo n.º 9
0
/*
===================
VID_Restart -- johnfitz -- change video modes on the fly
===================
*/
static void VID_Restart (void)
{
	int width, height, bpp;
	qboolean fullscreen;

	if (vid_locked || !vid_changed)
		return;

	if (r_oculusrift.value) { // phoboslab
		R_ReleaseHMDRenderer();
	}

	width = (int)vid_width.value;
	height = (int)vid_height.value;
	bpp = (int)vid_bpp.value;
	fullscreen = vid_fullscreen.value ? true : false;

//
// validate new mode
//
	if (!VID_ValidMode (width, height, bpp, fullscreen))
	{
		Con_Printf ("%dx%dx%d %s is not a valid mode\n",
				width, height, bpp, fullscreen? "fullscreen" : "windowed");
		return;
	}

//
// set new mode
//
	VID_SetMode (width, height, bpp, fullscreen);

	GL_Init ();
	TexMgr_ReloadImages ();
	GL_SetupState ();

	//warpimages needs to be recalculated
	TexMgr_RecalcWarpImageSize ();

	//conwidth and conheight need to be recalculated
	vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width;
	vid.conwidth = CLAMP (320, vid.conwidth, vid.width);
	vid.conwidth &= 0xFFFFFFF8;
	vid.conheight = vid.conwidth * vid.height / vid.width;
//
// keep cvars in line with actual mode
//
	VID_SyncCvars();
//
// update mouse grab
//
	if (key_dest == key_console || key_dest == key_menu)
	{
		if (modestate == MS_WINDOWED)
			IN_Deactivate(true);
		else if (modestate == MS_FULLSCREEN)
			IN_Activate();
	}

	if (r_oculusrift.value) { // phoboslab
		R_InitHMDRenderer();
	}
}
Ejemplo n.º 10
0
bool WindowsHost::InitGL(std::string *error_message)
{
	return GL_Init(displayWindow_, error_message);
}
Ejemplo n.º 11
0
void WindowsHost::InitGL()
{
	GL_Init(MainWindow::GetDisplayHWND());
}
Ejemplo n.º 12
0
qboolean VID_InitMode(viddef_mode_t *mode)
{
	const EventTypeSpec winEvents[] =
	{
		{ kEventClassWindow, kEventWindowClosed },
		{ kEventClassWindow, kEventWindowCollapsing },
		{ kEventClassWindow, kEventWindowExpanded },
	};
	OSStatus carbonError;
	Rect windowBounds;
	CFStringRef windowTitle;
	AGLPixelFormat pixelFormat;
	GLint attributes [32];
	GLenum error;

	if (!GL_OpenLibrary())
	{
		Con_Printf("Unable to load GL driver\n");
		return false;
	}

	if ((qaglChoosePixelFormat = (AGLPixelFormat (*) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList))GL_GetProcAddress("aglChoosePixelFormat")) == NULL
	 || (qaglCreateContext = (AGLContext (*) (AGLPixelFormat pix, AGLContext share))GL_GetProcAddress("aglCreateContext")) == NULL
	 || (qaglDestroyContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglDestroyContext")) == NULL
	 || (qaglDestroyPixelFormat = (void (*) (AGLPixelFormat pix))GL_GetProcAddress("aglDestroyPixelFormat")) == NULL
	 || (qaglErrorString = (const GLubyte* (*) (GLenum code))GL_GetProcAddress("aglErrorString")) == NULL
	 || (qaglGetError = (GLenum (*) (void))GL_GetProcAddress("aglGetError")) == NULL
	 || (qaglSetCurrentContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglSetCurrentContext")) == NULL
	 || (qaglSetDrawable = (GLboolean (*) (AGLContext ctx, AGLDrawable draw))GL_GetProcAddress("aglSetDrawable")) == NULL
	 || (qaglSetFullScreen = (GLboolean (*) (AGLContext ctx, GLsizei width, GLsizei height, GLsizei freq, GLint device))GL_GetProcAddress("aglSetFullScreen")) == NULL
	 || (qaglSetInteger = (GLboolean (*) (AGLContext ctx, GLenum pname, const GLint *params))GL_GetProcAddress("aglSetInteger")) == NULL
	 || (qaglSwapBuffers = (void (*) (AGLContext ctx))GL_GetProcAddress("aglSwapBuffers")) == NULL
	)
	{
		Con_Printf("AGL functions not found\n");
		ReleaseWindow(window);
		return false;
	}

	qCGLEnable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLEnable");
	qCGLDisable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLDisable");
	qCGLGetCurrentContext = (CGLContextObj (*) (void)) CGL_GetProcAddress("CGLGetCurrentContext");
	if(!qCGLEnable || !qCGLDisable || !qCGLGetCurrentContext)
		Con_Printf("CGL functions not found; disabling multithreaded OpenGL\n");

	// Ignore the events from the previous window
	AsyncEvent_Quitting = false;
	AsyncEvent_Collapsed = false;

	// Create the window, a bit towards the center of the screen
	windowBounds.left = 100;
	windowBounds.top = 100;
	windowBounds.right = mode->width + 100;
	windowBounds.bottom = mode->height + 100;
	carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
	if (carbonError != noErr || window == NULL)
	{
		Con_Printf("Unable to create window (error %u)\n", (unsigned)carbonError);
		return false;
	}

	// Set the window title
	windowTitle = CFSTR("DarkPlaces AGL");
	SetWindowTitleWithCFString(window, windowTitle);

	// Install the callback function for the window events we can't get
	// through ReceiveNextEvent (i.e. close, collapse, and expand)
	InstallWindowEventHandler (window, NewEventHandlerUPP (MainWindowEventHandler),
							   GetEventTypeCount(winEvents), winEvents, window, NULL);

	// Create the desired attribute list
	VID_BuildAGLAttrib(attributes, mode->bitsperpixel == 32, mode->fullscreen, mode->stereobuffer, mode->samples);

	if (!mode->fullscreen)
	{
		// Output to Window
		pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
		error = qaglGetError();
		if (error != AGL_NO_ERROR)
		{
			Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
					(char *)qaglErrorString(error));
			ReleaseWindow(window);
			return false;
		}
	}
	else  // Output is fullScreen
	{
		CGDirectDisplayID mainDisplay;
		CFDictionaryRef refDisplayMode;
		GDHandle gdhDisplay;

		// Get the mainDisplay and set resolution to current
		mainDisplay = CGMainDisplayID();
		CGDisplayCapture(mainDisplay);

		// TOCHECK: not sure whether or not it's necessary to change the resolution
		// "by hand", or if aglSetFullscreen does the job anyway
		refDisplayMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(mainDisplay, mode->bitsperpixel, mode->width, mode->height, mode->refreshrate, kCGDisplayModeIsSafeForHardware, NULL);
		CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
		DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);

		// Set pixel format with built attribs
		// Note: specifying a device is *required* for AGL_FullScreen
		pixelFormat = qaglChoosePixelFormat(&gdhDisplay, 1, attributes);
		error = qaglGetError();
		if (error != AGL_NO_ERROR)
		{
			Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
						(char *)qaglErrorString(error));
			ReleaseWindow(window);
			return false;
		}
	}

	// Create a context using the pform
	context = qaglCreateContext(pixelFormat, NULL);
	error = qaglGetError();
	if (error != AGL_NO_ERROR)
	{
		Con_Printf("qaglCreateContext FAILED: %s\n",
					(char *)qaglErrorString(error));
	}

	// Make the context the current one ('enable' it)
	qaglSetCurrentContext(context);
	error = qaglGetError();
	if (error != AGL_NO_ERROR)
	{
		Con_Printf("qaglSetCurrentContext FAILED: %s\n",
					(char *)qaglErrorString(error));
		ReleaseWindow(window);
		return false;
	}

	// Discard pform
	qaglDestroyPixelFormat(pixelFormat);

	// Attempt fullscreen if requested
	if (mode->fullscreen)
	{
		qaglSetFullScreen (context, mode->width, mode->height, mode->refreshrate, 0);
		error = qaglGetError();
		if (error != AGL_NO_ERROR)
		{
			Con_Printf("qaglSetFullScreen FAILED: %s\n",
						(char *)qaglErrorString(error));
			return false;
		}
	}
	else
	{
		// Set Window as Drawable
		qaglSetDrawable(context, GetWindowPort(window));
		error = qaglGetError();
		if (error != AGL_NO_ERROR)
		{
			Con_Printf("qaglSetDrawable FAILED: %s\n",
						(char *)qaglErrorString(error));
			ReleaseWindow(window);
			return false;
		}
	}

	if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
		Sys_Error("glGetString not found in %s", gl_driver);

	gl_platformextensions = "";
	gl_platform = "AGL";

	multithreadedgl = false;
	vid_isfullscreen = mode->fullscreen;
	vid_usingmouse = false;
	vid_usinghidecursor = false;
	vid_hidden = false;
	vid_activewindow = true;
	sound_active = true;
	GL_Init();

	SelectWindow(window);
	ShowWindow(window);

	return true;
}
Ejemplo n.º 13
0
void VID_Init(unsigned char *palette)
{
    int i;
    int attrib[] = {
                       GLX_RGBA,
                       GLX_RED_SIZE, 1,
                       GLX_GREEN_SIZE, 1,
                       GLX_BLUE_SIZE, 1,
                       GLX_DOUBLEBUFFER,
                       GLX_DEPTH_SIZE, 1,
                       None
                   };
    int width = 640, height = 480;
    XSetWindowAttributes attr;
    unsigned long mask;
    Window root;
    XVisualInfo *visinfo;

#ifdef USE_VMODE
    qbool fullscreen = true;
    int MajorVersion, MinorVersion;
    int actualWidth, actualHeight;
#endif

    Cvar_Register (&vid_ref);
    Cvar_Register (&vid_mode);
    Cvar_Register (&vid_hwgammacontrol);
    Cvar_Register (&_windowed_mouse);
    Cvar_Register (&m_filter);

    vid.colormap = host_colormap;

    // interpret command-line params
    // fullscreen cmdline check
#ifdef USE_VMODE
    if (COM_CheckParm("-window"))
        fullscreen = false;
#endif
    // set vid parameters
    if ((i = COM_CheckParm("-width")) != 0)
        width = atoi(com_argv[i+1]);
    if ((i = COM_CheckParm("-height")) != 0)
        height = atoi(com_argv[i+1]);
    if ((i = COM_CheckParm("-conwidth")) != 0)
        vid.width = Q_atoi(com_argv[i+1]);
    else
        vid.width = 640;

    vid.width &= 0xfff8; // make it a multiple of eight

    if (vid.width < 320)
        vid.width = 320;

    // pick a conheight that matches with correct aspect
    vid.height = vid.width*3 / 4;

    if ((i = COM_CheckParm("-conheight")) != 0)
        vid.height = Q_atoi(com_argv[i+1]);
    if (vid.height < 200)
        vid.height = 200;

    if (!(x_disp = XOpenDisplay(NULL)))
    {
        fprintf(stderr, "Error couldn't open the X display\n");
        exit(1);
    }

    scrnum = DefaultScreen(x_disp);
    root = RootWindow(x_disp, scrnum);

#ifdef USE_VMODE
    // check vmode extensions supported
    // Get video mode list
    MajorVersion = MinorVersion = 0;
    if (!XF86VidModeQueryVersion(x_disp, &MajorVersion, &MinorVersion))
    {
        vidmode_ext = false;
    }
    else
    {
        Com_Printf("Using XFree86-VidModeExtension Version %d.%d\n", MajorVersion, MinorVersion);
        vidmode_ext = true;
    }
#endif

    visinfo = glXChooseVisual(x_disp, scrnum, attrib);
    if (!visinfo)
    {
        fprintf(stderr, "qkHack: Error couldn't get an RGB, Double-buffered, Depth visual\n");
        exit(1);
    }

    // setup fullscreen size to fit display -->
#ifdef USE_VMODE
    if (vidmode_ext)
    {
        int best_fit, best_dist, dist, x, y;

        XF86VidModeGetAllModeLines(x_disp, scrnum, &num_vidmodes, &vidmodes);

        // Are we going fullscreen?  If so, let's change video mode
        if (fullscreen)
        {
            best_dist = 9999999;
            best_fit = -1;

            for (i = 0; i < num_vidmodes; i++)
            {
                if (width > vidmodes[i]->hdisplay || height > vidmodes[i]->vdisplay)
                    continue;

                x = width - vidmodes[i]->hdisplay;
                y = height - vidmodes[i]->vdisplay;
                dist = x * x + y * y;
                if (dist < best_dist)
                {
                    best_dist = dist;
                    best_fit = i;
                }
            }

            if (best_fit != -1)
            {
                actualWidth = vidmodes[best_fit]->hdisplay;
                actualHeight = vidmodes[best_fit]->vdisplay;
                // change to the mode
                XF86VidModeSwitchToMode(x_disp, scrnum, vidmodes[best_fit]);
                vidmode_active = true;
                // Move the viewport to top left
                XF86VidModeSetViewPort(x_disp, scrnum, 0, 0);
            }
            else
            {
                fullscreen = 0;
            }
        }
    }
#endif
    /* window attributes */
    attr.background_pixel = 0;
    attr.border_pixel = 0;
    attr.colormap = XCreateColormap(x_disp, root, visinfo->visual, AllocNone);
    attr.event_mask = X_MASK;
    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

    // if fullscreen disable window manager decoration
#ifdef USE_VMODE
    if (vidmode_active)
    {
        mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
               CWEventMask | CWOverrideRedirect;
        attr.override_redirect = True;
        attr.backing_store = NotUseful;
        attr.save_under = False;
    }
#endif
    x_win = XCreateWindow(x_disp, root, 0, 0, width, height,
                        0, visinfo->depth, InputOutput,
                        visinfo->visual, mask, &attr);
    XStoreName(x_disp, x_win, PROGRAM);
    XMapWindow(x_disp, x_win);

#ifdef USE_VMODE
    if (vidmode_active)
    {
        XRaiseWindow(x_disp, x_win);
        XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0, 0, 0);
        XFlush(x_disp);
        // Move the viewport to top left
        XF86VidModeSetViewPort(x_disp, scrnum, 0, 0);
    }
#endif
    XFlush(x_disp);

    ctx = glXCreateContext(x_disp, visinfo, NULL, True);

    glXMakeCurrent(x_disp, x_win, ctx);

    vid.realwidth = width;
    vid.realheight = height;

    if (vid.height > height)
        vid.height = height;
    if (vid.width > width)
        vid.width = width;

    vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
    vid.numpages = 2;

    InitSig(); // trap evil signals

    GL_Init();

    Check_Gamma(palette);

    VID_SetPalette(palette);

    InitHWGamma();

    Com_Printf ("Video mode %dx%d initialized.\n", width, height);

	SCR_InvalidateScreen ();
}
Ejemplo n.º 14
0
int main(int argc, char ** argv) {
	// Initialise SDL
	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) 
		DIE("SDL_Init: %s", SDL_GetError());

  GL_Init();

  //Init SDL_TTF to print text to the screen...
  if ( TTF_Init() )
  {
    fprintf( stderr, "Error initializing SDL_ttf!\n" );
    exit ( 1 );
  }

	S9xInitDisplay(argc, argv);

	// Configure snes9x
#if CONF_GUI
	OssoInit();						// Hildon-games-wrapper initialization.
#endif
	S9xLoadConfig(argc, argv);		// Load config files and parse cmd line.
  readOptions();
#if CONF_GUI
	OssoConfig();					// Apply specific hildon-games config.
#endif

  // S9x initialization
  S9xInitDisplay(argc, argv);
  S9xInitAudioOutput();
  S9xInitInputDevices();

  while(1)
  {
    S9xInit();
    S9xReset();

    char * rom = romSelector();
    S9xSetRomFile(rom);
    free(rom);

    // Load rom and related files: state, unfreeze if needed
    loadRom();
    resumeGame();

    // Late initialization
    sprintf(String, "DrNokSnes - %s", Memory.ROMName);
    S9xSetTitle(String);
    S9xHacksLoadFile(Config.hacksFile);
    if (!S9xGraphicsInit())
      DIE("S9xGraphicsInit failed");
    S9xAudioOutputEnable(true);
    SDL_PauseAudio(0);
    S9xVideoReset();

    Config.running = true;
    do {
      frameSync();			// May block, or set frameskip to true.
      S9xMainLoop();			// Does CPU things, renders if needed.
      pollEvents();
      //Ouch that this is going here...
      updateBindingMessage();
    } while (Config.running);

    S9xVideoReset();
    S9xGraphicsDeinit();

    // Save state
    Memory.SaveSRAM(S9xGetFilename(FILE_SRAM));
    pauseGame();
    Memory.Deinit();
    S9xDeinitAPU();
  }

  // Deinitialization
  S9xAudioOutputEnable(false);
  S9xDeinitInputDevices();
  S9xDeinitAudioOutput();
  S9xDeinitDisplay();

	// Late deinitialization
	S9xUnloadConfig();
#if CONF_GUI
	OssoDeinit();
#endif

	SDL_Quit();

	return 0;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
    GL_MEMPOOL_t pfixpool = NULL;
    GL_UINT8 *memfixpool = NULL;
    GL_UINT32 totalsize, blocksize, i;
    GL_UINT32 *buf[TEST_FIXMEM_BLOCKNUM+1];
    int ret = 0;

    GL_TraceInfo("========================== test  begin ==========================\r\n");

	GL_Init();

    blocksize = TEST_FIXMEM_BLOCKSIZE;
    totalsize = TEST_FIXMEM_BLOCKSIZE*TEST_FIXMEM_BLOCKNUM;

    memfixpool = (GL_UINT8*)malloc(totalsize );
    if(NULL == memfixpool) {
        ret = 1;
        goto __EXIT;
    }

    if(GL_SUCCESS != GL_MempoolFixCreate("fixmempool", memfixpool+1, totalsize, blocksize, &pfixpool)){
        GL_TraceError("%s GL_MempoolFixCreate fail!\r\n", argv[0]);
        ret = 1;
        goto __EXIT;
    }
    GL_TraceInfo(">>>>test malloc until no space \r\n");
    for(i = 0; i<TEST_FIXMEM_BLOCKNUM+1; i++){
        buf[i] = (GL_UINT32*)GL_MempoolFixAlloc(pfixpool, GL_NO_WAIT);
        if(buf[i]){
            GL_TraceError("%s GL_MempoolFixAlloc buf[%d] success! addr=0x%x\r\n", argv[0], i, (unsigned int)buf[i]);
            memset(buf[i], i, TEST_FIXMEM_BLOCKSIZE);
            GL_MempoolFixInfo(pfixpool);
        }else{
            GL_TraceError("%s GL_MempoolFixAlloc buf[%d] fail!\r\n", argv[0], i);
            //ret = 1;
            //goto __EXIT;
        }
    }

#if 1
    GL_TraceInfo(">>>>test the write and read\r\n");
    for(i = 0; i<totalsize; i++){
        if(0 == (i%16)){
            GL_TraceInfo("\r\n");
        }
        GL_TraceInfo("%x ", memfixpool[i]);
    }
    GL_TraceInfo("\r\n");
#endif

    GL_TraceInfo(">>>>test free normal\r\n");
    for(i = 0; i<TEST_FIXMEM_BLOCKNUM; i++){
        GL_MempoolFixFree(pfixpool, buf[i]);
        GL_MempoolFixInfo(pfixpool);
    }

    GL_TraceInfo(">>>>test free NULL\r\n");
    GL_MempoolFixFree(pfixpool, buf[i]);
    GL_MempoolFixInfo(pfixpool);

    GL_TraceInfo(">>>>test free twice\r\n");
    GL_MempoolFixFree(pfixpool, buf[0]);
    GL_MempoolFixInfo(pfixpool);


__EXIT:

    if(pfixpool){
        GL_MempoolFixDestroy(pfixpool);
    }
    if(memfixpool) {
        free(memfixpool);
    }

    if(ret){
        GL_TraceError("%s test fail!\r\n", argv[0]);
    }else{
        GL_TraceError("%s test pass!\r\n", argv[0]);
    }

    GL_TraceInfo("========================== test  exit ==========================\r\n");
	GL_Uninit();

    return ret;

}
Ejemplo n.º 16
0
bool WindowsHost::InitGL(std::string *error_message)
{
	return GL_Init(MainWindow::GetHWND(), error_message);
}
Ejemplo n.º 17
0
/**
  * @brief  Background task
  * @param  pvParameters not used
  * @retval None
  */
static void Background_Task(void * pvParameters)
{
  static uint32_t ticks = 0;

  /* Init Modules manager */
  MOD_PreInit();

  /*Add modules here */
  MOD_AddModule(&mod_system, UTILITIES_GROUP);
  MOD_AddModule(&mod_audio, MULTIMEDIA_GROUP);
  MOD_AddModule(&mod_image, MULTIMEDIA_GROUP);
  MOD_AddModule(&mod_ethernet, CONNECTIVITY_GROUP);
  MOD_AddModule(&mod_camera, MULTIMEDIA_GROUP);
  MOD_AddModule(&mod_usbd, CONNECTIVITY_GROUP);
  MOD_AddModule(&mod_recorder, MULTIMEDIA_GROUP);
  MOD_AddModule(&mod_serial, CONNECTIVITY_GROUP);
  MOD_AddModule(&mod_calendar, UTILITIES_GROUP);
  MOD_AddModule(&mod_filemgr, UTILITIES_GROUP);
  MOD_AddModule(&mod_console, UTILITIES_GROUP);
  MOD_AddModule(&mod_credits, UTILITIES_GROUP);  

  CONSOLE_LOG((uint8_t *)"[SYSTEM] System modules added.");

  /* Show startup Page */
  GL_Startup();

  /* Init Libraries and stack here */
  MOD_LibInit();

  /* Show the main menu and start*/
  GL_Init();

  while (1)
  {
    if ( ticks++ > 10 )
    {
      ticks = 0;

      /* toggle LED1..4 each 100ms */
      STM_EVAL_LEDToggle(LED1);
      STM_EVAL_LEDToggle(LED2);
      STM_EVAL_LEDToggle(LED3);
      STM_EVAL_LEDToggle(LED4);

      /* Wait for HMI events */
      GL_Handle_Inputs();

      /*Update GUI processes */
      GL_Background_Handler();

      /* power saving mode */
      GL_LowPower();

      /* Apply new settings if they were changed */
      GL_HandleSystemSettingsChange();

      /* Display processes running in background */
      GL_UpdateBackgroundProcessStatus();
    }

    /* Handle modules background tasks */
    MOD_HandleModulesBackground();

    /* This task is handled periodically, each 10 mS */
    vTaskDelay(10);
  }
}