]> git.tdb.fi Git - libs/gl.git/blobdiff - source/rendertarget.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / rendertarget.cpp
index 74b4f32214e0bfe33ca54935b45d6d749a628de7..1349944b862ff969f6347d5ca070696bb597f09b 100644 (file)
@@ -34,19 +34,21 @@ RenderTargetFormat RenderTargetFormat::operator,(PixelFormat f) const
        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;
@@ -72,26 +74,23 @@ int RenderTargetFormat::index(RenderOutput o) const
 
 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);
 }