本文整理汇总了C++中FileReader::ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::ReadBytes方法的具体用法?C++ FileReader::ReadBytes怎么用?C++ FileReader::ReadBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::ReadBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadTexture
void Texture::LoadTexture(const char* path)
{
FileReader *FR = new FileReader(path);
unsigned char*buffer = (unsigned char*)malloc(sizeof(unsigned char)*4);
//move to position 12, next 4 bytes are size
//
FR->FileSeek(12,0);
FR->ReadBytes(4,buffer);
int sizex= buffer[0]+buffer[1]*256;
int sizey= buffer[2]+buffer[3]*256;
free(buffer);
buffer = (unsigned char*)malloc(sizeof(unsigned char)*1);
FR->FileSeek(16,0);
FR->ReadBytes(1,buffer);
int bpp = buffer[0];
free(buffer);
int datasize = sizex*sizey*bpp/8;
m_pixels = (unsigned char*)malloc(sizeof(unsigned char)*datasize);
unsigned char *Buffer = (unsigned char*)malloc(sizeof(unsigned char)*datasize);
FR->FileSeek(18,0);
FR->ReadBytes(datasize,Buffer);
for(int i = 0;i<datasize;i+=4)
{
m_pixels[i+0] = Buffer[i+2];
m_pixels[i+1] = Buffer[i+1];
m_pixels[i+2] = Buffer[i+0];
m_pixels[i+3] = Buffer[i+3];
}
delete FR;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
debug::checkGlError("glPixel");
glGenTextures(1,&m_textureID);
debug::checkGlError("glGentextures");
glActiveTexture(GL_TEXTURE0);
debug::checkGlError("glActivetexture");
// Bind the texture object
glBindTexture(GL_TEXTURE_2D, m_textureID);
debug::checkGlError("Bindtexture");
// Load the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sizex, sizey, 0, GL_RGBA,
GL_UNSIGNED_BYTE, m_pixels);
debug::checkGlError("textimage2D");
// Set the filtering mode
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
debug::checkGlError("textparameteri");
LOGI("asd!4");
}
示例2: OpenFile
void ObjLoader::OpenFile(const char* path)
{
FileReader* FR = new FileReader(path);
lenght = FR->FileLength();
buff = (char*) malloc(lenght+1);
FR->ReadBytes(lenght, buff);
delete FR;
}
示例3: ReadCheckFile
void SPAuthCheckPrv::ReadCheckFile()
{
// Read check prevention file
mGameSecondsBeforeNextCheck = 1; // default -> check
try
{
FileReader aReader;
if(!aReader.Open(gSPAuthCheck_FileName))
return;
unsigned short aNumBytes = aReader.ReadShort();
if(aNumBytes==0 || aReader.Available()<aNumBytes)
return;
char *aBuf = new char[aNumBytes];
std::auto_ptr<char> aDelBuf(aBuf);
aReader.ReadBytes(aBuf,aNumBytes);
aReader.Close();
ByteBufferPtr aDecrypt = mEncryptKey.Decrypt(aBuf,aNumBytes);
if(aDecrypt.get()==NULL)
return;
WONFile aFile(gSPAuthCheck_FileName);
ReadBuffer aReadBuf(aDecrypt->data(),aDecrypt->length());
std::string aSig;
aReadBuf.ReadString(aSig);
if(aSig!="magic")
return;
time_t aCreateTime = aFile.GetCreateTime();
time_t aCompareCreateTime = aReadBuf.ReadLong();
if(aCompareCreateTime != aCreateTime)
return;
mGameSecondsBeforeNextCheck = aReadBuf.ReadLong();
if(mGameSecondsBeforeNextCheck==0) // don't remove file in this case
return;
aFile.Remove();
}
catch(FileReaderException&)
{
}
catch(ReadBufferException&)
{
}
}
示例4: ReadShaderFile
GLuint Shader::ReadShaderFile(const char* path, GLenum type)
{
long lenght;
char *buffer;
FileReader *FR = new FileReader(path);
lenght = FR->FileLength();
buffer = (char*) malloc(lenght+1);
FR->ReadBytes(lenght, buffer);
delete FR;
buffer[lenght] = 0;
#ifndef WINDOWS_FRAMEWORK
LOGE("%lu", lenght);
#endif
GLuint shader = LoadShader(type,buffer);
return shader;
}