void display(const Image& image) { wclear(mainwin); int nwidth = getmaxx(mainwin); int nheight = getmaxy(mainwin); double xmin = -image.width; double xmax = image.width; double ymin = -image.height; double ymax = image.height; auto end = image.getPoints().end(); for (auto it = image.getPoints().begin(); it != end; ++it) { int x = (int) ((it->second.x - xmin) / (xmax-xmin) * nwidth ); int y = (int) ((it->second.y - ymin) / (ymax-ymin) * nheight); #if DEBUG getLog() << "About to draw " << it->second.x << ", " << it->second.y << std::endl; getLog() << "This goes at " << x << "; " << nwidth << ", " << y << "/" << nheight << std::endl; // getLog() << x << ", " << y << std::endl; // getLog() << "curses bounds: " << nwidth << ", " << nheight << std::endl; #endif if (x < 0 || y < 0 || x >= nwidth || y >= nheight) { getLog() << "We have a really bad X or Y" << std::endl; return; } mvaddstr(y, x, "."); } refresh(); }
bool CDexModelXAni::LoadModelFile(const char* filename) { HRESULT hr; int64 mseconds = getTime()->GetTotalMillSeconds(); //从.X文件加载层次框架和动画数据 hr = D3DXLoadMeshHierarchyFromX(filename, D3DXMESH_MANAGED, DexGameEngine::getEngine()->GetDevice(), m_pAlloc, NULL, &m_pFrameRoot, &m_pAnimController); //最后一个参数:动画控制器 if (FAILED(hr)) return false; //建立各级框架的组合变换矩阵 SetupBoneMatrixPointers(m_pFrameRoot); int index = 4; if(m_pAnimController != NULL) { m_pAnimController->GetAnimationSet(index, &m_pAnimationSet1); m_pAnimController->SetTrackAnimationSet(0, m_pAnimationSet1); m_pAnimController->ResetTime(); } getLog()->BeginLog(); getLog()->Log(log_ok, "加载animation模型%s成功!用时:%d ms\n",filename, getTime()->GetTotalMillSeconds() - mseconds); getLog()->EndLog(); return true; }
void ArtDirectorClient::connectToServer() { if(!_socket->isOpen()) { QHostAddress address(_serverIpAddress.c_str()); _socket->connectToHost(address, _serverTcpPort); if(!_socket->waitForConnected()) { getLog().postMessage(new Message('E', false, "Could not reach the server " + toString(address.toString(), _serverTcpPort), "ArtDirectorClient")); getLog().postMessage(new Message('E', false, _socket->errorString().toStdString(), "ArtDirectorClient")); _socket->close(); } } else { getLog().postMessage(new Message('W', false, "A connection is already established with the server", "ArtDirectorClient")); } }
void write_log(const char *fmt, ...) { FILE* fp = getLog()->getFP(); char* buf = getLog()->getBuf(); fprintf(fp, "%s", buf); va_list ap; va_start(ap, fmt); vfprintf(fp, fmt, ap); va_end (ap); fprintf(fp, "\n"); fflush(fp); }
GLvoid Shader::compileShaders(const GLchar *pVertexFilePath, const GLchar *pFragmentFilePath) { iVertexShaderHandle = loadShader(GL_VERTEX_SHADER, pVertexFilePath); assert(iVertexShaderHandle != -1); iFragmentShaderHandle = loadShader(GL_FRAGMENT_SHADER, pFragmentFilePath); if (iFragmentShaderHandle == -1) { glDeleteShader(iVertexShaderHandle); bCompiled = GL_FALSE; return ; } /*if (iVertexShaderHandle ==-1 || iFragmentShaderHandle==-1) { bCompiled=GL_FALSE; return ; }*/ char const* vertexSourcePointer = sVertexShaderCode.c_str(); glShaderSource(iVertexShaderHandle, 1, &vertexSourcePointer, NULL); glCompileShader(iVertexShaderHandle); GLint errorVertex = getLog(iVertexShaderHandle); char const* fragmentSourcePointer = sFragmentShaderCode.c_str(); glShaderSource(iFragmentShaderHandle, 1, &fragmentSourcePointer, NULL); glCompileShader(iFragmentShaderHandle); GLint errorFragment = getLog(iFragmentShaderHandle); if ( (errorVertex > 1) || (errorFragment > 1) ) { bCompiled = GL_FALSE; deleteShader(); return ; } linkProgram(); bCompiled = (uiProgramID != -1); /*if(uiProgramID==-1) { bCompiled=GL_FALSE; return ; } bCompiled=GL_TRUE;*/ }
Program::Program(const std::string& vShaderFile, const std::string& fShaderFile) : _vertexShader (NULL) , _fragmentShader (NULL) , _geometryShader (NULL) { _handle = glCreateProgram(); GL_ERR_CHECK(); _vertexShader = new Shader(vShaderFile, GL_VERTEX_SHADER); _fragmentShader = new Shader(fShaderFile, GL_FRAGMENT_SHADER); glAttachShader(_handle, _vertexShader->getHandle()); GL_ERR_CHECK(); glAttachShader(_handle, _fragmentShader->getHandle()); GL_ERR_CHECK(); // Link the program glLinkProgram(_handle); GL_ERR_CHECK(); // Check for linker errors if(!getLinkStatus()) { std::stringstream err; err << "GLSL program failed to link:" << std::endl; err << getLog() << std::endl; throw std::runtime_error(err.str()); } bind(); mapUniformNamesToIndices(); mapAttributeNamesToIndices(); }
/** * Constructor */ Shader::Shader(const std::string& filename, GLenum shaderType) : _handle (0) { std::string source = readTextFile(filename); const GLchar* sourcePtr0 = source.c_str(); const GLchar** sourcePtr = &sourcePtr0; // Set the source and attempt compilation _handle = glCreateShader(shaderType); GL_ERR_CHECK(); glShaderSource(_handle, 1, sourcePtr, NULL); GL_ERR_CHECK(); glCompileShader(_handle); GL_ERR_CHECK(); if(!getCompileStatus()) { std::stringstream err; err << "Failed to compile shader file: " << filename << std::endl; err << getLog() << std::endl; throw std::runtime_error(err.str()); } }
bool MyActor::deserialize(ke::Serializer& serializer) { if (!ke::Actor::deserialize(serializer)) { return false; } mA = deserializeComponent<ke::NodeComponent>(serializer); mB = deserializeComponent<ke::AnimatorComponent>(serializer); if (mB == nullptr) { getLog() << "Shit"; } if (mScene.useLight()) { mC = deserializeComponent<ke::PointLightComponent>(serializer); } mD = deserializeComponent<ke::InputComponent>(serializer); if (mScene.usePhysic()) { mE = deserializeComponent<ke::PhysicComponent>(serializer); } mCam = deserializeComponent<ke::CameraComponent>(serializer); return true; }
bool GLFFmpegCamcorder::finalise() { int hasNext = 1; // true while(hasNext) { if(avcodec_encode_video2(_context, _paket, nullptr, &hasNext) < 0) { getLog().postMessage(new Message( 'E', false, "Couldn't encode frame", "GLFFmpegCamcorder") ); return false; } else { _videoStream.write((char*)_paket->data, _paket->size); av_free_packet(_paket); } } _videoStream << 0x00 << 0x00 << 0x01 << 0xb7; _videoStream.close(); avcodec_close(_context); av_free(_context); av_freep(&_dstFrame->data[0]); av_free(_dstFrame); return true; }
IDexState* PalPlayerAttackStateSelectTarget::Update() { if(player->getAuto() && player->getTargets().size() == 0) { int8 select_enemy = 1; EPlayerType self_type = player->getPlayerData()->m_PlayerType; if(select_enemy) { TlistPlayer players; if(self_type == EPT_ENEMY) { players = PalGameStateBattleMain::getBattleMain()->getPlayers(EPT_ROLE); } else { players = PalGameStateBattleMain::getBattleMain()->getPlayers(EPT_ENEMY); } if(players.size()==0) { getLog()->Log(log_error, "select target error! enemy size is 0!"); } else { PalPlayer* target = players.front(); player->AddTarget(target); } } } return PalPlayerAttackState::Update(); }
Program::Program(const std::string& vShaderFile, const std::string& fShaderFile, const std::string& gShaderFile) : _vertexShader (NULL) , _fragmentShader (NULL) , _geometryShader (NULL) { _handle = glCreateProgram(); GL_ERR_CHECK(); _vertexShader = new Shader(vShaderFile, GL_VERTEX_SHADER); _fragmentShader = new Shader(fShaderFile, GL_FRAGMENT_SHADER); _geometryShader = new Shader(gShaderFile, GL_GEOMETRY_SHADER); glAttachShader(_handle, _vertexShader->getHandle()); GL_ERR_CHECK(); glAttachShader(_handle, _fragmentShader->getHandle()); GL_ERR_CHECK(); glAttachShader(_handle, _geometryShader->getHandle()); GL_ERR_CHECK(); // Link the program glLinkProgram(_handle); GL_ERR_CHECK(); // Check for linker errors if(!getLinkStatus()) { std::stringstream err; err << "GLSL program failed to link:" << std::endl; err << getLog() << std::endl; throw GL::Exception(err.str()); } }
TEST( Thread, virtualFunctionCallErrorTest ) { static const int THREAD_CNT = 1000; int oldLevel = getLog()->level; getLog()->level = VLog::LEVEL_NONE; for (int i = 0; i < THREAD_CNT; i++) { NoDestructorThread* thread = new NoDestructorThread; thread->open(); // Deleting object witheout calling call() medhod can occur virtual function call error. delete thread; } getLog()->level = oldLevel; LOG_INFO("THREAD_CNT=%d succeedCnt=%d virtual function call count=%d\n", THREAD_CNT, succeedCnt, THREAD_CNT - succeedCnt); EXPECT_TRUE( succeedCnt != THREAD_CNT ); // May be at lease one error occurs!!! }
/* -------------------------------------------------------------------- */ int pwslot(char *in, char *pw) { int slot; if (strlen(pw) < 2) return ERROR; /* Don't search for these pwds */ slot = pwexists(pw); if (slot == ERROR) return ERROR; /* initials must match too */ if ( (logTab[slot].ltinhash) != (int)hash(in) ) return ERROR; getLog(&lBuf, logTab[slot].ltlogSlot); if ( (strcmpi(pw, lBuf.lbpw) == SAMESTRING) && (strcmpi(in, lBuf.lbin) == SAMESTRING) ) { memcpy(&logBuf, &lBuf, sizeof logBuf); thisSlot = slot; thisLog = logTab[slot].ltlogSlot; return(slot); } else { return ERROR; } }
void ArtDirectorClient::connected() { _isConnected = true; getLog().postMessage(new Message('I', false, "New connection established with server", "ArtDirectorClient")); }
void CDexDesktop::SetFocusWgt(CDexWidget* wgt) { getLog()->BeginLog(); if(m_focusWidget != NULL) { if(m_focusWidget != wgt) { getLog()->Log(log_ok,"¿Ø¼þ%s lose focus!\n", m_focusWidget->GetName().c_str()); } } m_focusWidget = wgt; if(m_focusWidget != NULL) { getLog()->Log(log_ok,"¿Ø¼þ%s get focus!\n", m_focusWidget->GetName().c_str()); } getLog()->EndLog(); }
InputComponent::~InputComponent () { #ifdef DREAM_LOG auto log = getLog(); log->trace("Destructing"); #endif }
PhysicsDebugDrawer::~PhysicsDebugDrawer () { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Destroying Object" ); #endif }
void UserAf::v_setZombie( MonitorContainer * i_monitoring) { AFCommon::QueueLog("Deleting user: "******"Became a zombie."); AFCommon::saveLog( getLog(), af::Environment::getUsersLogsDir(), m_name, af::Environment::getAfNodeLogsRotate()); }
int main(int argc,char **argv){ int width,height; int **pixel; int **out; float **tmp; pixel = readPNG(argv[1],&width,&height); writePNG("res_original.png",pixel,width,height); out = histEQ(pixel,width,height); writePNG("res_Equalized.png",out,width,height); FREE_PIXEL(out); out = getNegative(pixel,width,height); writePNG("res_Negative.png",out,width,height); FREE_PIXEL(out); out = halfIntensity(pixel,width,height); writePNG("res_HalfI.png",out,width,height); FREE_PIXEL(out); out = IRescale(pixel,width,height,min,max,0,100); writePNG("res_scaleto0100.png",out,width,height); FREE_PIXEL(out); out = IRescale(pixel,width,height,min,max,200,255); writePNG("res_scaleto200255.png",out,width,height); FREE_PIXEL(out); tmp = getExp(pixel,width,height,20,1.01); out = Normalize(tmp,width,height); writePNG("res_exp.png",out,width,height); FREE_PIXEL(out); tmp = getLog(pixel,width,height,20.2); out = Normalize(tmp,width,height); writePNG("res_log.png",out,width,height); FREE_PIXEL(out); tmp = getPower(pixel,width,height,1,0.5); out = Normalize(tmp,width,height); writePNG("res_powerg05.png",out,width,height); FREE_PIXEL(out); tmp = getPower(pixel,width,height,1,2); out = Normalize(tmp,width,height); writePNG("res_powerg2.png",out,width,height); FREE_PIXEL(out); tmp = getPower(pixel,width,height,1,2.5); out = Normalize(tmp,width,height); writePNG("res_powerg25.png",out,width,height); FREE_PIXEL(out); //printHist(out,width,height); free(pixel); return 0; }
void PhysicsDebugDrawer::drawAll () { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Drawing {} lines" , mVertexBuffer.size()/2 ); #endif preRender(); // Enable shader program glUseProgram(mShaderProgram); glBindVertexArray(mVAO); ShaderRuntime::CurrentShaderProgram = mShaderProgram; // Set the projection matrix GLint projUniform = glGetUniformLocation(mShaderProgram, "projection"); if (projUniform == -1) { #ifdef DREAM_LOG log->error( "Unable to find Uniform Location for projection" ); checkGLError(); #endif return; } else { mat4 projectionMatrix = mCamera->getProjectionMatrix(); glUniformMatrix4fv(projUniform, 1, GL_FALSE, glm::value_ptr(projectionMatrix)); } // Set the view matrix GLint viewUniform = glGetUniformLocation(mShaderProgram, "view"); if (viewUniform == -1) { #ifdef DREAM_LOG log->error( "Unable to find Uniform Location for view" ); checkGLError(); #endif return; } else { mat4 viewMatrix = mCamera->getViewMatrix(); glUniformMatrix4fv(viewUniform, 1, GL_FALSE, glm::value_ptr(viewMatrix)); } glBindBuffer(GL_ARRAY_BUFFER, mVBO); glBufferData(GL_ARRAY_BUFFER, static_cast<GLint>(mVertexBuffer.size() * sizeof(PhysicsDebugVertex)), &mVertexBuffer[0], GL_STATIC_DRAW); // Draw glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(mVertexBuffer.size())); // Unbind postRender(); // Clear old buffer mVertexBuffer.clear(); }
void ThreadedSSLSocketInitiator::onInitialize(const SessionSettings &s) throw( RuntimeError) { if (m_sslInit) return; ssl_init(); std::string errStr; /* set up the application context */ if ((m_ctx = createSSLContext(false, m_settings, errStr)) == 0) { throw RuntimeError(errStr); } if (m_cert && m_key) { if (SSL_CTX_use_certificate(m_ctx, m_cert) < 1) { ssl_term(); throw RuntimeError("Failed to set certificate"); } if (SSL_CTX_use_RSAPrivateKey(m_ctx, m_key) <= 0) { ssl_term(); throw RuntimeError("Failed to set key"); } } else if (!loadSSLCert(m_ctx, false, m_settings, getLog(), ThreadedSSLSocketInitiator::passwordHandleCB, errStr)) { ssl_term(); throw RuntimeError(errStr); } int verifyLevel; if (!loadCAInfo(m_ctx, false, m_settings, getLog(), errStr, verifyLevel)) { ssl_term(); throw RuntimeError(errStr); } m_sslInit = true; }
void PhysicsDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVector3& color) { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Draw Sphere is not implemented" ); #endif }
void Project::resetProjectRuntime() { #ifdef DREAM_LOG auto log = getLog(); log->debug("Resetting project runtime"); #endif delete mRuntime; mRuntime = nullptr; }
void PhysicsDebugDrawer::drawContactPoint (const btVector3& pointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color) { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Draw Contact Point is not implemented" ); #endif }
void PhysicsDebugDrawer::reportErrorWarning (const char* warningString) { #ifdef DREAM_LOG auto log = getLog(); log->debug( warningString ); #endif }
void PhysicsDebugDrawer::draw3dText (const btVector3& location,const char* textString) { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Draw 3DText is not implemented" ); #endif }
void PhysicsDebugDrawer::drawTriangle (const btVector3& a,const btVector3& b,const btVector3& c,const btVector3& color,btScalar alpha) { #ifdef DREAM_LOG auto log = getLog(); log->debug( "Draw Triangle is not implemented" ); #endif }
void Log::lprintf( char *format, ... ) { va_list vl; va_start(vl, format); Log * log = getLog(); log->myMsg[MSG_MAX-1] = 0; vsnprintf(log->myMsg, MSG_MAX-1, format, vl); PRINTF(log->myMsg); FLUSH(); }
void initializeDisplay() { // initscr(); mainwin = initscr(); //newwin(50, 50, 1, 1); box(mainwin, 0, 0); if (mainwin == nullptr) { getLog() << "This would seem to be a problem" << std::endl; getLog() << "Error initialising ncurses.\n" << std::endl; exit(EXIT_FAILURE); } nonl(); cbreak(); curs_set(0); // memory leak /*return*/ new std::thread{waitToDie}; }
GlShader::~GlShader() { if(_id != 0) { glDeleteShader(_id); } getLog().postMessage(new Message('I', false, "OpenGL shader (id=" + toString(_id) + ") deleted", "GlShader")); }