瀏覽代碼

video: allow to set the default clear color.

legacy
Sam Hocevar sam 12 年之前
父節點
當前提交
a3f410d697
共有 2 個檔案被更改,包括 17 行新增1 行删除
  1. +16
    -1
      src/video.cpp
  2. +1
    -0
      src/video.h

+ 16
- 1
src/video.cpp 查看文件

@@ -48,6 +48,7 @@ private:
#if defined _XBOX
static Direct3D *d3d_ctx;
static D3DDevice *d3d_dev;
static D3DCOLOR clear_color;
#endif
};

@@ -58,6 +59,7 @@ ivec2 VideoData::saved_viewport(0, 0);
#if defined _XBOX
Direct3D *VideoData::d3d_ctx;
D3DDevice *VideoData::d3d_dev;
D3DCOLOR VideoData::clear_color;
#endif

/*
@@ -85,6 +87,8 @@ void Video::Setup(ivec2 size)
size.y = VideoMode.dwDisplayHeight;
VideoData::saved_viewport = size;

VideoData::clear_color = D3DCOLOR_XRGB(26, 51, 77);

d3dpp.BackBufferWidth = size.x;
d3dpp.BackBufferHeight = size.y;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
@@ -185,13 +189,24 @@ void Video::SetDepth(bool set)
#endif
}

void Video::SetClearColor(vec4 color)
{
#if defined _XBOX
VideoData::clear_color = D3DCOLOR_XRGB((int)(color.r * 255.999f),
(int)(color.g * 255.999f),
(int)(color.b * 255.999f));
#else
glClearColor(color.r, color.g, color.b, color.a);
#endif
}

void Video::Clear()
{
ivec2 size = GetSize();
#if defined _XBOX
VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
| D3DCLEAR_STENCIL,
D3DCOLOR_XRGB(26, 51, 77), 1.0f, 0);
VideoData::clear_color, 1.0f, 0);
#else
glViewport(0, 0, size.x, size.y);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);


+ 1
- 0
src/video.h 查看文件

@@ -29,6 +29,7 @@ public:
static void Destroy();
static void SetFov(float theta);
static void SetDepth(bool set);
static void SetClearColor(vec4 color);
static void Clear();
static void Capture(uint32_t *buffer);
static ivec2 GetSize();


Loading…
取消
儲存