mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Split up color-bits into red-bits + green-bits + blue-bits
This commit is contained in:
parent
0358abfc0e
commit
bc24576b02
@ -117,10 +117,9 @@ get_properties(FrameBufferProperties &properties,
|
||||
|
||||
properties.set_back_buffers(1);
|
||||
properties.set_rgb_color(1);
|
||||
properties.set_color_bits(red_size+green_size+blue_size);
|
||||
properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size);
|
||||
properties.set_stencil_bits(stencil_size);
|
||||
properties.set_depth_bits(depth_size);
|
||||
properties.set_alpha_bits(alpha_size);
|
||||
properties.set_multisamples(samples);
|
||||
|
||||
// Set both hardware and software bits, indicating not-yet-known.
|
||||
|
@ -71,13 +71,14 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for
|
||||
properties.clear();
|
||||
|
||||
// Now update our framebuffer_mode and bit depth appropriately.
|
||||
GLint double_buffer, stereo, aux_buffers, color_size, alpha_size,
|
||||
depth_size, stencil_size, accum_size, sample_buffers, samples,
|
||||
renderer_id, accelerated, window, pbuffer;
|
||||
GLint double_buffer, stereo, aux_buffers, color_float, color_size,
|
||||
alpha_size, depth_size, stencil_size, accum_size, sample_buffers,
|
||||
samples, renderer_id, accelerated, window, pbuffer;
|
||||
|
||||
[pixel_format getValues:&double_buffer forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:screen];
|
||||
[pixel_format getValues:&stereo forAttribute:NSOpenGLPFAStereo forVirtualScreen:screen];
|
||||
[pixel_format getValues:&aux_buffers forAttribute:NSOpenGLPFAAuxBuffers forVirtualScreen:screen];
|
||||
[pixel_format getValues:&color_float forAttribute:NSOpenGLPFAColorFloat forVirtualScreen:screen];
|
||||
[pixel_format getValues:&color_size forAttribute:NSOpenGLPFAColorSize forVirtualScreen:screen];
|
||||
[pixel_format getValues:&alpha_size forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:screen];
|
||||
[pixel_format getValues:&depth_size forAttribute:NSOpenGLPFADepthSize forVirtualScreen:screen];
|
||||
@ -93,6 +94,7 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for
|
||||
properties.set_back_buffers(double_buffer);
|
||||
properties.set_stereo(stereo);
|
||||
properties.set_rgb_color(1);
|
||||
properties.set_float_color(color_float);
|
||||
properties.set_color_bits(color_size);
|
||||
properties.set_stencil_bits(stencil_size);
|
||||
properties.set_depth_bits(depth_size);
|
||||
|
@ -419,7 +419,18 @@ ConfigVariableInt depth_bits
|
||||
PRC_DESC("The minimum number of depth buffer bits requested."));
|
||||
ConfigVariableInt color_bits
|
||||
("color-bits", 0,
|
||||
PRC_DESC("The minimum number of color buffer bits requested."));
|
||||
PRC_DESC("The minimum number of total color buffer bits requested. This "
|
||||
"value is like red-bits + blue-bits + green-bits except Panda "
|
||||
"won't care how the bits are divided up."));
|
||||
ConfigVariableInt red_bits
|
||||
("red-bits", 0,
|
||||
PRC_DESC("The minimum number of red color buffer bits requested."));
|
||||
ConfigVariableInt green_bits
|
||||
("green-bits", 0,
|
||||
PRC_DESC("The minimum number of green color buffer bits requested."));
|
||||
ConfigVariableInt blue_bits
|
||||
("blue-bits", 0,
|
||||
PRC_DESC("The minimum number of blue color buffer bits requested."));
|
||||
ConfigVariableInt alpha_bits
|
||||
("alpha-bits", 0,
|
||||
PRC_DESC("The minimum number of alpha buffer bits requested."));
|
||||
|
@ -96,6 +96,9 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableBool framebuffer_srgb;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableBool framebuffer_float;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt depth_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt color_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt red_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt green_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt blue_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt alpha_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt stencil_bits;
|
||||
extern EXPCL_PANDA_DISPLAY ConfigVariableInt accum_bits;
|
||||
|
@ -90,7 +90,40 @@ get_depth_bits() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int FrameBufferProperties::
|
||||
get_color_bits() const {
|
||||
return _property[FBP_color_bits];
|
||||
return max(_property[FBP_color_bits],
|
||||
_property[FBP_red_bits] +
|
||||
_property[FBP_green_bits] +
|
||||
_property[FBP_blue_bits]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::get_red_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int FrameBufferProperties::
|
||||
get_red_bits() const {
|
||||
return _property[FBP_red_bits];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::get_green_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int FrameBufferProperties::
|
||||
get_green_bits() const {
|
||||
return _property[FBP_green_bits];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::get_blue_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int FrameBufferProperties::
|
||||
get_blue_bits() const {
|
||||
return _property[FBP_blue_bits];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -286,6 +319,58 @@ set_color_bits(int n) {
|
||||
_specified[FBP_color_bits] = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::set_rgba_bits
|
||||
// Access: Published
|
||||
// Description: Sets all color bit requirements separately.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void FrameBufferProperties::
|
||||
set_rgba_bits(int r, int g, int b, int a) {
|
||||
_property[FBP_red_bits] = r;
|
||||
_specified[FBP_red_bits] = true;
|
||||
_property[FBP_green_bits] = g;
|
||||
_specified[FBP_green_bits] = true;
|
||||
_property[FBP_blue_bits] = b;
|
||||
_specified[FBP_blue_bits] = true;
|
||||
_property[FBP_alpha_bits] = a;
|
||||
_specified[FBP_alpha_bits] = true;
|
||||
_property[FBP_color_bits] = r + g + b;
|
||||
_specified[FBP_color_bits] = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::set_red_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void FrameBufferProperties::
|
||||
set_red_bits(int n) {
|
||||
_property[FBP_red_bits] = n;
|
||||
_specified[FBP_red_bits] = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::set_green_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void FrameBufferProperties::
|
||||
set_green_bits(int n) {
|
||||
_property[FBP_green_bits] = n;
|
||||
_specified[FBP_green_bits] = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::set_blue_bits
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void FrameBufferProperties::
|
||||
set_blue_bits(int n) {
|
||||
_property[FBP_blue_bits] = n;
|
||||
_specified[FBP_blue_bits] = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::set_alpha_bits
|
||||
// Access: Published
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "string_utils.h"
|
||||
#include "renderBuffer.h"
|
||||
#include "config_display.h"
|
||||
#include "texture.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::Constructor
|
||||
@ -100,6 +101,9 @@ get_default() {
|
||||
display_cat.error() << " framebuffer-stereo #t\n";
|
||||
display_cat.error() << " depth-bits N\n";
|
||||
display_cat.error() << " color-bits N\n";
|
||||
display_cat.error() << " red-bits N\n";
|
||||
display_cat.error() << " green-bits N\n";
|
||||
display_cat.error() << " blue-bits N\n";
|
||||
display_cat.error() << " alpha-bits N\n";
|
||||
display_cat.error() << " stencil-bits N\n";
|
||||
display_cat.error() << " multisamples N\n";
|
||||
@ -143,6 +147,15 @@ get_default() {
|
||||
if (color_bits > 0) {
|
||||
default_props.set_color_bits(color_bits);
|
||||
}
|
||||
if (red_bits > 0) {
|
||||
default_props.set_red_bits(red_bits);
|
||||
}
|
||||
if (green_bits > 0) {
|
||||
default_props.set_green_bits(green_bits);
|
||||
}
|
||||
if (blue_bits > 0) {
|
||||
default_props.set_blue_bits(blue_bits);
|
||||
}
|
||||
if (alpha_bits > 0) {
|
||||
default_props.set_alpha_bits(alpha_bits);
|
||||
}
|
||||
@ -251,6 +264,15 @@ output(ostream &out) const {
|
||||
if (_property[FBP_color_bits] > 0) {
|
||||
out << "color_bits=" << _property[FBP_color_bits] << " ";
|
||||
}
|
||||
if (_property[FBP_red_bits] > 0) {
|
||||
out << "red_bits=" << _property[FBP_red_bits] << " ";
|
||||
}
|
||||
if (_property[FBP_green_bits] > 0) {
|
||||
out << "green_bits=" << _property[FBP_green_bits] << " ";
|
||||
}
|
||||
if (_property[FBP_blue_bits] > 0) {
|
||||
out << "blue_bits=" << _property[FBP_blue_bits] << " ";
|
||||
}
|
||||
if (_property[FBP_alpha_bits] > 0) {
|
||||
out << "alpha_bits=" << _property[FBP_alpha_bits] << " ";
|
||||
}
|
||||
@ -384,6 +406,15 @@ is_basic() const {
|
||||
if (_property[FBP_color_bits] > 1) {
|
||||
return false;
|
||||
}
|
||||
if (_property[FBP_red_bits] > 1) {
|
||||
return false;
|
||||
}
|
||||
if (_property[FBP_green_bits] > 1) {
|
||||
return false;
|
||||
}
|
||||
if (_property[FBP_blue_bits] > 1) {
|
||||
return false;
|
||||
}
|
||||
if (_property[FBP_alpha_bits] > 1) {
|
||||
return false;
|
||||
}
|
||||
@ -662,3 +693,120 @@ verify_hardware_software(const FrameBufferProperties &props, const string &rende
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::setup_color_texture
|
||||
// Access: Public
|
||||
// Description: Sets the texture up for render-to-texture matching
|
||||
// these framebuffer properties.
|
||||
//
|
||||
// Returns true if there was a format that had enough
|
||||
// bits, false otherwise. Of course, this is no
|
||||
// guarantee that a particular graphics back-end
|
||||
// supports rendering to textures of that format.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FrameBufferProperties::
|
||||
setup_color_texture(Texture *tex) const {
|
||||
// Note by rdb: I'm not entirely happy about this system. I'd
|
||||
// eventually like to move to a system in which framebuffer color
|
||||
// formats and texture formats are unified (like in Direct3D and
|
||||
// OpenGL) and where a table such as the below one would be
|
||||
// generated dynamically by the GSG to reflect the formats that
|
||||
// are supported for render-to-texture.
|
||||
|
||||
static const int num_formats = 12;
|
||||
static const struct {
|
||||
unsigned char color_bits, red_bits, green_bits, blue_bits, alpha_bits;
|
||||
bool has_float;
|
||||
Texture::Format format;
|
||||
} formats[num_formats] = {
|
||||
//{ 1, 1, 0, 0, 0, F_red},
|
||||
{ 1, 1, 1, 1, 0, false, Texture::F_rgb },
|
||||
{ 1, 1, 1, 1, 1, false, Texture::F_rgba },
|
||||
{ 24, 8, 8, 8, 0, false, Texture::F_rgb8 },
|
||||
{ 24, 8, 8, 8, 8, false, Texture::F_rgba8 },
|
||||
{ 16, 16, 0, 0, 0, true, Texture::F_r16 },
|
||||
{ 32, 16, 16, 0, 0, true, Texture::F_rg16 },
|
||||
{ 48, 16, 16, 16, 0, true, Texture::F_rgb16 },
|
||||
{ 48, 16, 16, 16, 16, true, Texture::F_rgba16 },
|
||||
{ 32, 32, 0, 0, 0, true, Texture::F_r32 },
|
||||
{ 64, 32, 32, 0, 0, true, Texture::F_rg32 },
|
||||
{ 96, 32, 32, 32, 0, true, Texture::F_rgb32 },
|
||||
{ 96, 32, 32, 32, 32, true, Texture::F_rgba32 },
|
||||
};
|
||||
|
||||
if (get_srgb_color()) {
|
||||
// These are the only sRGB formats. Deal with it.
|
||||
if (get_alpha_bits() == 0) {
|
||||
tex->set_format(Texture::F_srgb);
|
||||
} else {
|
||||
tex->set_format(Texture::F_srgb_alpha);
|
||||
}
|
||||
|
||||
return (get_color_bits() <= 24 &&
|
||||
get_red_bits() <= 8 &&
|
||||
get_green_bits() <= 8 &&
|
||||
get_blue_bits() <= 8 &&
|
||||
get_alpha_bits() <= 8);
|
||||
|
||||
} else {
|
||||
if (get_float_color()) {
|
||||
tex->set_component_type(Texture::T_float);
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_formats; ++i) {
|
||||
if (get_color_bits() <= (int)formats[i].color_bits &&
|
||||
get_red_bits() <= (int)formats[i].red_bits &&
|
||||
get_blue_bits() <= (int)formats[i].blue_bits &&
|
||||
get_alpha_bits() <= (int)formats[i].alpha_bits &&
|
||||
get_float_color() <= formats[i].has_float) {
|
||||
|
||||
tex->set_format(formats[i].format);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't get requested bits. Choose a generic format and return.
|
||||
tex->set_format((get_alpha_bits() == 0) ? Texture::F_rgb : Texture::F_rgba);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::setup_depth_texture
|
||||
// Access: Public
|
||||
// Description: Sets the texture up for render-to-texture matching
|
||||
// these framebuffer properties.
|
||||
//
|
||||
// Returns true if there was a format that had enough
|
||||
// bits, false otherwise. Of course, this is no
|
||||
// guarantee that a particular graphics back-end
|
||||
// supports rendering to textures of that format.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FrameBufferProperties::
|
||||
setup_depth_texture(Texture *tex) const {
|
||||
if (get_float_depth()) {
|
||||
tex->set_component_type(Texture::T_float);
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
return (get_depth_bits() <= 32);
|
||||
|
||||
} else if (get_depth_bits() <= 1) {
|
||||
tex->set_format(Texture::F_depth_component);
|
||||
return true;
|
||||
|
||||
} else if (get_depth_bits() <= 16) {
|
||||
tex->set_format(Texture::F_depth_component16);
|
||||
return true;
|
||||
|
||||
} else if (get_depth_bits() <= 24) {
|
||||
tex->set_format(Texture::F_depth_component24);
|
||||
return true;
|
||||
|
||||
} else if (get_depth_bits() <= 32) {
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
return true;
|
||||
}
|
||||
|
||||
tex->set_format(Texture::F_depth_component);
|
||||
return false;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "pandabase.h"
|
||||
#include "pnotify.h"
|
||||
|
||||
class Texture;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : FrameBufferProperties
|
||||
// Description : A container for the various kinds of properties we
|
||||
@ -31,6 +33,9 @@ private:
|
||||
// This section has to start with "depth" and end with "accum"
|
||||
FBP_depth_bits,
|
||||
FBP_color_bits,
|
||||
FBP_red_bits,
|
||||
FBP_green_bits,
|
||||
FBP_blue_bits,
|
||||
FBP_alpha_bits,
|
||||
FBP_stencil_bits,
|
||||
FBP_accum_bits,
|
||||
@ -72,6 +77,9 @@ PUBLISHED:
|
||||
// Individual queries.
|
||||
INLINE int get_depth_bits() const;
|
||||
INLINE int get_color_bits() const;
|
||||
INLINE int get_red_bits() const;
|
||||
INLINE int get_green_bits() const;
|
||||
INLINE int get_blue_bits() const;
|
||||
INLINE int get_alpha_bits() const;
|
||||
INLINE int get_stencil_bits() const;
|
||||
INLINE int get_accum_bits() const;
|
||||
@ -93,6 +101,10 @@ PUBLISHED:
|
||||
// Individual assigners.
|
||||
INLINE void set_depth_bits(int n);
|
||||
INLINE void set_color_bits(int n);
|
||||
INLINE void set_rgba_bits(int r, int g, int b, int a);
|
||||
INLINE void set_red_bits(int n);
|
||||
INLINE void set_green_bits(int n);
|
||||
INLINE void set_blue_bits(int n);
|
||||
INLINE void set_alpha_bits(int n);
|
||||
INLINE void set_stencil_bits(int n);
|
||||
INLINE void set_accum_bits(int n);
|
||||
@ -136,6 +148,9 @@ PUBLISHED:
|
||||
int get_aux_mask() const;
|
||||
int get_buffer_mask() const;
|
||||
bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const;
|
||||
|
||||
bool setup_color_texture(Texture *tex) const;
|
||||
bool setup_depth_texture(Texture *tex) const;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties);
|
||||
|
@ -4476,32 +4476,34 @@ FrameBufferProperties DXGraphicsStateGuardian8::
|
||||
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) {
|
||||
FrameBufferProperties props;
|
||||
int index=0;
|
||||
int alpha=0;
|
||||
int color=0;
|
||||
int r=0, g=0, b=0, a=0;
|
||||
switch (cformat) {
|
||||
case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break;
|
||||
case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break;
|
||||
case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break;
|
||||
case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break;
|
||||
case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break;
|
||||
case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break;
|
||||
case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break;
|
||||
case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break;
|
||||
case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break;
|
||||
case D3DFMT_A8P8: index=1; color= 8; alpha=8; break;
|
||||
case D3DFMT_P8: index=1; color= 8; alpha=0; break;
|
||||
case D3DFMT_R8G8B8: r=8; g=8; b=8; a=0; break;
|
||||
case D3DFMT_A8R8G8B8: r=8; g=8; b=8; a=8; break;
|
||||
case D3DFMT_X8R8G8B8: r=8; g=8; b=8; a=0; break;
|
||||
case D3DFMT_R5G6B5: r=5; g=6; b=5; a=0; break;
|
||||
case D3DFMT_X1R5G5B5: r=5; g=5; b=5; a=0; break;
|
||||
case D3DFMT_A1R5G5B5: r=5; g=5; b=5; a=1; break;
|
||||
case D3DFMT_A4R4G4B4: r=4; g=4; b=4; a=4; break;
|
||||
case D3DFMT_R3G3B2: r=3; g=3; b=2; a=0; break;
|
||||
case D3DFMT_A8R3G3B2: r=3; g=3; b=2; a=8; break;
|
||||
case D3DFMT_X4R4G4B4: r=4; g=4; b=4; a=0; break;
|
||||
case D3DFMT_A2B10G10R10: r=10;g=10;b=10;a=2; break;
|
||||
case D3DFMT_A8P8: index=8; a=8; break;
|
||||
case D3DFMT_P8: index=8; a=0; break;
|
||||
default: break;
|
||||
}
|
||||
props.set_color_bits(color);
|
||||
props.set_alpha_bits(alpha);
|
||||
if (index) {
|
||||
if (index > 0) {
|
||||
props.set_rgb_color(0);
|
||||
props.set_indexed_color(1);
|
||||
} else if (color) {
|
||||
props.set_color_bits(index);
|
||||
} else if (r + g + b > 0) {
|
||||
props.set_rgb_color(1);
|
||||
props.set_indexed_color(0);
|
||||
props.set_rgba_bits(r, g, b, a);
|
||||
}
|
||||
props.set_alpha_bits(a);
|
||||
|
||||
int depth=0;
|
||||
int stencil=0;
|
||||
switch (dformat) {
|
||||
@ -4511,6 +4513,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) {
|
||||
case D3DFMT_D16: depth=16; stencil=0; break;
|
||||
case D3DFMT_D24X8: depth=24; stencil=0; break;
|
||||
case D3DFMT_D24X4S4: depth=24; stencil=4; break;
|
||||
default: break;
|
||||
}
|
||||
props.set_depth_bits(depth);
|
||||
props.set_stencil_bits(stencil);
|
||||
|
@ -5403,32 +5403,34 @@ calc_fb_properties(DWORD cformat, DWORD dformat,
|
||||
DWORD multisampletype, DWORD multisamplequality) {
|
||||
FrameBufferProperties props;
|
||||
int index=0;
|
||||
int alpha=0;
|
||||
int color=0;
|
||||
int r=0, g=0, b=0, a=0;
|
||||
switch (cformat) {
|
||||
case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break;
|
||||
case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break;
|
||||
case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break;
|
||||
case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break;
|
||||
case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break;
|
||||
case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break;
|
||||
case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break;
|
||||
case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break;
|
||||
case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break;
|
||||
case D3DFMT_A8P8: index=1; color= 8; alpha=8; break;
|
||||
case D3DFMT_P8: index=1; color= 8; alpha=0; break;
|
||||
case D3DFMT_R8G8B8: r=8; g=8; b=8; a=0; break;
|
||||
case D3DFMT_A8R8G8B8: r=8; g=8; b=8; a=8; break;
|
||||
case D3DFMT_X8R8G8B8: r=8; g=8; b=8; a=0; break;
|
||||
case D3DFMT_R5G6B5: r=5; g=6; b=5; a=0; break;
|
||||
case D3DFMT_X1R5G5B5: r=5; g=5; b=5; a=0; break;
|
||||
case D3DFMT_A1R5G5B5: r=5; g=5; b=5; a=1; break;
|
||||
case D3DFMT_A4R4G4B4: r=4; g=4; b=4; a=4; break;
|
||||
case D3DFMT_R3G3B2: r=3; g=3; b=2; a=0; break;
|
||||
case D3DFMT_A8R3G3B2: r=3; g=3; b=2; a=8; break;
|
||||
case D3DFMT_X4R4G4B4: r=4; g=4; b=4; a=0; break;
|
||||
case D3DFMT_A2B10G10R10: r=10;g=10;b=10;a=2; break;
|
||||
case D3DFMT_A8P8: index=8; a=8; break;
|
||||
case D3DFMT_P8: index=8; a=0; break;
|
||||
default: break;
|
||||
}
|
||||
props.set_color_bits(color);
|
||||
props.set_alpha_bits(alpha);
|
||||
if (index) {
|
||||
if (index > 0) {
|
||||
props.set_rgb_color(0);
|
||||
props.set_indexed_color(1);
|
||||
} else if (color) {
|
||||
props.set_color_bits(index);
|
||||
} else if (r + g + b > 0) {
|
||||
props.set_rgb_color(1);
|
||||
props.set_indexed_color(0);
|
||||
props.set_rgba_bits(r, g, b, a);
|
||||
}
|
||||
props.set_alpha_bits(a);
|
||||
|
||||
int depth=0;
|
||||
int stencil=0;
|
||||
switch (dformat) {
|
||||
@ -5438,6 +5440,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat,
|
||||
case D3DFMT_D16: depth=16; stencil=0; break;
|
||||
case D3DFMT_D24X8: depth=24; stencil=0; break;
|
||||
case D3DFMT_D24X4S4: depth=24; stencil=4; break;
|
||||
default: break;
|
||||
}
|
||||
props.set_depth_bits(depth);
|
||||
props.set_stencil_bits(stencil);
|
||||
|
@ -123,10 +123,9 @@ get_properties(FrameBufferProperties &properties,
|
||||
|
||||
properties.set_back_buffers(1);
|
||||
properties.set_rgb_color(1);
|
||||
properties.set_color_bits(red_size+green_size+blue_size);
|
||||
properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size);
|
||||
properties.set_stencil_bits(stencil_size);
|
||||
properties.set_depth_bits(depth_size);
|
||||
properties.set_alpha_bits(alpha_size);
|
||||
properties.set_multisamples(samples);
|
||||
|
||||
// Set both hardware and software bits, indicating not-yet-known.
|
||||
|
@ -626,18 +626,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
||||
// Adjust the texture format based on the requested framebuffer settings.
|
||||
switch (slot) {
|
||||
case RTP_depth:
|
||||
if (_fb_properties.get_float_depth()) {
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
tex->set_component_type(Texture::T_float);
|
||||
} else if (_fb_properties.get_depth_bits() > 24) {
|
||||
tex->set_format(Texture::F_depth_component32);
|
||||
} else if (_fb_properties.get_depth_bits() > 16) {
|
||||
tex->set_format(Texture::F_depth_component24);
|
||||
} else if (_fb_properties.get_depth_bits() > 8) {
|
||||
tex->set_format(Texture::F_depth_component16);
|
||||
} else {
|
||||
tex->set_format(Texture::F_depth_component);
|
||||
}
|
||||
_fb_properties.setup_depth_texture(tex);
|
||||
break;
|
||||
case RTP_depth_stencil:
|
||||
tex->set_format(Texture::F_depth_stencil);
|
||||
@ -663,34 +652,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
|
||||
tex->set_component_type(Texture::T_float);
|
||||
break;
|
||||
default:
|
||||
if (_fb_properties.get_srgb_color()) {
|
||||
if (_fb_properties.get_alpha_bits() == 0) {
|
||||
tex->set_format(Texture::F_srgb);
|
||||
} else {
|
||||
tex->set_format(Texture::F_srgb_alpha);
|
||||
}
|
||||
} else {
|
||||
if (_fb_properties.get_float_color()) {
|
||||
tex->set_component_type(Texture::T_float);
|
||||
}
|
||||
if (_fb_properties.get_alpha_bits() == 0) {
|
||||
if (_fb_properties.get_color_bits() > 16 * 3) {
|
||||
tex->set_format(Texture::F_rgb32);
|
||||
} else if (_fb_properties.get_color_bits() > 8 * 3) {
|
||||
tex->set_format(Texture::F_rgb16);
|
||||
} else {
|
||||
tex->set_format(Texture::F_rgb);
|
||||
}
|
||||
} else {
|
||||
if (_fb_properties.get_color_bits() > 16 * 3) {
|
||||
tex->set_format(Texture::F_rgba32);
|
||||
} else if (_fb_properties.get_color_bits() > 8 * 3) {
|
||||
tex->set_format(Texture::F_rgba16);
|
||||
} else {
|
||||
tex->set_format(Texture::F_rgba);
|
||||
}
|
||||
}
|
||||
}
|
||||
_fb_properties.setup_color_texture(tex);
|
||||
}
|
||||
|
||||
#ifndef OPENGLES
|
||||
|
@ -126,10 +126,10 @@ get_properties(FrameBufferProperties &properties, XVisualInfo *visual) {
|
||||
} else {
|
||||
properties.set_indexed_color(1);
|
||||
}
|
||||
properties.set_color_bits(red_size+green_size+blue_size);
|
||||
|
||||
properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size);
|
||||
properties.set_stencil_bits(stencil_size);
|
||||
properties.set_depth_bits(depth_size);
|
||||
properties.set_alpha_bits(alpha_size);
|
||||
properties.set_accum_bits(ared_size+agreen_size+ablue_size+aalpha_size);
|
||||
|
||||
// Set both hardware and software bits, indicating not-yet-known.
|
||||
@ -212,10 +212,9 @@ get_properties_advanced(FrameBufferProperties &properties,
|
||||
properties.set_indexed_color(true);
|
||||
}
|
||||
|
||||
properties.set_color_bits(red_size+green_size+blue_size);
|
||||
properties.set_rgba_bits(red_size, green_size, blue_size, alpha_size);
|
||||
properties.set_stencil_bits(stencil_size);
|
||||
properties.set_depth_bits(depth_size);
|
||||
properties.set_alpha_bits(alpha_size);
|
||||
properties.set_accum_bits(ared_size+agreen_size+ablue_size+aalpha_size);
|
||||
properties.set_multisamples(samples);
|
||||
|
||||
|
@ -200,11 +200,11 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
|
||||
attrib.push_back(AGL_PIXEL_SIZE);
|
||||
attrib.push_back(color_bits);
|
||||
attrib.push_back(AGL_RED_SIZE);
|
||||
attrib.push_back(color_bits / 3);
|
||||
attrib.push_back(fb_props.get_red_bits());
|
||||
attrib.push_back(AGL_GREEN_SIZE);
|
||||
attrib.push_back(color_bits / 3);
|
||||
attrib.push_back(fb_props.get_green_bits());
|
||||
attrib.push_back(AGL_BLUE_SIZE);
|
||||
attrib.push_back(color_bits / 3);
|
||||
attrib.push_back(fb_props.get_blue_bits());
|
||||
attrib.push_back(AGL_ALPHA_SIZE);
|
||||
attrib.push_back(alpha_bits);
|
||||
}
|
||||
@ -314,12 +314,15 @@ describe_pixel_format(FrameBufferProperties &fb_props) {
|
||||
}
|
||||
int color_bits = 0;
|
||||
if (aglDescribePixelFormat(_aglPixFmt, AGL_RED_SIZE, &value)) {
|
||||
fb_props.set_red_bits(value);
|
||||
color_bits += value;
|
||||
}
|
||||
if (aglDescribePixelFormat(_aglPixFmt, AGL_GREEN_SIZE, &value)) {
|
||||
fb_props.set_green_bits(value);
|
||||
color_bits += value;
|
||||
}
|
||||
if (aglDescribePixelFormat(_aglPixFmt, AGL_BLUE_SIZE, &value)) {
|
||||
fb_props.set_blue_bits(value);
|
||||
color_bits += value;
|
||||
}
|
||||
fb_props.set_color_bits(color_bits);
|
||||
|
@ -123,8 +123,12 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) {
|
||||
|
||||
if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
|
||||
properties.set_indexed_color(1);
|
||||
properties.set_color_bits(pfd.cColorBits);
|
||||
properties.set_alpha_bits(pfd.cAlphaBits);
|
||||
} else {
|
||||
properties.set_rgb_color(1);
|
||||
properties.set_rgba_bits(pfd.cRedBits, pfd.cGreenBits,
|
||||
pfd.cBlueBits, pfd.cAlphaBits);
|
||||
}
|
||||
|
||||
int mode = 0;
|
||||
@ -140,12 +144,6 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) {
|
||||
properties.set_force_hardware(1);
|
||||
}
|
||||
|
||||
if (pfd.cColorBits != 0) {
|
||||
properties.set_color_bits(pfd.cColorBits);
|
||||
}
|
||||
if (pfd.cAlphaBits != 0) {
|
||||
properties.set_alpha_bits(pfd.cAlphaBits);
|
||||
}
|
||||
if (pfd.cDepthBits != 0) {
|
||||
properties.set_depth_bits(pfd.cDepthBits);
|
||||
}
|
||||
@ -173,14 +171,18 @@ get_properties_advanced(FrameBufferProperties &properties,
|
||||
int ni = 0;
|
||||
|
||||
int acceleration_i, pixel_type_i, double_buffer_i, stereo_i,
|
||||
color_bits_i, alpha_bits_i, accum_bits_i, depth_bits_i,
|
||||
stencil_bits_i, multisamples_i, srgb_capable_i;
|
||||
color_bits_i, red_bits_i, green_bits_i, blue_bits_i, alpha_bits_i,
|
||||
accum_bits_i, depth_bits_i, stencil_bits_i, multisamples_i,
|
||||
srgb_capable_i;
|
||||
|
||||
iattrib_list[acceleration_i = ni++] = WGL_ACCELERATION_ARB;
|
||||
iattrib_list[pixel_type_i = ni++] = WGL_PIXEL_TYPE_ARB;
|
||||
iattrib_list[double_buffer_i = ni++] = WGL_DOUBLE_BUFFER_ARB;
|
||||
iattrib_list[stereo_i = ni++] = WGL_STEREO_ARB;
|
||||
iattrib_list[color_bits_i = ni++] = WGL_COLOR_BITS_ARB;
|
||||
iattrib_list[red_bits_i = ni++] = WGL_RED_BITS_ARB;
|
||||
iattrib_list[green_bits_i = ni++] = WGL_GREEN_BITS_ARB;
|
||||
iattrib_list[blue_bits_i = ni++] = WGL_BLUE_BITS_ARB;
|
||||
iattrib_list[alpha_bits_i = ni++] = WGL_ALPHA_BITS_ARB;
|
||||
iattrib_list[accum_bits_i = ni++] = WGL_ACCUM_BITS_ARB;
|
||||
iattrib_list[depth_bits_i = ni++] = WGL_DEPTH_BITS_ARB;
|
||||
@ -211,8 +213,14 @@ get_properties_advanced(FrameBufferProperties &properties,
|
||||
|
||||
if (ivalue_list[pixel_type_i] == WGL_TYPE_COLORINDEX_ARB) {
|
||||
properties.set_indexed_color(true);
|
||||
properties.set_color_bits(ivalue_list[color_bits_i]);
|
||||
properties.set_alpha_bits(ivalue_list[alpha_bits_i]);
|
||||
} else {
|
||||
properties.set_rgb_color(true);
|
||||
properties.set_rgba_bits(ivalue_list[red_bits_i],
|
||||
ivalue_list[green_bits_i],
|
||||
ivalue_list[blue_bits_i],
|
||||
ivalue_list[alpha_bits_i]);
|
||||
}
|
||||
|
||||
if (ivalue_list[double_buffer_i]) {
|
||||
@ -227,10 +235,6 @@ get_properties_advanced(FrameBufferProperties &properties,
|
||||
properties.set_srgb_color(true);
|
||||
}
|
||||
|
||||
if (ivalue_list[alpha_bits_i] != 0) {
|
||||
properties.set_alpha_bits(ivalue_list[alpha_bits_i]);
|
||||
}
|
||||
|
||||
if (ivalue_list[accum_bits_i] != 0) {
|
||||
properties.set_accum_bits(ivalue_list[accum_bits_i]);
|
||||
}
|
||||
@ -249,8 +253,6 @@ get_properties_advanced(FrameBufferProperties &properties,
|
||||
}
|
||||
}
|
||||
|
||||
properties.set_color_bits(ivalue_list[color_bits_i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user