if(!count)
throw invalid_operation("RenderTargetFormat::operator,");
- PixelFormat unsized = get_unsized_pixelformat(f);
+ PixelComponents comp = get_components(f);
unsigned size = get_component_size(f);
unsigned char out = outputs[count-1];
if(get_output_type(out)>=get_output_type(RENDER_DEPTH))
{
- if(unsized!=DEPTH_COMPONENT)
- throw invalid_argument("RenderTargetformat::operator,");
+ if(comp!=DEPTH_COMPONENT)
+ throw invalid_argument("RenderTargetFormat::operator,");
if(size>1)
--size;
+ if(get_component_type(f)==UNSIGNED_INT)
+ --size;
}
else
{
- if(unsized!=RED && unsized!=RG && unsized!=RGB && unsized!=RGBA)
+ if(comp!=RED && comp!=RG && comp!=RGB && comp!=RGBA)
throw invalid_argument("RenderTargetformat::operator,");
if(size>3)
--size;
PixelFormat get_output_pixelformat(unsigned char o)
{
- unsigned size = ((o>>2)&3);
- PixelFormat base;
+ PixelComponents comp;
+ DataType type;
if(get_output_type(o)>=get_output_type(RENDER_DEPTH))
{
- base = DEPTH_COMPONENT;
- if(size)
- ++size;
+ static DataType types[4] = { UNSIGNED_SHORT, UNSIGNED_SHORT, UNSIGNED_INT, FLOAT };
+ comp = DEPTH_COMPONENT;
+ type = types[(o>>2)&3];
}
else
{
- static PixelFormat base_formats[4] = { RED, RG, RGB, RGBA };
- base = base_formats[o&3];
- if(size==3)
- ++size;
+ static PixelComponents components[4] = { RED, RG, RGB, RGBA };
+ static DataType types[4] = { UNSIGNED_BYTE, UNSIGNED_SHORT, HALF_FLOAT, FLOAT };
+ comp = components[o&3];
+ type = types[(o>>2)&3];
}
- if(size)
- return get_sized_pixelformat(base, size);
- else
- return base;
+ return make_pixelformat(comp, type);
}