Beispiel #1
0
        static public void Draw(D3dBB2d bb, d3d_device device, float z, Vector2 offset, float scale, int color)
        {
            Vector2 pos  = offsetscale(bb.Min, offset, scale);
            Vector2 pos2 = offsetscale(bb.Max, offset, scale);

            pos  += bb.OffsetLT;
            pos2 += bb.OffsetRB;
            Vector2 size = pos2 - pos;

            device.DrawLineRect(new Vector3(pos.X, pos.Y, z), size, color);
        }
 /*-------------------------------------------------------------------------
  * Streamから構築
  * 組み込みリソースからの構築用
  * 通常DDSファイルを使用すること
  *
  * 2のべき乗でない場合強制的に2のべき乗に変換されてしまうので注意
  * 2のべき乗で絵を作ること
  * ---------------------------------------------------------------------------*/
 public d3d_sprite_rects(d3d_device device, Stream stream)
 {
     try{
         m_texture      = TextureLoader.FromStream(device.device, stream);
         m_texture_size = d3d_utility.GetTextureSize(m_texture);
     }catch {
         m_texture        = null;
         m_texture_size.X = 0;
         m_texture_size.Y = 0;
     }
     m_rects = new List <rect>();
 }
Beispiel #3
0
        /*-------------------------------------------------------------------------
         * 初期化
         * ---------------------------------------------------------------------------*/
        public d3d_systemfont(d3d_device device)
        {
            if (device == null)
            {
                return;
            }

            // 2のべき乗でない場合強制的に2のべき乗に변환されてしまうので注意
            // 2のべき乗で絵を作ること
            Assembly ass    = Assembly.GetExecutingAssembly();
            Stream   stream = ass.GetManifestResourceStream("directx.image.systemfont_8x16_ui_gothic.dds");

            m_sprite_rects = new d3d_sprite_rects(device, stream);
            initialize(device);
        }
Beispiel #4
0
        /*-------------------------------------------------------------------------
         * 初期化
         * ---------------------------------------------------------------------------*/
        private void initialize(d3d_device device)
        {
            m_d3d_device = device;
            if (device.device == null)
            {
                return;
            }

            m_sprite = new d3d_sprite(device.device, device.is_use_ve1_1_ps1_1);

            // 矩形등록
            init_rects();

            // 初期위치
            locate = new Vector3(0, 0, 0.1f);
        }
            public textured_font(d3d_device device, string str, Microsoft.DirectX.Direct3D.Font font, Format format)
            {
                m_ref_count = 0;
                m_str       = str;
                try {
                    Rectangle rect = font.MeasureString(null, str, DrawTextFormat.None, Color.White);
                    m_size = new Vector2(rect.Right, rect.Bottom);

                    // 텍스쳐を작성
                    // 사이즈は4の배수とする
                    int width  = (((int)m_size.X) + 3) & ~3;
                    int height = (((int)m_size.Y) + 3) & ~3;
                    m_texture_size = new Vector2(width, height);
                    m_texture      = new Texture(device.device, width, height, 1,
                                                 Usage.RenderTarget, format, Pool.Default);
                } catch {
                    // 텍스쳐작성실패
                    m_size         = new Vector2(0, 0);
                    m_texture_size = new Vector2(0, 0);
                    m_texture      = null;
                    return;
                }

                // 렌더링 타겟を지정
                Surface depth      = device.device.DepthStencilSurface;
                Surface backbuffer = device.device.GetBackBuffer(0, 0, BackBufferType.Mono);

                device.device.DepthStencilSurface = null;                          // zバッファ없음
                device.device.SetRenderTarget(0, m_texture.GetSurfaceLevel(0));

                // 화면のクリア
                device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0));
                // 렌더링
                device.device.RenderState.ZBufferEnable = false;
                font.DrawText(null, str, new Point(0, 0), Color.White);
                device.device.RenderState.ZBufferEnable = true;

                // 렌더링 타겟を元に戻す
                device.device.DepthStencilSurface = depth;
                device.device.SetRenderTarget(0, backbuffer);

                backbuffer.Dispose();
                depth.Dispose();
            }
        /*-------------------------------------------------------------------------
         *
         * ---------------------------------------------------------------------------*/
        public d3d_textured_font(d3d_device device, Microsoft.DirectX.Direct3D.Font font)
        {
            m_device = device;
            m_font   = font;
            m_map    = new Dictionary <string, textured_font>();
            m_device.device.DeviceReset += new System.EventHandler(device_reset);

            // A1R5G5B5の렌더링 타겟が사용가능か調べる
            // 사용できない場合はA8R8G8B8を사용する
            // Radeon계は사용가능
            // NVIDIA계は사용不可
            // Intel계はたぶん사용가능
            m_texture_format = Format.A1R5G5B5;
            if (!m_device.CheckDeviceFormat(Usage.RenderTarget, ResourceType.Textures, Format.A1R5G5B5))
            {
                // A1R5G5B5の렌더링 타겟が作れない
                m_texture_format = Format.A8R8G8B8;
            }
        }
