Example #1
0
        public override System.Boolean R_Init2( )
        {
            VID.MenuInit();
            gl_config.vendor_string = GL.GetString(StringName.Vendor);
            VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\\');
            gl_config.renderer_string = GL.GetString(StringName.Renderer);
            VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\\');
            gl_config.version_string = GL.GetString(StringName.Version);
            VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\\');
            gl_config.extensions_string = GL.GetString(StringName.Extensions);
            VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\\');
            gl_config.ParseOpenGLVersion();
            var renderer_buffer = gl_config.renderer_string.ToLower();
            var vendor_buffer   = gl_config.vendor_string.ToLower();

            if (renderer_buffer.IndexOf("voodoo") >= 0)
            {
                if (renderer_buffer.IndexOf("rush") < 0)
                {
                    gl_config.renderer = GL_RENDERER_VOODOO;
                }
                else
                {
                    gl_config.renderer = GL_RENDERER_VOODOO_RUSH;
                }
            }
            else if (vendor_buffer.IndexOf("sgi") >= 0)
            {
                gl_config.renderer = GL_RENDERER_SGI;
            }
            else if (renderer_buffer.IndexOf("permedia") >= 0)
            {
                gl_config.renderer = GL_RENDERER_PERMEDIA2;
            }
            else if (renderer_buffer.IndexOf("glint") >= 0)
            {
                gl_config.renderer = GL_RENDERER_GLINT_MX;
            }
            else if (renderer_buffer.IndexOf("glzicd") >= 0)
            {
                gl_config.renderer = GL_RENDERER_REALIZM;
            }
            else if (renderer_buffer.IndexOf("gdi") >= 0)
            {
                gl_config.renderer = GL_RENDERER_MCD;
            }
            else if (renderer_buffer.IndexOf("pcx2") >= 0)
            {
                gl_config.renderer = GL_RENDERER_PCX2;
            }
            else if (renderer_buffer.IndexOf("verite") >= 0)
            {
                gl_config.renderer = GL_RENDERER_RENDITION;
            }
            else
            {
                gl_config.renderer = unchecked (( Int32 )GL_RENDERER_OTHER);
            }
            var monolightmap = gl_monolightmap.string_renamed.ToUpper();

            if (monolightmap.Length < 2 || monolightmap[1] != 'F')
            {
                if (gl_config.renderer == GL_RENDERER_PERMEDIA2)
                {
                    Cvar.Set("gl_monolightmap", "A");
                    VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\\n");
                }
                else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0)
                {
                    Cvar.Set("gl_monolightmap", "0");
                }
                else
                {
                    Cvar.Set("gl_monolightmap", "0");
                }
            }

            if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0)
            {
                Cvar.Set("scr_drawall", "1");
            }
            else
            {
                Cvar.Set("scr_drawall", "0");
            }

            if (gl_config.renderer == GL_RENDERER_MCD)
            {
                Cvar.SetValue("gl_finish", 1);
            }

            if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0)
            {
                if (gl_3dlabs_broken.value != 0F)
                {
                    gl_config.allow_cds = false;
                }
                else
                {
                    gl_config.allow_cds = true;
                }
            }
            else
            {
                gl_config.allow_cds = true;
            }

            if (gl_config.allow_cds)
            {
                VID.Printf(Defines.PRINT_ALL, "...allowing CDS\\n");
            }
            else
            {
                VID.Printf(Defines.PRINT_ALL, "...disabling CDS\\n");
            }
            if (gl_config.extensions_string.IndexOf("GL_EXT_compiled_vertex_array") >= 0 || gl_config.extensions_string.IndexOf("GL_SGI_compiled_vertex_array") >= 0)
            {
                VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\\n");
                if (gl_ext_compiled_vertex_array.value != 0F)
                {
                    qglLockArraysEXT = true;
                }
                else
                {
                    qglLockArraysEXT = false;
                }
            }
            else
            {
                VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\\n");
                qglLockArraysEXT = false;
            }

            if (gl_config.extensions_string.IndexOf("WGL_EXT_swap_control") >= 0)
            {
                qwglSwapIntervalEXT = true;
                VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\\n");
            }
            else
            {
                qwglSwapIntervalEXT = false;
                VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\\n");
            }

            if (gl_config.extensions_string.IndexOf("GL_EXT_point_parameters") >= 0)
            {
                if (gl_ext_pointparameters.value != 0F)
                {
                    qglPointParameterfEXT = true;
                    VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\\n");
                }
                else
                {
                    VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\\n");
                }
            }
            else
            {
                VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\\n");
            }

            if (!qglColorTableEXT && gl_config.extensions_string.IndexOf("GL_EXT_paletted_texture") >= 0 && gl_config.extensions_string.IndexOf("GL_EXT_shared_texture_palette") >= 0)
            {
                if (gl_ext_palettedtexture.value != 0F)
                {
                    VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\\n");
                    qglColorTableEXT = false;
                }
                else
                {
                    VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\\n");
                    qglColorTableEXT = false;
                }
            }
            else
            {
                VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\\n");
            }

            if (gl_config.extensions_string.IndexOf("GL_ARB_multitexture") >= 0)
            {
                try
                {
                    GL.ClientActiveTexture(TextureUnit.Texture0);
                    VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\\n");
                    qglActiveTextureARB = true;
                    TEXTURE0            = ( Int32 )TextureUnit.Texture0;
                    TEXTURE1            = ( Int32 )TextureUnit.Texture1;
                }
                catch (Exception e)
                {
                    qglActiveTextureARB = false;
                }
            }
            else
            {
                qglActiveTextureARB = false;
                VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\\n");
            }

            if (!(qglActiveTextureARB))
            {
                VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing!\\n");
                return(false);
            }

            GL_SetDefaultState();
            GL_InitImages();
            Mod_Init();
            R_InitParticleTexture();
            Draw_InitLocal();
            ErrorCode err = GL.GetError();

            if (err != ErrorCode.NoError)
            {
                VID.Printf(Defines.PRINT_ALL, "GL.GetError() = 0x%x\\n\\t%s\\n", err, "" + Enum.GetName(typeof(ErrorCode), err));
            }
            glImpl.EndFrame();
            return(true);
        }