예제 #1
0
// Loads a PCX file
bool CBitmap::loadPCX(const char *fileName)
{
	FILE *filePtr = fopen(fileName,"rb"); // Open the file
	BYTE *scanLine = NULL; // A pointer to contain a row of pixel data in the PCX

	SPCXHeader header = {0}; // Create a zeroed out SPCXHeader
	
	// We want to do robust error checking so we'll wrap the loading code in a 
	// try...catch block so we can deal with errors in only place
	try
	{
		// Error Check
		if(!filePtr)
			throw "Couldn't open .pcx file";
		
		// Read in the .pcx file header
		if(!fread(&header,sizeof(SPCXHeader),1,filePtr))
			throw "Couldn't read .pcx header";

		// Error Check -- manufacturer better equal 10 otherwise this 
		// for sure isn't a .pcx file
		if((int)header.manufacturer != 10)
			throw "Not a valid .pcx file";

		// Okay we have the header.  Let's determine the width, height, and number of channels
		// that are in the .pcx file.  Notice the +1 for width and height
		int width = header.xMax - header.xMin + 1;
		int height = header.yMax - header.yMin + 1; 
		int channels = header.planes;

		// Okay let's set the size of our CBitmap
		if(!setSize(width,height,channels))
			throw "Couldn't create bitmap for loading .pcx into";

		// Now we need to test to see if there is a palette
		// If the header version equals 5, there is a chance that there is a palette
		if((int)header.version == 5)
		{
			// Since it's a version 5 .pcx it's possible that it has a palette so
			// now we must test further
			
			BYTE test_byte; // byte to check to see if it's a 8-bit .pcx file

			// Seek to where the test byte is
			if(fseek(filePtr,-PCX_PALETTE_TEST,SEEK_END))
				throw "PCX file is corrupt";
			
			// Read in the test byte
			if(!fread(&test_byte,sizeof(BYTE),1,filePtr))
				throw "PCX file is corrupt";
			
			// Check the test byte -- If it EQUALS '12' we have a palette to read in
			if(test_byte == 12)
			{
				// Load the palette
				if(!loadPCXPalette(filePtr))
					throw "Couldn't load palette";
			}
		}
		
		// Next seek past the SPCXHeader
		if(fseek(filePtr,PCX_HEADER_SIZE,SEEK_SET))
			throw "PCX file is corrupt";		
		
		// The total number of bytes in a scanline
		int totalBytes = (int)header.planes * header.bytesPerLine;

		// Allocate the scanline
		scanLine = new BYTE[totalBytes];

		// Error Check
		if(scanLine == NULL)
			throw "Couldn't allocate memory";

		// Now loop over the entire .pcx file -- We'll fill each "scanLine" and then
		// convert that scanLine to our CBitmap depending on what type of .pcx we're dealing with
		for(int lineCount = 0; lineCount < height; lineCount++)
		{
			if(!readScanLine(filePtr, scanLine, totalBytes))
				throw "Error reading scanLine";

			// If it's an 8-bit .pcx file, simply copy over the scanline
			if((int)header.planes == 1) 
				memcpy(getLinePtr(lineCount),scanLine,getStride());

			else // Converge "scanLine" into the same form as a CBitmap 24-bit scanline
			{
				uchar *pixels = getLinePtr(lineCount);
				
				// Loop through the entire line of pixels.
				for(int i = 0; i < width; ++i)
				{
					/* 
						What does this mess do?  Well lets break down what each part is doing.
						
						i * header.planes - This puts "pixels" at the current pixel
						+ RED_BITMAP_OFFSET - Offset from the current pixel to the 'R' color component
						+ GREEN_BITMAP_OFFSET - Offset from the current pixel to the 'G' color component 
						+ BLUE_BITMAP_OFFSET - Offset from the current pixel to the 'B' color component
						
						PCX stores the scanline as a sequence of 'R', then a sequence of 'G', 
						then a sequence of 'B' so "i + header.bytesPerLine" moves to the sequence
						containing the 'G' components and "i + header.bytesPerLine * 2" moves to 
						the sequence containing the 'B' components
					*/				
					pixels[i * header.planes + RED_BITMAP_OFFSET] = scanLine[i];
					pixels[i * header.planes + GREEN_BITMAP_OFFSET] = scanLine[i + header.bytesPerLine];
					pixels[i * header.planes + BLUE_BITMAP_OFFSET] = scanLine[i + header.bytesPerLine * 2];
				}
			
			}  // end of if...else ((int)header.planes == 1)

		} // end of for(int lineCount = 0; lineCount < height; lineCount++)
	}
	catch (char *str) // If an error happened, catch it here and cleanup
	{
		MessageBox(NULL, str, "ERROR", MB_OK | MB_ICONERROR);
		
		if(filePtr)
			fclose(filePtr);
			
		if(scanLine)
			delete[] scanLine;
			
		return false;
	}

	delete[] scanLine; // Free mem
	fclose(filePtr); // Close the file
		return true; // PCX was successfully loaded
}
예제 #2
0
파일: Bias.cpp 프로젝트: apoma/plumed2
void Bias::apply(){
  if(onStep()) for(unsigned i=0;i<getNumberOfArguments();++i){
    getPntrToArgument(i)->addForce(getStride()*outputForces[i]);
  }
}
예제 #3
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                set             (const Vec2i& dstPos, const Image& src, const Vec2i& srcPos, const Vec2i& size)                 { FW_ASSERT(contains(dstPos, size) && src.contains(srcPos, size)); blit(getFormat(), getMutablePtr(dstPos), getStride(), src.getFormat(), src.getPtr(srcPos), src.getStride(), size); }
예제 #4
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                set             (const Image& src)                                                                              { blit(getFormat(), getMutablePtr(), getStride(), src.getFormat(), src.getPtr(), src.getStride(), Vec2i(min(getSize().x, src.getSize().x), min(getSize().y, src.getSize().y))); }
예제 #5
0
void GeoVectorProperty::activate(DrawEnv *pEnv, UInt32 slot)
{
    Window *pWin = pEnv->getWindow();

    bool isGeneric = (slot >= 16);  // !!!HACK. needs to be replaced for 2.0
    slot &= 15;

    bool hasVBO = pWin->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200);

    osgSinkUnusedWarning(pWin);

    if(hasVBO && isGeneric == true)
    {
        OSGGETGLFUNCBYID_GL3_ES( glVertexAttribPointer, 
                                 osgGlVertexAttribPointer,
                                _funcVertexAttribPointerARB,
                                 pWin);

        if(getGLId() != 0 && getUseVBO()) // Do we have a VBO?
        {
            pWin->validateGLObject(getGLId(), pEnv);
            
            OSGGETGLFUNCBYID_GL3_ES(  glBindBuffer, 
                                      osgGlBindBuffer,
                                     _funcBindBuffer, 
                                      pWin);
            
            osgGlBindBuffer(GL_ARRAY_BUFFER_ARB,
                            pWin->getGLObjectId(getGLId()));
            
            osgGlVertexAttribPointer(slot, 
                                     getDimension(),
                                     getFormat   (),
                                     getNormalize(),
                                     getStride   (), 
                                     0);
            
            osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
        }
        else
        {
            osgGlVertexAttribPointer(slot, 
                                     getDimension(),
                                     getFormat   (), 
                                     getNormalize(),
                                     getStride   (), 
                                     getData     ());
        }
        
        OSGGETGLFUNCBYID_GL3_ES( glEnableVertexAttribArray,
                                 osgGlEnableVertexAttribArray,
                                _funcEnableVertexAttribArrayARB,
                                 pWin);
        
        osgGlEnableVertexAttribArray(slot);
  
        OSGGETGLFUNCBYID_GL3_ES( glVertexAttribDivisor,
                                 osgGlVertexAttribDivisor,
                                _funcVertexAttribDivisorARB,
                                 pWin);
 
        osgGlVertexAttribDivisor(slot, _sfDivisor.getValue());
    }
    else 
    {        
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
        const void *pData = NULL;

        OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, 
                                 osgGlBindBuffer,
                                _funcBindBuffer, 
                                 pWin);

        hasVBO &= getUseVBO() && (getGLId() != 0);

        if(hasVBO == true) // Do we have a VBO?
        {
            pWin->validateGLObject(getGLId(), pEnv);                

            osgGlBindBuffer(GL_ARRAY_BUFFER_ARB,
                            pWin->getGLObjectId(getGLId()));
        }
        else
        {
            pData = getData();
        }
        
        switch(slot)
        {
            case 0:     
                glVertexPointer(getDimension(), 
                                getFormat   (),
                                getStride   (),
                                pData         );

                glEnableClientState(GL_VERTEX_ARRAY);
                break;

            case 2:     
                glNormalPointer(getFormat(),
                                getStride(),
                                pData      );

                glEnableClientState(GL_NORMAL_ARRAY);
                break;

            case 3:   
                glColorPointer(getDimension(), 
                               getFormat   (),
                               getStride   (), 
                               pData         );

                glEnableClientState(GL_COLOR_ARRAY);
                break;

            case 4:   
                if(pWin->hasExtOrVersion(_extSecondaryColor, 0x0104))
                {
                    OSGGETGLFUNCBYID_GL3( glSecondaryColorPointer,
                                          osgGlSecondaryColorPointer,
                                         _funcSecondaryColorPointer,
                                          pWin);

                    osgGlSecondaryColorPointer(getDimension(),
                                               getFormat   (),
                                               getStride   (), 
                                               pData         );

                    glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
                }
                else
                {
                    FWARNING(("GeoVectorProperty::activate: Window "
                              "has no Secondary Color extension\n"));
                }
                break;

            case 8:  
            case 9:
            case 10: 
            case 11:
            case 12: 
            case 13:
            case 14: 
            case 15:
            {
                if(pWin->hasExtOrVersion(_extMultitexture, 0x0103, 0x0200))
                {
                    OSGGETGLFUNCBYID_GL3_ES( glClientActiveTexture,
                                             osgGlClientActiveTexture,
                                            _funcClientActiveTextureARB,
                                             pWin);

                    osgGlClientActiveTexture(GL_TEXTURE0_ARB + slot - 8);

                    glTexCoordPointer(getDimension(),
                                      getFormat   (),
                                      getStride   (),
                                      pData         );

                    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
                }
                else if(slot == 8)
                {
                    glTexCoordPointer(getDimension(),
                                      getFormat   (),
                                      getStride   (),
                                      pData         );

                    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
                }
                else
                {
                    SWARNING << "GeoVectorProperty::activate: Window "
                             << "has no Multi Texture extension" << std::endl;
                }
            }
            break;

            default:    FWARNING(("GeoVectorProperty::activate: Non-Generic"
                                  " attribute nr. %d unknown!\n", slot));
                break;

        }
        if(hasVBO == true) // Do we have a VBO?
        {
            osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
        }