Beispiel #7
0
        /*-------------------------------------------------------------------------
         *
         * ---------------------------------------------------------------------------*/
        public d3d_textured_font(d3d_device device, Microsoft.DirectX.Direct3D.Font font)
        {
            m_device = device;
            m_font   = font;
            m_map    = new Dictionary <string, textured_font>();
            m_device.device.DeviceReset += new System.EventHandler(device_reset);

            // A1R5G5B5のレンダーターゲットが使用可能か調べる
            // 使用できない場合はA8R8G8B8を使用する
            // Radeon系は使用可能
            // NVIDIA系は使用不可
            // Intel系はたぶん使用可能
            m_texture_format = Format.A1R5G5B5;
            if (!m_device.CheckDeviceFormat(Usage.RenderTarget, ResourceType.Textures, Format.A1R5G5B5))
            {
                // A1R5G5B5のレンダーターゲットが作れない
                m_texture_format = Format.A8R8G8B8;
            }
        }
Beispiel #8
0
            /*-------------------------------------------------------------------------
             *
             * ---------------------------------------------------------------------------*/
            public window(d3d_device device, Vector2 pos, Vector2 size, float z)
            {
                m_device = device;
                m_pos    = pos;
                m_size   = size;
                m_z      = z;
                title    = "タイトル";

                m_back_color  = Color.FromArgb(180, 170, 170, 170).ToArgb();
                title_color   = Color.SkyBlue.ToArgb();
                m_frame_color = Color.Black.ToArgb();

                m_window_mode  = mode.normal;
                m_screen_size  = new Vector2(0, 0);
                is_draw_header = true;

                update_pos();
                update_size();
            }
Beispiel #9
0
 /*-------------------------------------------------------------------------
  * 描画
  * (offset + pos) * scale
  * ---------------------------------------------------------------------------*/
 public void Draw(d3d_device device, float z, Vector2 offset, float scale, int color)
 {
     D3dBB2d.Draw(this, device, z, offset, scale, color);
 }
Beispiel #10
0
 static public void Draw(D3dBB2d bb, d3d_device device, float z, int color)
 {
     Draw(bb, device, z, new Vector2(0, 0), 1, color);
 }
Beispiel #11
0
 /*-------------------------------------------------------------------------
  * 描画
  * ---------------------------------------------------------------------------*/
 public void Draw(d3d_device device, float z, int color)
 {
     D3dBB2d.Draw(this, device, z, color);
 }
 /*-------------------------------------------------------------------------
  *
  * ---------------------------------------------------------------------------*/
 public textured_font(d3d_device device, string str, Microsoft.DirectX.Direct3D.Font font)
     : this(device, str, font, Format.A8R8G8B8)
 {
 }
Beispiel #13
0
 /*-------------------------------------------------------------------------
  *
  * ---------------------------------------------------------------------------*/
 public d3d_windows(d3d_device device)
 {
     m_device  = device;
     m_windows = new List <window>();
 }