Example #1
0
File: vid.c Project: btb/d2x
void ogl_cmd_texturemode(int argc, char **argv)
{
	if (argc < 2) {
		cmd_insertf("help %s", argv[0]);
		return;
	}

	if (!stricmp(argv[1], "GL_NEAREST")) {
		GL_texminfilt = GL_NEAREST;
		GL_texmagfilt = GL_NEAREST;
	} else if (!stricmp(argv[1], "GL_LINEAR")) {
		GL_texminfilt = GL_LINEAR;
		GL_texmagfilt = GL_LINEAR;
	} else if (!stricmp(argv[1], "GL_NEAREST_MIPMAP_NEAREST")) {
		GL_texminfilt = GL_NEAREST_MIPMAP_NEAREST;
		GL_texmagfilt = GL_NEAREST;
	} else if (!stricmp(argv[1], "GL_LINEAR_MIPMAP_NEAREST")) {
		GL_texminfilt = GL_LINEAR_MIPMAP_NEAREST;
		GL_texmagfilt = GL_LINEAR;
	} else if (!stricmp(argv[1], "GL_NEAREST_MIPMAP_LINEAR")) {
		GL_texminfilt = GL_NEAREST_MIPMAP_LINEAR;
		GL_texmagfilt = GL_NEAREST;
	} else if (!stricmp(argv[1], "GL_LINEAR_MIPMAP_LINEAR")) {
		GL_texminfilt = GL_LINEAR_MIPMAP_LINEAR;
		GL_texmagfilt = GL_LINEAR;
	} else
		return;

	GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt);

	ogl_smash_texture_list_internal();
}
Example #2
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;
}
Example #3
0
File: vid.c Project: 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;
}