void teRenderGL::End() { #ifdef TE_DEBUG switch(glGetError()) { case GL_NO_ERROR: break; case GL_INVALID_ENUM: TE_LOG_ERR("OpenGL Error : Invalid enum"); break; case GL_INVALID_VALUE: TE_LOG_ERR("OpenGL Error : Invalid value"); break; case GL_INVALID_OPERATION: TE_LOG_ERR("OpenGL Error : Invalid operation"); break; case GL_OUT_OF_MEMORY: TE_LOG_ERR("OpenGL Error : Out of memory"); break; #if defined(TE_OPENGL_ES_11) || defined(TE_OPENGL_15) case GL_STACK_OVERFLOW: TE_LOG_ERR("OpenGL Error : Stack overflow"); break; case GL_STACK_UNDERFLOW: TE_LOG_ERR("OpenGL Error : Stack underflow"); break; #endif default: TE_LOG_ERR("OpenGL Error : Unknown error") break; } #endif #if defined (TE_PLATFORM_IPHONE) const GLenum discards[] = {GL_DEPTH_ATTACHMENT}; te::app::GetApplicationManager()->GetFrameBuffer()->Bind(); glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards); #else glFlush(); glFinish(); #endif if(CurrentContext) CurrentContext->PresentCurrentTexture(); }
void teShader::LogErrors(const c8 * stageName, GLuint shader, GLuint program) { #ifdef TE_DEBUG GLint logLength = 0; GLint status = 0; if(shader) { tglGetShaderiv(shader, GL_COMPILE_STATUS, &status); tglGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); } else if(program) { tglGetProgramiv(program, GL_LINK_STATUS, &status); tglGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); } if(status) return; if(logLength > 0) { GLchar * log = (GLchar*)TE_ALLOCATE(logLength); if(shader) tglGetShaderInfoLog(shader, logLength, &logLength, log); else if(program) tglGetProgramInfoLog(program, logLength, &logLength, log); if(logLength > 0) { TE_LOG_ERR("shader stage %s error : %s", stageName, log); } TE_FREE(log); } #endif }
void teDecodeFile(const teString & from, const teString & to, u32 chunkSize, c8 * chunkInputBuffer, u32 chunkInputBufferSize, c8 * chunkOutputBuffer, u32 chunkOutputBufferSize, u1 localPath) { TE_ASSERT(chunkInputBufferSize >= LZ4_compressBound(chunkSize)); TE_ASSERT(chunkOutputBufferSize >= chunkSize); IBuffer * fileInput = GetFileManager()->OpenFile(from, CFileBuffer::FWM_READ, localPath); if(!fileInput) return; IBuffer * fileOutput = GetFileManager()->OpenFile(to, CFileBuffer::FWM_WRITE, localPath); if(!fileOutput) { TE_SAFE_DROP(fileInput); return; } fileInput->SetStreamMode(true); fileOutput->SetStreamMode(true); fileInput->Lock(BLT_READ); fileInput->SetPosition(0); u32 magicNumber = u32Max; fileInput->Read(&magicNumber, ARCHIVE_MAGICNUMBER_SIZE); TE_ASSERT(magicNumber == ARCHIVE_MAGICNUMBER); fileOutput->Lock(BLT_WRITE); fileOutput->SetPosition(0); c8 * inBuffer = chunkInputBuffer; c8 * outBuffer = chunkOutputBuffer; while(true) { if((fileInput->GetSize() - fileInput->GetPosition()) < ARCHIVE_MAGICNUMBER_SIZE) break; u32 chunkSizeInFile; fileInput->Read(&chunkSizeInFile, sizeof(u32)); if(chunkSizeInFile == ARCHIVE_MAGICNUMBER) continue; fileInput->Read(inBuffer, chunkSizeInFile); s32 outputSize = LZ4_uncompress_unknownOutputSize(inBuffer, outBuffer, chunkSizeInFile, chunkSize); if(outputSize < 0) { TE_LOG_ERR("lz4 decoding failed, corrupted input\n"); fileInput->Unlock(); fileOutput->Unlock(); TE_SAFE_DROP(fileInput); TE_SAFE_DROP(fileOutput); return; } fileOutput->Write(outBuffer, (u32)outputSize); } fileInput->Unlock(); fileOutput->Unlock(); TE_SAFE_DROP(fileInput); TE_SAFE_DROP(fileOutput); }