Esempio n. 1
0
int gr_init(int mode)
{
    int retcode,t,glt=0;
    // Only do this function once!
    if (gr_installed==1)
        return -1;


#ifdef OGL_RUNTIME_LOAD
    ogl_init_load_library();
#endif

#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
    if (FindArg("-gl_voodoo")) {
        ogl_voodoohack=1;
        gr_toggle_fullscreen();
    }
    if (FindArg("-fullscreen"))
        gr_toggle_fullscreen();
#endif
    if ((glt=FindArg("-gl_alttexmerge")))
        ogl_alttexmerge=1;
    if ((t=FindArg("-gl_stdtexmerge")))
        if (t>=glt)//allow overriding of earlier args
            ogl_alttexmerge=0;

    if ((glt=FindArg("-gl_16bittextures")))
        ogl_rgba_format=GL_RGB5_A1;

    if ((glt=FindArg("-gl_mipmap"))) {
        GL_texmagfilt=GL_LINEAR;
        GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
    }
    if ((glt=FindArg("-gl_trilinear"))) {
        GL_texmagfilt=GL_LINEAR;
        GL_texminfilt=GL_LINEAR_MIPMAP_LINEAR;
    }
    if ((t=FindArg("-gl_simple"))) {
        if (t>=glt) { //allow overriding of earlier args
            glt=t;
            GL_texmagfilt=GL_NEAREST;
            GL_texminfilt=GL_NEAREST;
        }
    }
    if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))) {
        if (t>=glt)//allow overriding of earlier args
            GL_texmagfilt=ogl_atotexfilti(Args[t+1],0);
    }
    if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))) {
        if (t>=glt)//allow overriding of earlier args
            GL_texminfilt=ogl_atotexfilti(Args[t+1],1);
    }
    GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt);

    if ((t=FindArg("-gl_anisotropy")) || (t=FindArg("-gl_anisotropic"))) {
        GL_texanisofilt=atof(Args[t+1]);
    }

    mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps,GL_texanisofilt));


    if ((t=FindArg("-gl_vidmem"))) {
        ogl_mem_target=atoi(Args[t+1])*1024*1024;
    }
    if ((t=FindArg("-gl_reticle"))) {
        gl_reticle=atoi(Args[t+1]);
    }
    //printf("ogl_mem_target=%i\n",ogl_mem_target);

    ogl_init();//platform specific initialization

    ogl_init_texture_list_internal();

    MALLOC( grd_curscreen,grs_screen,1 );
    memset( grd_curscreen, 0, sizeof(grs_screen));
    grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;

    // Set the mode.
    if ((retcode=gr_set_mode(mode)))
    {
        return retcode;
    }
    grd_curscreen->sc_canvas.cv_color = 0;
    grd_curscreen->sc_canvas.cv_drawmode = 0;
    grd_curscreen->sc_canvas.cv_font = NULL;
    grd_curscreen->sc_canvas.cv_font_fg_color = 0;
    grd_curscreen->sc_canvas.cv_font_bg_color = 0;
    gr_set_current_canvas( &grd_curscreen->sc_canvas );

    gr_installed = 1;

    atexit(gr_close);

    return 0;
}
Esempio n. 2
0
int gr_init(int mode)
{
#ifdef RPI
	char sdl_driver[32];
	char *sdl_driver_ret;
#endif

	int retcode;

	// Only do this function once!
	if (gr_installed==1)
		return -1;

#ifdef RPI
	// Initialize the broadcom host library
	// we have to call this before we can create an OpenGL ES context
	bcm_host_init();

	// Check if we are running with SDL directfb driver ...
	sdl_driver_ret=SDL_VideoDriverName(sdl_driver,32);
	if (sdl_driver_ret) {
		if (strcmp(sdl_driver_ret,"x11")) {
			con_printf(CON_URGENT,"RPi: activating hack for console driver\n");
			sdl_no_modeswitch=1;
		}
	}
#endif

#ifdef _WIN32
	ogl_init_load_library();
#endif

	if (!GameCfg.WindowMode && !GameArg.SysWindow)
		sdl_video_flags|=SDL_FULLSCREEN;

	if (GameArg.SysNoBorders)
		sdl_video_flags|=SDL_NOFRAME;

	gr_set_attributes();

	ogl_init_texture_list_internal();

	CALLOC( grd_curscreen,grs_screen,1 );
	grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;

	// Set the mode.
	if ((retcode=gr_set_mode(mode)))
		return retcode;

	grd_curscreen->sc_canvas.cv_color = 0;
	grd_curscreen->sc_canvas.cv_fade_level = GR_FADE_OFF;
	grd_curscreen->sc_canvas.cv_blend_func = GR_BLEND_NORMAL;
	grd_curscreen->sc_canvas.cv_drawmode = 0;
	grd_curscreen->sc_canvas.cv_font = NULL;
	grd_curscreen->sc_canvas.cv_font_fg_color = 0;
	grd_curscreen->sc_canvas.cv_font_bg_color = 0;
	gr_set_current_canvas( &grd_curscreen->sc_canvas );

	ogl_init_pixel_buffers(256, 128);       // for gamefont_init

	gr_installed = 1;

	return 0;
}
Esempio n. 3
0
File: vid.c Progetto: btb/d2x
int vid_init(void)
{
	int t, glt = 0;

 	// Only do this function once!
	if (vid_installed == 1)
		return -1;

#ifdef _WIN32
	ogl_init_load_library();
#endif

#ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE
	if (FindArg("-gl_voodoo")){
		ogl_voodoohack=1;
		vid_toggle_fullscreen();
	}
	if (FindArg("-fullscreen"))
		vid_toggle_fullscreen();
#endif
	if ((glt=FindArg("-gl_alttexmerge")))
		ogl_alttexmerge=1;
	if ((t=FindArg("-gl_stdtexmerge")))
		if (t>=glt)//allow overriding of earlier args
			ogl_alttexmerge=0;

	if ((glt = FindArg("-gl_16bittextures")))
	{
		ogl_rgba_internalformat = GL_RGB5_A1;
		ogl_rgb_internalformat = GL_RGB5;
	}

	if ((glt=FindArg("-gl_mipmap"))){
		GL_texmagfilt=GL_LINEAR;
		GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
	}
	if ((glt=FindArg("-gl_trilinear")))
	{
		GL_texmagfilt = GL_LINEAR;
		GL_texminfilt = GL_LINEAR_MIPMAP_LINEAR;
	}
	if ((t=FindArg("-gl_simple"))){
		if (t>=glt){//allow overriding of earlier args
			glt=t;
			GL_texmagfilt=GL_NEAREST;
			GL_texminfilt=GL_NEAREST;
		}
	}
	if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))){
		if (t>=glt)//allow overriding of earlier args
			GL_texmagfilt=ogl_atotexfilti(Args[t+1],0);
	}
	if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))){
		if (t>=glt)//allow overriding of earlier args
			GL_texminfilt=ogl_atotexfilti(Args[t+1],1);
	}
	GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt);

	if ((t = FindArg("-gl_anisotropy")) || (t = FindArg("-gl_anisotropic")))
	{
		GL_texanisofilt=atof(Args[t + 1]);
	}

	mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps,GL_texanisofilt));

	
	if ((t=FindArg("-gl_vidmem"))){
		ogl_mem_target=atoi(Args[t+1])*1024*1024;
	}
	if ((t=FindArg("-gl_reticle"))){
		gl_reticle=atoi(Args[t+1]);
	}
	//printf("ogl_mem_target=%i\n",ogl_mem_target);
	
	ogl_init();//platform specific initialization

	ogl_init_texture_list_internal();
		
	cmd_addcommand("gl_texturemode", ogl_cmd_texturemode, "gl_texturemode <x>\n" "    use OpenGL texture mode <x>. Available mode are\n"
	                                                                             "        GL_NEAREST\n"
	                                                                             "        GL_LINEAR\n"
	                                                                             "        GL_NEAREST_MIPMAP_NEAREST\n"
	                                                                             "        GL_LINEAR_MIPMAP_NEAREST\n"
	                                                                             "        GL_NEAREST_MIPMAP_LINEAR\n"
	                                                                             "        GL_LINEAR_MIPMAP_LINEAR");

	vid_installed = 1;
	
	atexit(vid_close);

	return 0;
}