Пример #1
0
        // Draw_AlphaPic
        public static void DrawAlphaPic(int x, int y, glpic_t pic, float alpha)
        {
            if (_ScrapDirty)
            {
                UploadScrap();
            }

            GL.Disable(EnableCap.AlphaTest);
            GL.Enable(EnableCap.Blend);
            GL.Color4(1f, 1f, 1f, alpha);
            Bind(pic.texnum);
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(pic.sl, pic.tl);
            GL.Vertex2(x, y);
            GL.TexCoord2(pic.sh, pic.tl);
            GL.Vertex2(x + pic.width, y);
            GL.TexCoord2(pic.sh, pic.th);
            GL.Vertex2(x + pic.width, y + pic.height);
            GL.TexCoord2(pic.sl, pic.th);
            GL.Vertex2(x, y + pic.height);
            GL.End();
            GL.Color4(1f, 1f, 1f, 1f);
            GL.Enable(EnableCap.AlphaTest);
            GL.Disable(EnableCap.Blend);
        }
Пример #2
0
        // Draw_Pic(int x, int y, qpic_t* pic)
        public static void DrawPic(int x, int y, glpic_t pic)
        {
            if (_ScrapDirty)
            {
                UploadScrap();
            }

            GL.Color4(1f, 1f, 1f, 1f);
            Bind(pic.texnum);
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(pic.sl, pic.tl);
            GL.Vertex2(x, y);
            GL.TexCoord2(pic.sh, pic.tl);
            GL.Vertex2(x + pic.width, y);
            GL.TexCoord2(pic.sh, pic.th);
            GL.Vertex2(x + pic.width, y + pic.height);
            GL.TexCoord2(pic.sl, pic.th);
            GL.Vertex2(x, y + pic.height);
            GL.End();
        }
Пример #3
0
        // Draw_Init
        public static void Init()
        {
            for (int i = 0; i < _MenuCachePics.Length; i++)
            {
                _MenuCachePics[i] = new cachepic_t();
            }

            if (_glNoBind == null)
            {
                _glNoBind  = new Cvar("gl_nobind", "0");
                _glMaxSize = new Cvar("gl_max_size", "1024");
                _glPicMip  = new Cvar("gl_picmip", "0");
            }

            // 3dfx can only handle 256 wide textures
            string renderer = GL.GetString(StringName.Renderer);

            if (renderer.Contains("3dfx") || renderer.Contains("Glide"))
            {
                Cvar.Set("gl_max_size", "256");
            }

            Cmd.Add("gl_texturemode", TextureMode_f);

            // load the console background and the charset
            // by hand, because we need to write the version
            // string into the background before turning
            // it into a texture
            int offset = Wad.GetLumpNameOffset("conchars");

            byte[] draw_chars = Wad.Data; // draw_chars
            for (int i = 0; i < 256 * 64; i++)
            {
                if (draw_chars[offset + i] == 0)
                {
                    draw_chars[offset + i] = 255;               // proper transparent color
                }
            }

            // now turn them into textures
            _CharTexture = LoadTexture("charset", 128, 128, new ByteArraySegment(draw_chars, offset), false, true);

            byte[] buf = Common.LoadFile("gfx/conback.lmp");
            if (buf == null)
            {
                Sys.Error("Couldn't load gfx/conback.lmp");
            }

            dqpicheader_t cbHeader = Sys.BytesToStructure <dqpicheader_t>(buf, 0);

            Wad.SwapPic(cbHeader);

            // hack the version number directly into the pic
            string ver     = String.Format("(c# {0,7:F2}) {1,7:F2}", (float)QDef.CSQUAKE_VERSION, (float)QDef.VERSION);
            int    offset2 = Marshal.SizeOf(typeof(dqpicheader_t)) + 320 * 186 + 320 - 11 - 8 * ver.Length;
            int    y       = ver.Length;

            for (int x = 0; x < y; x++)
            {
                CharToConback(ver[x], new ByteArraySegment(buf, offset2 + (x << 3)), new ByteArraySegment(draw_chars, offset));
            }

            _ConBack        = new glpic_t();
            _ConBack.width  = cbHeader.width;
            _ConBack.height = cbHeader.height;
            int ncdataIndex = Marshal.SizeOf(typeof(dqpicheader_t)); // cb->data;

            SetTextureFilters(TextureMinFilter.Nearest, TextureMagFilter.Nearest);

            _ConBack.texnum = LoadTexture("conback", _ConBack.width, _ConBack.height, new ByteArraySegment(buf, ncdataIndex), false, false);
            _ConBack.width  = Scr.vid.width;
            _ConBack.height = Scr.vid.height;

            // save a texture slot for translated picture
            _TranslateTexture = _TextureExtensionNumber++;

            // save slots for scraps
            _ScrapTexNum             = _TextureExtensionNumber;
            _TextureExtensionNumber += MAX_SCRAPS;

            //
            // get the other pics we need
            //
            _Disc     = PicFromWad("disc");
            _BackTile = PicFromWad("backtile");
        }