#endif
    }
}
예제 #6
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                write           (const ImageFormat& format, const void* ptr, S64 stride)                                        { blit(getFormat(), getMutablePtr(), getStride(), format, (const U8*)ptr, stride, getSize()); }
예제 #7
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                read            (const ImageFormat& format, void* ptr, S64 stride, const Vec2i& pos, const Vec2i& size) const   { FW_ASSERT(contains(pos, size)); blit(format, (U8*)ptr, stride, getFormat(), getPtr(pos), getStride(), size); }
예제 #8
0
	string PoolingLayer::convet2CaffeFormat()
	{
		string layerStrStart = "layer\n{\n";
		string layerStrEnd = "}";

		string nameStrStart = "\tname: \"";
		string nameStrEnd = "\"\n";

		string typeStrStart = "\ttype: \"";
		string typeStrEnd = "\"\n";

		string topStrStart = "\ttop: \"";
		string topStrEnd = "\"\n";

		string bottomStrStart = "\tbottom: \"";
		string bottomStrEnd = "\"\n";

		string poolingParamStrStart = "\tpooling_param\n\t{\n";
		string poolingParamStrEnd = "\t}\n";

		string kernelSizeStrStart = "\t\tkernel_size: ";
		string kernelSizeStrEnd = "\n";

		/*string kernelHStrStart = "\t\tkernel_h: ";
		string kernelHStrEnd = "\n";

		string kernelWStrStart = "\t\tkernel_w: ";
		string kernelWStrEnd = "\n";*/

		string strideStrStart = "\t\tstride: ";
		string strideStrEnd = "\n";
		/*string strideHStrStart = "\t\tstride_h: ";
		string strideHStrEnd = "\n";
		string strideWStrStart = "\t\tstride_w: ";
		string strideWStrEnd = "\n";*/

		string padStrStart = "\t\tpad: ";
		string padStrEnd = "\n";
		/*string padHStrStart = "\t\tpad_h: ";
		string padHStrEnd = "\n";
		string padWStrStart = "\t\tpad_w: ";
		string padWStrEnd = "\n";*/

		string poolStrStart = "\t\tpool: ";
		string poolStrEnd = "\n";

		string engineStrStart = "\t\tengine: ";
		string engineStrEnd = "\n";

		string globalPoolingStrStart = "\t\tglobal_pooling: ";
		string globalPoolingStrEnd = "\n";

		string phaseStrStart = "\tinclude:\n\t{\n";		
		string phaseStrEnd = "\t}\n";

		string phaseStateStrStart = "\t\tphase: ";
		string phaseStateStrEnd = "\n";

		string outStr = layerStrStart+
						nameStrStart + mName + nameStrEnd + 
						typeStrStart + getLayerType() + typeStrEnd;

		for(size_t i = 0; i < mTops->size(); i++)
		{
			outStr = outStr + topStrStart + (*mTops)[i] + topStrEnd;
		}

		for(size_t i = 0; i < mBottoms->size(); i++)
		{
			outStr = outStr + bottomStrStart + (*mBottoms)[i] + bottomStrEnd;
		}

		outStr += poolingParamStrStart;	



		if (((PoolingParam*)mParam)->mPool != MMALab::POOLMETHOD_MAX)

		{
			switch (((PoolingParam*)mParam)->mPool)
			{
			case MMALab::POOLMETHOD_AVE:
				outStr += poolStrStart + "AVE" + poolStrEnd;
				break;
			case MMALab::POOLMETHOD_STOCHASTIC:
				outStr += poolStrStart + "STOCHASTIC" + poolStrEnd;
				break;
			}
		}

		if (((PoolingParam*)mParam)->mPad != 0)
		{
			outStr += padStrStart + to_string(getPad()) + padStrEnd;
		}
		/*if (((PoolingParam*)mParam)->mPadH != 0)
		{
			outStr += padHStrStart + to_string(getPadH()) + padHStrEnd;
		}
		if (((PoolingParam*)mParam)->mPadW != 0)
		{
			outStr += padWStrStart + to_string(getPadW()) + padWStrEnd;
		}*/

		outStr += kernelSizeStrStart   + to_string(getKernelSize()) + kernelSizeStrEnd;
		/*outStr += kernelHStrStart   + to_string(getKernelH()) + kernelHStrEnd;
		outStr += kernelWStrStart   + to_string(getKernelW()) + kernelWStrEnd;*/

		if (((PoolingParam*)mParam)->mStride != 1)
		{
			outStr += strideStrStart + to_string(getStride()) + strideStrEnd;
		}
		/*if (((PoolingParam*)mParam)->mStrideH != 1)
		{
			outStr += strideHStrStart + to_string(getStrideH()) + strideHStrEnd;
		}
		if (((PoolingParam*)mParam)->mStrideW != 1)
		{
			outStr += strideWStrStart + to_string(getStrideW()) + strideWStrEnd;
		}*/

		if (((PoolingParam*)mParam)->mEngine != MMALab::DEFAULT)
		{
			switch (((PoolingParam*)mParam)->mEngine)
			{
			case MMALab::CAFFE:
				outStr += engineStrStart + "CAFFE" + engineStrEnd;
				break;

			case MMALab::CUDNN:
				outStr += engineStrStart + "CUDNN" + engineStrEnd;
				break;
			}
		}

		if (((PoolingParam*)mParam)->mGlobalPooling != false)
		{
			outStr += globalPoolingStrStart + "true" + globalPoolingStrEnd;
		}

		outStr += poolingParamStrEnd;		
				
		if (mPhase != Phase::BOTH)
		{
			outStr += phaseStrStart + phaseStateStrStart;

			if (mPhase == Phase::TRAIN)
			{
				outStr += "TRAIN";
			}
			else if (mPhase == Phase::TEST)
			{
				outStr += "TEST";
			}

			outStr += phaseStateStrEnd + phaseStrEnd;
		}
		
		outStr += layerStrEnd;

		return outStr;	
	}
