Changeset 13204

Show
Ignore:
Timestamp:
04/23/14 21:30:33 (8 hours ago)
Author:
robert
Message:

Added src/osg/OpenGL.in configuration file and include/osg/OpenGL header files

Location:
OpenSceneGraph/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp

    r12835 r13204  
    116116} 
    117117 
    118 struct ModulateAlphaByLuminanceOperator 
    119 { 
    120     ModulateAlphaByLuminanceOperator() {} 
    121  
    122     inline void luminance(float&) const {} 
    123     inline void alpha(float&) const {} 
    124     inline void luminance_alpha(float& l,float& a) const { a*= l; } 
    125     inline void rgb(float&,float&,float&) const {} 
    126     inline void rgba(float& r,float& g,float& b,float& a) const { float l = (r+g+b)*0.3333333; a *= l;} 
    127 }; 
    128  
    129  
    130118struct ScaleOperator 
    131119{ 
     
    309297 
    310298 
    311 } 
    312  
    313 enum ColourSpaceOperation 
    314 { 
    315     NO_COLOUR_SPACE_OPERATION, 
    316     MODULATE_ALPHA_BY_LUMINANCE, 
    317     MODULATE_ALPHA_BY_COLOUR, 
    318     REPLACE_ALPHA_WITH_LUMINANCE, 
    319     REPLACE_RGB_WITH_LUMINANCE 
    320 }; 
    321  
    322 struct ModulateAlphaByColourOperator 
    323 { 
    324     ModulateAlphaByColourOperator(const osg::Vec4& colour):_colour(colour) { _lum = _colour.length(); } 
    325  
    326     osg::Vec4 _colour; 
    327     float _lum; 
    328  
    329     inline void luminance(float&) const {} 
    330     inline void alpha(float&) const {} 
    331     inline void luminance_alpha(float& l,float& a) const { a*= l*_lum; } 
    332     inline void rgb(float&,float&,float&) const {} 
    333     inline void rgba(float& r,float& g,float& b,float& a) const { a = (r*_colour.r()+g*_colour.g()+b*_colour.b()+a*_colour.a()); } 
    334 }; 
    335  
    336 struct ReplaceAlphaWithLuminanceOperator 
    337 { 
    338     ReplaceAlphaWithLuminanceOperator() {} 
    339  
    340     inline void luminance(float&) const {} 
    341     inline void alpha(float&) const {} 
    342     inline void luminance_alpha(float& l,float& a) const { a= l; } 
    343     inline void rgb(float&,float&,float&) const { } 
    344     inline void rgba(float& r,float& g,float& b,float& a) const { float l = (r+g+b)*0.3333333; a = l; } 
    345 }; 
    346  
    347 osg::Image* doColourSpaceConversion(ColourSpaceOperation op, osg::Image* image, osg::Vec4& colour) 
    348 { 
    349     switch(op) 
    350     { 
    351         case (MODULATE_ALPHA_BY_LUMINANCE): 
    352         { 
    353             std::cout<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl; 
    354             osg::modifyImage(image,ModulateAlphaByLuminanceOperator()); 
    355             return image; 
    356         } 
    357         case (MODULATE_ALPHA_BY_COLOUR): 
    358         { 
    359             std::cout<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl; 
    360             osg::modifyImage(image,ModulateAlphaByColourOperator(colour)); 
    361             return image; 
    362         } 
    363         case (REPLACE_ALPHA_WITH_LUMINANCE): 
    364         { 
    365             std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
    366             osg::modifyImage(image,ReplaceAlphaWithLuminanceOperator()); 
    367             return image; 
    368         } 
    369         case (REPLACE_RGB_WITH_LUMINANCE): 
    370         { 
    371             std::cout<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
    372             osg::Image* newImage = new osg::Image; 
    373             newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType()); 
    374             osg::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(), 
    375                         newImage, 0, 0, 0, false); 
    376             return newImage; 
    377         } 
    378         default: 
    379             return image; 
    380     } 
    381299} 
    382300 
     
    672590 
    673591    // set up colour space operation. 
    674     ColourSpaceOperation colourSpaceOperation = NO_COLOUR_SPACE_OPERATION; 
     592    osg::ColorSpaceOperation colourSpaceOperation = osg::NO_COLOUR_SPACE_OPERATION; 
    675593    osg::Vec4 colourModulate(0.25f,0.25f,0.25f,0.25f); 
    676     while(arguments.read("--modulate-alpha-by-luminance")) { colourSpaceOperation = MODULATE_ALPHA_BY_LUMINANCE; } 
    677     while(arguments.read("--modulate-alpha-by-colour", colourModulate.x(),colourModulate.y(),colourModulate.z(),colourModulate.w() )) { colourSpaceOperation = MODULATE_ALPHA_BY_COLOUR; } 
    678     while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = REPLACE_ALPHA_WITH_LUMINANCE; } 
    679     while(arguments.read("--replace-rgb-with-luminance")) { colourSpaceOperation = REPLACE_RGB_WITH_LUMINANCE; } 
     594    while(arguments.read("--modulate-alpha-by-luminance")) { colourSpaceOperation = osg::MODULATE_ALPHA_BY_LUMINANCE; } 
     595    while(arguments.read("--modulate-alpha-by-colour", colourModulate.x(),colourModulate.y(),colourModulate.z(),colourModulate.w() )) { colourSpaceOperation = osg::MODULATE_ALPHA_BY_COLOUR; } 
     596    while(arguments.read("--replace-alpha-with-luminance")) { colourSpaceOperation = osg::REPLACE_ALPHA_WITH_LUMINANCE; } 
     597    while(arguments.read("--replace-rgb-with-luminance")) { colourSpaceOperation = osg::REPLACE_RGB_WITH_LUMINANCE; } 
    680598 
    681599 
     
    1019937 
    1020938 
    1021     if (colourSpaceOperation!=NO_COLOUR_SPACE_OPERATION) 
     939    if (colourSpaceOperation!=osg::NO_COLOUR_SPACE_OPERATION) 
    1022940    { 
    1023941        for(Images::iterator itr = images.begin(); 
     
    1025943            ++itr) 
    1026944        { 
    1027             (*itr) = doColourSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
     945            (*itr) = osg::colorSpaceConversion(colourSpaceOperation, itr->get(), colourModulate); 
    1028946        } 
    1029947    } 
  • OpenSceneGraph/trunk/include/osg/Image

    r13155 r13204  
    180180        virtual void readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type = GL_UNSIGNED_BYTE, unsigned int face = 0); 
    181181 
     182        /** swap the data and settings between two image objects.*/ 
     183        void swap(osg::Image& rhs); 
    182184 
    183185        /** Scale image to specified size. */ 
     
    472474        WriteHint   _writeHint; 
    473475 
    474  
    475476        Origin _origin; 
    476477 
  • OpenSceneGraph/trunk/include/osg/ImageUtils

    r13041 r13204  
    154154            bool resizeToPowerOfTwo = false); 
    155155 
     156 
     157 
     158 
    156159/** create a 2D osg::Image that provides a point at the center of the image. 
    157160 *  The colour across th image is computed from a balance between the center color and the background color controlled by the power of the radius from the center.*/ 
    158161extern OSG_EXPORT osg::Image* createSpotLightImage(const osg::Vec4& centerColour, const osg::Vec4& backgroudColour, unsigned int size, float power); 
     162 
     163 
     164enum ColorSpaceOperation 
     165{ 
     166    NO_COLOUR_SPACE_OPERATION, 
     167    MODULATE_ALPHA_BY_LUMINANCE, 
     168    MODULATE_ALPHA_BY_COLOUR, 
     169    REPLACE_ALPHA_WITH_LUMINANCE, 
     170    REPLACE_RGB_WITH_LUMINANCE 
     171}; 
     172 
     173/** Convert the RGBA values in a Image based on a ColorSpaceOperation defined scheme.*/ 
     174extern osg::Image* colorSpaceConversion(ColorSpaceOperation op, osg::Image* image, const osg::Vec4& colour); 
     175 
    159176 
    160177} 
  • OpenSceneGraph/trunk/include/osgPresentation/SlideShowConstructor

    r13197 r13204  
    1616#include <osg/Vec3> 
    1717#include <osg/Vec4> 
     18#include <osg/ImageUtils> 
    1819#include <osg/Group> 
    1920#include <osg/ClearNode> 
     
    292293            cutoffValue(0.1), 
    293294            sampleDensityValue(0.005), 
    294             sampleDensityWhenMovingValue(0.0) 
     295            sampleDensityWhenMovingValue(0.0), 
     296            colorSpaceOperation(osg::NO_COLOUR_SPACE_OPERATION), 
     297            colorModulate(1.0f,1.0f,1.0f,1.0f) 
    295298        { 
    296299            region[0] = region[1] = region[2] = 0.0f; 
     
    309312        float                                   sampleDensityValue; 
    310313        float                                   sampleDensityWhenMovingValue; 
     314 
     315        osg::ColorSpaceOperation                colorSpaceOperation; 
     316        osg::Vec4                               colorModulate; 
    311317    }; 
    312318 
  • OpenSceneGraph/trunk/src/osg/Image.cpp

    r13155 r13204  
    11841184} 
    11851185 
     1186void Image::swap(osg::Image& rhs) 
     1187{ 
     1188    std::swap(_fileName, rhs._fileName); 
     1189    std::swap(_writeHint, rhs._writeHint); 
     1190 
     1191    std::swap(_origin, rhs._origin); 
     1192 
     1193    std::swap(_s, rhs._s); std::swap(_t, rhs._t); std::swap(_r, rhs._r); 
     1194    std::swap(_rowLength, rhs._rowLength); 
     1195    std::swap(_internalTextureFormat, rhs._internalTextureFormat); 
     1196    std::swap(_pixelFormat, rhs._pixelFormat); 
     1197    std::swap(_dataType, rhs._dataType); 
     1198    std::swap(_packing, rhs._packing); 
     1199    std::swap(_pixelAspectRatio, rhs._pixelAspectRatio); 
     1200 
     1201    std::swap(_allocationMode, rhs._allocationMode); 
     1202    std::swap(_data, rhs._data); 
     1203 
     1204    std::swap(_mipmapData, rhs._mipmapData); 
     1205 
     1206    std::swap(_bufferObject, rhs._bufferObject); 
     1207 
     1208    std::swap(_dimensionsChangedCallbacks, rhs._dimensionsChangedCallbacks); 
     1209} 
     1210 
     1211 
    11861212void Image::scaleImage(int s,int t,int r, GLenum newDataType) 
    11871213{ 
  • OpenSceneGraph/trunk/src/osg/ImageUtils.cpp

    r13041 r13204  
    616616 
    617617 
    618 } 
    619  
     618struct ModulateAlphaByColourOperator 
     619{ 
     620    ModulateAlphaByColourOperator(const osg::Vec4& colour):_colour(colour) { _lum = _colour.length(); } 
     621 
     622    osg::Vec4 _colour; 
     623    float _lum; 
     624 
     625    inline void luminance(float&) const {} 
     626    inline void alpha(float&) const {} 
     627    inline void luminance_alpha(float& l,float& a) const { a*= l*_lum; } 
     628    inline void rgb(float&,float&,float&) const {} 
     629    inline void rgba(float& r,float& g,float& b,float& a) const { a = (r*_colour.r()+g*_colour.g()+b*_colour.b()+a*_colour.a()); } 
     630}; 
     631 
     632struct ReplaceAlphaWithLuminanceOperator 
     633{ 
     634    ReplaceAlphaWithLuminanceOperator() {} 
     635 
     636    inline void luminance(float&) const {} 
     637    inline void alpha(float&) const {} 
     638    inline void luminance_alpha(float& l,float& a) const { a= l; } 
     639    inline void rgb(float&,float&,float&) const { } 
     640    inline void rgba(float& r,float& g,float& b,float& a) const { float l = (r+g+b)*0.3333333; a = l; } 
     641}; 
     642 
     643osg::Image* colorSpaceConversion(ColorSpaceOperation op, osg::Image* image, const osg::Vec4& colour) 
     644{ 
     645    switch(op) 
     646    { 
     647        case (MODULATE_ALPHA_BY_LUMINANCE): 
     648        { 
     649            OSG_NOTICE<<"doing conversion MODULATE_ALPHA_BY_LUMINANCE"<<std::endl; 
     650            osg::modifyImage(image, ModulateAlphaByLuminanceOperator()); 
     651            return image; 
     652        } 
     653        case (MODULATE_ALPHA_BY_COLOUR): 
     654        { 
     655            OSG_NOTICE<<"doing conversion MODULATE_ALPHA_BY_COLOUR"<<std::endl; 
     656            osg::modifyImage(image, ModulateAlphaByColourOperator(colour)); 
     657            return image; 
     658        } 
     659        case (REPLACE_ALPHA_WITH_LUMINANCE): 
     660        { 
     661            OSG_NOTICE<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
     662            osg::modifyImage(image, ReplaceAlphaWithLuminanceOperator()); 
     663            return image; 
     664        } 
     665        case (REPLACE_RGB_WITH_LUMINANCE): 
     666        { 
     667            OSG_NOTICE<<"doing conversion REPLACE_ALPHA_WITH_LUMINANCE"<<std::endl; 
     668            osg::Image* newImage = new osg::Image; 
     669            newImage->allocateImage(image->s(), image->t(), image->r(), GL_LUMINANCE, image->getDataType()); 
     670            osg::copyImage(image, 0, 0, 0, image->s(), image->t(), image->r(), 
     671                        newImage, 0, 0, 0, false); 
     672            return newImage; 
     673        } 
     674        default: 
     675            return image; 
     676    } 
     677} 
     678 
     679 
     680 
     681} 
     682 
  • OpenSceneGraph/trunk/src/osgPlugins/p3d/ReaderWriterP3D.cpp

    r13197 r13204  
    10981098    if (getProperty(cur, "sampleDensity", volumeData.sampleDensityValue)) {} 
    10991099    if (getProperty(cur, "sampleDensityWhenMoving", volumeData.sampleDensityWhenMovingValue)) {} 
     1100 
     1101 
     1102    if (getProperty(cur, "colourModulate", volumeData.colorModulate)) {} 
     1103    if (getProperty(cur, "colorModulate", volumeData.colorModulate)) {} 
     1104 
     1105    std::string operation; 
     1106    if (getProperty(cur, "colorSpaceOperation", operation) || getProperty(cur, "colourSpaceOperation", operation)) 
     1107    { 
     1108        osg::ColorSpaceOperation colorOp = osg::NO_COLOUR_SPACE_OPERATION; 
     1109        if (operation=="NO_COLOUR_SPACE_OPERATION") volumeData.colorSpaceOperation = osg::NO_COLOUR_SPACE_OPERATION; 
     1110        else if (operation=="MODULATE_ALPHA_BY_LUMINANCE") volumeData.colorSpaceOperation = osg::MODULATE_ALPHA_BY_LUMINANCE; 
     1111        else if (operation=="MODULATE_ALPHA_BY_COLOUR") volumeData.colorSpaceOperation = osg::MODULATE_ALPHA_BY_COLOUR; 
     1112        else if (operation=="REPLACE_ALPHA_WITH_LUMINANCE") volumeData.colorSpaceOperation = osg::REPLACE_ALPHA_WITH_LUMINANCE; 
     1113        else if (operation=="REPLACE_RGB_WITH_LUMINANCE") volumeData.colorSpaceOperation = osg::REPLACE_RGB_WITH_LUMINANCE; 
     1114    } 
     1115     
     1116     
    11001117 
    11011118    // check for any transfer function required 
  • OpenSceneGraph/trunk/src/osgPresentation/SlideShowConstructor.cpp

    r13201 r13204  
    20822082    if (!image && !volume) return; 
    20832083 
     2084 
     2085    if (volumeData.colorSpaceOperation!=osg::NO_COLOUR_SPACE_OPERATION) 
     2086    { 
     2087        OSG_NOTICE<<"Doing colour space conversion"<<std::endl; 
     2088        osg::ref_ptr<osg::Image> converted_image = osg::colorSpaceConversion(volumeData.colorSpaceOperation, image.get(), volumeData.colorModulate); 
     2089        if (converted_image!=image) 
     2090        { 
     2091            image->swap(*converted_image); 
     2092        } 
     2093    } 
     2094     
    20842095    if (positionData.scale.x()<0.0) 
    20852096    {