Selaa lähdekoodia

video: allow to set the default clear color.

legacy
Sam Hocevar sam 13 vuotta sitten
vanhempi
commit
a3f410d697
2 muutettua tiedostoa jossa 17 lisäystä ja 1 poistoa
  1. +16
    -1
      src/video.cpp
  2. +1
    -0
      src/video.h

+ 16
- 1
src/video.cpp Näytä tiedosto

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


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


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


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

d3dpp.BackBufferWidth = size.x; d3dpp.BackBufferWidth = size.x;
d3dpp.BackBufferHeight = size.y; d3dpp.BackBufferHeight = size.y;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
@@ -185,13 +189,24 @@ void Video::SetDepth(bool set)
#endif #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() void Video::Clear()
{ {
ivec2 size = GetSize(); ivec2 size = GetSize();
#if defined _XBOX #if defined _XBOX
VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER VideoData::d3d_dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER
| D3DCLEAR_STENCIL, | D3DCLEAR_STENCIL,
D3DCOLOR_XRGB(26, 51, 77), 1.0f, 0); VideoData::clear_color, 1.0f, 0);
#else #else
glViewport(0, 0, size.x, size.y); glViewport(0, 0, size.x, size.y);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);


+ 1
- 0
src/video.h Näytä tiedosto

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


||||||
x
 
000:0
Ladataan…
Peruuta
Tallenna