예제 #9
0
void ManyRestraintsBase::apply() {
    plumed_dbg_assert( getNumberOfComponents()==1 );
    getPntrToComponent(0)->addForce( -1.0*getStride() );
}
예제 #10
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 S64                 getOffset       (const Vec2i& pos = 0) const        { FW_ASSERT(contains(pos, 0)); return m_offset + pos.x * getBPP() + pos.y * getStride(); }
예제 #11
0
파일: SImage.cpp 프로젝트: IjonTichy/SLADE
/* SImage::drawPixel
 * Draws a pixel of [colour] at [x],[y], blending it according to
 * the options set in [properties]. If the image is paletted, the
 * resulting pixel colour is converted to its nearest match in [pal]
 *******************************************************************/
bool SImage::drawPixel(int x, int y, rgba_t colour, si_drawprops_t& properties, Palette8bit* pal)
{
	// Check valid coords
	if (x < 0 || y < 0 || x >= width || y >= height)
		return false;

	// Get palette to use
	if (has_palette || !pal)
		pal = &palette;

	// Setup alpha
	if (properties.src_alpha)
		colour.a *= properties.alpha;
	else
		colour.a = 255*properties.alpha;

	// Do nothing if completely transparent
	if (colour.a == 0)
		return true;

	// Get pixel index
	unsigned p = y * getStride() + x * getBpp();

	// Check for simple case (normal blending, no transparency involved)
	if (colour.a == 255 && properties.blend == NORMAL)
	{
		if (type == RGBA)
			colour.write(data+p);
		else
		{
			data[p] = pal->nearestColour(colour);
			mask[p] = colour.a;
		}

		return true;
	}

	// Not-so-simple case, do full processing
	rgba_t d_colour;
	if (type == PALMASK)
		d_colour = pal->colour(data[p]);
	else
		d_colour.set(data[p], data[p+1], data[p+2], data[p+3]);

	// Additive blending
	if (properties.blend == ADD)
	{
		d_colour.set(	MathStuff::clamp(d_colour.r+colour.r*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.g+colour.g*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.b+colour.b*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.a + colour.a, 0, 255));
	}

	// Subtractive blending
	else if (properties.blend == SUBTRACT)
	{
		d_colour.set(	MathStuff::clamp(d_colour.r-colour.r*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.g-colour.g*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.b-colour.b*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.a + colour.a, 0, 255));
	}

	// Reverse-Subtractive blending
	else if (properties.blend == REVERSE_SUBTRACT)
	{
		d_colour.set(	MathStuff::clamp((-d_colour.r)+colour.r*properties.alpha, 0, 255),
		                MathStuff::clamp((-d_colour.g)+colour.g*properties.alpha, 0, 255),
		                MathStuff::clamp((-d_colour.b)+colour.b*properties.alpha, 0, 255),
		                MathStuff::clamp(d_colour.a + colour.a, 0, 255));
	}

	// 'Modulate' blending
	else if (properties.blend == MODULATE)
	{
		d_colour.set(	MathStuff::clamp(colour.r*d_colour.r / 255, 0, 255),
		                MathStuff::clamp(colour.g*d_colour.g / 255, 0, 255),
		                MathStuff::clamp(colour.b*d_colour.b / 255, 0, 255),
		                MathStuff::clamp(d_colour.a + colour.a, 0, 255));
	}

	// Normal blending (or unknown blend type)
	else
	{
		float inv_alpha = 1.0f - properties.alpha;
		d_colour.set(	d_colour.r*inv_alpha + colour.r*properties.alpha,
		                d_colour.g*inv_alpha + colour.g*properties.alpha,
		                d_colour.b*inv_alpha + colour.b*properties.alpha,
		                MathStuff::clamp(d_colour.a + colour.a, 0, 255));
	}

	// Apply new colour
	if (type == PALMASK)
	{
		data[p] = pal->nearestColour(d_colour);
		mask[p] = d_colour.a;
	}
	else if (type == RGBA)
		d_colour.write(data+p);
	else if (type == ALPHAMAP)
		data[p] = d_colour.a;

	return true;
}
예제 #12
0
template <class T, typename S> S ArrayBase<T,S>::getNumBytes(void) const
{
    return getSize() * getStride();
}
예제 #13
0
// virtual (default)
void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
{
	LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
	stop_glerror();
	volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;

	if ((data_mask & mTypeMask) != data_mask)
	{
		llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask. Missing: ";

		static const char* mask_names[] = {"VERTEX","NORMAL","TEXCOORD0","TEXCOORD1","TEXCOORD2","TEXCOORD3","COLOR","BINORMAL","WEIGHT","WEIGHT4","CLOTH_WEIGHT"};
		for(int i = 0; i < 32; ++i)
		{
			if((data_mask & (1<<i)) && !(mTypeMask & (1<<i)))
			{
				if(i < (sizeof(mask_names)/sizeof(mask_names[0])))
					llcont << "MAP_" << mask_names[i] << ", ";
				else
					llcont << "MAP_UNKNOWN (1<<" << i << "), ";
			}
		}
		llcont << "\n Has: ";
		for(int i = 0; i < 32; ++i)
		{
			if(mTypeMask & (1<<i))
			{
				if(i < (sizeof(mask_names)/sizeof(mask_names[0])))
					llcont << "MASK_" << mask_names[i] << ", ";
				else
					llcont << "MAP_UNKNOWN (1<<" << i << "), ";
			}
		}
		llcont << llendl;
	}

	if (data_mask & MAP_NORMAL)
	{
		glNormalPointer(GL_FLOAT, getStride(TYPE_NORMAL), (void*)(base + mOffsets[TYPE_NORMAL]));
	}
	if (data_mask & MAP_TEXCOORD3)
	{
		glClientActiveTextureARB(GL_TEXTURE3_ARB);
		glTexCoordPointer(2,GL_FLOAT, getStride(TYPE_TEXCOORD3), (void*)(base + mOffsets[TYPE_TEXCOORD3]));
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
	if (data_mask & MAP_TEXCOORD2)
	{
		glClientActiveTextureARB(GL_TEXTURE2_ARB);
		glTexCoordPointer(2,GL_FLOAT, getStride(TYPE_TEXCOORD2), (void*)(base + mOffsets[TYPE_TEXCOORD2]));
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
	if (data_mask & MAP_TEXCOORD1)
	{
		glClientActiveTextureARB(GL_TEXTURE1_ARB);
		glTexCoordPointer(2,GL_FLOAT, getStride(TYPE_TEXCOORD1), (void*)(base + mOffsets[TYPE_TEXCOORD1]));
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
	if (data_mask & MAP_BINORMAL)
	{
		glClientActiveTextureARB(GL_TEXTURE2_ARB);
		glTexCoordPointer(3,GL_FLOAT, getStride(TYPE_BINORMAL), (void*)(base + mOffsets[TYPE_BINORMAL]));
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
	if (data_mask & MAP_TEXCOORD0)
	{
		glTexCoordPointer(2,GL_FLOAT, getStride(TYPE_TEXCOORD0), (void*)(base + mOffsets[TYPE_TEXCOORD0]));
	}
	if (data_mask & MAP_COLOR)
	{
		glColorPointer(4, GL_UNSIGNED_BYTE, getStride(TYPE_COLOR), (void*)(base + mOffsets[TYPE_COLOR]));
	}
	
	if (data_mask & MAP_WEIGHT)
	{
		glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, getStride(TYPE_WEIGHT), (void*)(base + mOffsets[TYPE_WEIGHT]));
	}

	if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
	{
		glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, getStride(TYPE_WEIGHT4), (void*)(base+mOffsets[TYPE_WEIGHT4]));
	}

	if (data_mask & MAP_CLOTHWEIGHT)
	{
		glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE,  getStride(TYPE_CLOTHWEIGHT), (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
	}
	if (data_mask & MAP_VERTEX)
	{
		glVertexPointer(3,GL_FLOAT, getStride(TYPE_VERTEX), (void*)(base + 0));
	}

	llglassertok();
}
void GeoMultiProperty::activate(DrawEnv *pEnv, 
                                UInt32   slot )
{
    Window *win = pEnv->getWindow();
    bool isGeneric = (slot >= 16);  // !!!HACK. needs to be replaced for 2.0
    slot &= 15;
    
    if(!win->hasExtOrVersion(_extVertexBufferObject, 0x0105, 0x0200))
    {
        FWARNING(("GeoMultiProperty::activate: Window %p doesn't "
                  "support VBOs!\n", win));
                  return;
    }
    
    win->validateGLObject(getContainer()->getGLId(), pEnv);

     // get "glBindBufferARB" function pointer

    OSGGETGLFUNCBYID_GL3_ES( glBindBuffer, 
                             osgGlBindBuffer,
                            _funcBindBuffer, 
                             win);
   
    osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, 
                    win->getGLObjectId(getContainer()->getGLId()));

#define BUFFER_OFFSET(i)     (static_cast<char *>(NULL) + (i))

    if(isGeneric)
    {
        OSGGETGLFUNCBYID_GL3_ES( glVertexAttribPointer, 
                                 osgGlVertexAttribPointer,
                                _funcglVertexAttribPointerARB,
                                 win);

        osgGlVertexAttribPointer(slot, 
                                 getDimension(), 
                                 getFormat(), 
                                 getNormalize(),
                                 getStride(), 
                                 BUFFER_OFFSET(getOffset()));

        OSGGETGLFUNCBYID_GL3_ES( glEnableVertexAttribArray,
                                 osgGlEnableVertexAttribArray,
                                _funcglEnableVertexAttribArrayARB,
                                 win);
 
        osgGlEnableVertexAttribArray(slot);
    }
    else
    {
#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
        switch(slot)
        {
            case 0:     
                glVertexPointer(getDimension(), getFormat(),
                                getStride(), BUFFER_OFFSET(getOffset()));
                glEnableClientState(GL_VERTEX_ARRAY);
                break;
            case 2:     
                glNormalPointer(getFormat(),
                                getStride(), BUFFER_OFFSET(getOffset()));
                glEnableClientState(GL_NORMAL_ARRAY);
                break;
            case 3:     
                glColorPointer(getDimension(), getFormat(),
                               getStride(), BUFFER_OFFSET(getOffset()));
                glEnableClientState(GL_COLOR_ARRAY);
                break;
            case 4:     
                if (win->hasExtOrVersion(_extSecondaryColor, 0x0104))
                {
                    OSGGETGLFUNCBYID_EXT( glSecondaryColorPointer,
                                          osgGlSecondaryColorPointer,
                                         _funcglSecondaryColorPointer,
                                          win);

                    osgGlSecondaryColorPointer(getDimension(),
                                               getFormat(),
                                               getStride(), 
                                               BUFFER_OFFSET(getOffset()));

                    glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
                }
                else
                {
                    FWARNING(("GeoVectorProperty::activate: Window "
                              "has no Secondary Color extension\n"));
                }
                break;
            case 8:  case 9: 
            case 10: case 11: 
            case 12: case 13: 
            case 14: case 15: 
            {
                OSGGETGLFUNCBYID_GL3_ES( glClientActiveTexture,
                                         osgGlClientActiveTexture,
                                        _funcglClientActiveTextureARB,
                                         win);

                osgGlClientActiveTexture(GL_TEXTURE0_ARB + slot - 8);

                glTexCoordPointer(getDimension(), 
                                  getFormat(),
                                  getStride(), 
                                  BUFFER_OFFSET(getOffset()));

                glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            }
            break;
            default:    FWARNING(("GeoVectorProperty::activate: Non-Generic"
                                  " attribute nr. %d unknown!\n", slot));
                break;
        }     
#endif
    } // isGeneric

    osgGlBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
}
예제 #15
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                read            (const ImageFormat& format, void* ptr, S64 stride) const                                        { blit(format, (U8*)ptr, stride, getFormat(), getPtr(), getStride(), getSize()); }
void
GeoMultiProperty::getGenericValue(MaxTypeT &eval, const SizeT index ) const
{
          UInt16  dim    = getDimension();
          bool    norm   = getNormalize();
          UInt32  stride = getStride() ? getStride() : getFormatSize() * dim;
    const UInt8  *data   = getData() + stride * index;

#define getValNormCase(vectype)                                 \
{                                                               \
vectype ival(vectype::Null);                                    \
for (UInt16 i = 0; i < dim; ++i)                                \
    ival[i] =                                                   \
        reinterpret_cast<const vectype::ValueType*>(data)[i];   \
                                                                \
if(norm)                                                        \
{                                                               \
    GeoConvertNormalize::convertOut(eval, ival,              \
        TypeTraits<vectype::ValueType>::getMax(), 0);           \
}                                                               \
else                                                            \
{                                                               \
    GeoConvert::convertOut(eval, ival);                      \
}                                                               \
}

#define getValCase(vectype)                                     \
{                                                               \
vectype ival(vectype::Null);                                    \
for (UInt16 i = 0; i < dim; ++i)                                \
    ival[i] =                                                   \
        reinterpret_cast<const vectype::ValueType*>(data)[i];   \
                                                                \
GeoConvert::convertOut(eval, ival);                          \
}
    switch(getFormat())
    {
        case GL_BYTE:                   getValNormCase(Vec4b );
            break;
        case GL_UNSIGNED_BYTE:          getValNormCase(Vec4ub);
            break;
        case GL_SHORT:                  getValNormCase(Vec4s );
            break;
        case GL_UNSIGNED_SHORT:         getValNormCase(Vec4us);
            break;
/*    case GL_INT:                    getValNormCase(Vec4i );
                                    break;
    case GL_UNSIGNED_INT:           getValNormCase(Vec4ui);
                                    break;
 */    
        case GL_FLOAT:                  getValCase    (Vec4f );
            break;
#ifndef OSG_OGL_NO_DOUBLE
        case GL_DOUBLE:                 getValCase    (Vec4d );
            break;
#endif
    }

#undef getValNormCase
#undef getValCase
}
예제 #17
0
파일: Image.hpp 프로젝트: jtyot/morse-pc
 void                write           (const ImageFormat& format, const void* ptr, S64 stride, const Vec2i& pos, const Vec2i& size)   { FW_ASSERT(contains(pos, size)); blit(getFormat(), getMutablePtr(pos), getStride(), format, (const U8*)ptr, stride, size); }
예제 #18
0
off_t Spectrogram::lineToSample(int line) {
	return line * getStride();
}
예제 #19
0
void GridPrintingBase::runFinalJobs(){
  if( getStride()>0 ) return;

  OFile ofile; ofile.link(*this);
  ofile.open( filename ); printGrid( ofile ); ofile.close();
}