//----------------------------------------------------------------------------- bool vktraceviewer_QTraceFileLoader::load_controllers(vktraceviewer_trace_file_info* pTraceFileInfo) { if (pTraceFileInfo->header.tracer_count == 0) { emit OutputMessage(VKTRACE_LOG_ERROR, "No API specified in tracefile for replaying."); return false; } for (int i = 0; i < pTraceFileInfo->header.tracer_count; i++) { uint8_t tracerId = pTraceFileInfo->header.tracer_id_array[i].id; const VKTRACE_TRACER_REPLAYER_INFO* pReplayerInfo = &(gs_tracerReplayerInfo[tracerId]); if (pReplayerInfo->tracerId != tracerId) { emit OutputMessage(VKTRACE_LOG_ERROR, QString("Replayer info for TracerId (%1) failed consistency check.").arg(tracerId)); assert(!"TracerId in VKTRACE_TRACER_REPLAYER_INFO does not match the requested tracerId. The array needs to be corrected."); } else if (strlen(pReplayerInfo->debuggerLibraryname) != 0) { // Have our factory create the necessary controller emit OutputMessage(VKTRACE_LOG_VERBOSE, QString("Loading controller: %1").arg(pReplayerInfo->debuggerLibraryname)); m_pController = m_controllerFactory.Load(pReplayerInfo->debuggerLibraryname); if (m_pController != NULL) { m_controllerFilename = QString(pReplayerInfo->debuggerLibraryname); // Only one controller needs to be loaded, so break from loop break; } else { // controller failed to be created emit OutputMessage(VKTRACE_LOG_ERROR, QString("Unable to load controller for TracerId %1.").arg(tracerId)); } } } return m_pController != NULL; }
void CError::Print ( std::string msg ) { // User-level error (no additional info) m_ErrorID = ""; m_ErrorSubsys = "undef"; m_ErrorMsg = msg; m_ErrorFunc = ""; m_ErrorFix = ""; m_ErrorExtra = ""; OutputMessage (); }
void MIDIDriver::AllNotesOff ( int chan ) { MIDITimedBigMessage msg; // send a note off for every note on in the out_matrix if ( out_matrix.GetChannelCount ( chan ) > 0 ) { for ( int note = 0; note < 128; ++note ) { while ( out_matrix.GetNoteCount ( chan, note ) > 0 ) { // make a note off with note on msg, velocity 0 msg.SetNoteOn ( ( unsigned char ) chan, ( unsigned char ) note, 0 ); OutputMessage ( msg ); } } } msg.SetControlChange ( chan, C_DAMPER, 0 ); OutputMessage ( msg ); msg.SetAllNotesOff ( ( unsigned char ) chan ); OutputMessage ( msg ); }
int XmlNotationDeclaration::Compare(Reason::System::Object *object, int comparitor) { if (object->InstanceOf(this)) { return Name.Compare(&((XmlNotationDeclaration*)object)->Name, comparitor); } else if (object->InstanceOf(Sequence::Instance)) { return Name.Compare(((Sequence*)object), comparitor); } else { OutputMessage("XmlNotationDeclaration::Compare - ERROR: Invalid object type for comparison.\n"); return Identity::Error; } }
void CError::PrintF ( std::string subsys, char* msg, ... ) { char buf[2000]; va_list argptr; m_ErrorID = ""; m_ErrorSubsys = subsys; va_start(argptr, msg); #ifdef _MSC_VER vsprintf_s (buf, 2000, msg, argptr); #else vsnprintf(buf, 2000, msg, argptr); #endif va_end (argptr); m_ErrorMsg = buf; m_ErrorFunc = ""; m_ErrorFix = ""; m_ErrorExtra = ""; OutputMessage (); }
/* ------------------------------------------------------------------------------------------------ * Flush queued messages to the console output. */ void FlushMessages() { // Acquire a global lock std::lock_guard< std::mutex > lock(g_Mutex); // Output any queued messages while (!g_Messages.empty()) { // Identify the message type and send it if (g_Messages.front().second) { OutputMessage("%s", g_Messages.front().first.c_str()); } else { OutputError("%s", g_Messages.front().first.c_str()); } // Pop the message from the queue g_Messages.pop(); } }
FMOD::Sound* SoundManagerAL::GetSoundBuffer( const char* filename ) { string key = filename; map< string, FMOD::Sound* >::iterator itor = m_bufferMap.find( key ); if( itor == m_bufferMap.end() ) { FMOD::Sound* snd=NULL; if(m_system->createSound(filename, FMOD_HARDWARE | FMOD_3D, 0, &snd) != FMOD_OK ) { OutputMessage("Dios mio, couldn't create sound file!" ) ; } if( snd ) { snd->set3DMinMaxDistance(30, 2000.0f); //snd->setMode(FMOD_LOOP_NORMAL); } m_bufferMap[key] = snd; } return m_bufferMap[key] ; }
//----------------------------------------------------------------------------- bool vktraceviewer_QTraceFileLoader::populate_trace_file_info(vktraceviewer_trace_file_info* pTraceFileInfo) { assert(pTraceFileInfo != NULL); assert(pTraceFileInfo->pFile != NULL); // read trace file header if (1 != fread(&(pTraceFileInfo->header), sizeof(vktrace_trace_file_header), 1, pTraceFileInfo->pFile)) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to read header from file."); return false; } // Find out how many trace packets there are. // Seek to first packet long first_offset = pTraceFileInfo->header.first_packet_offset; int seekResult = fseek(pTraceFileInfo->pFile, first_offset, SEEK_SET); if (seekResult != 0) { emit OutputMessage(VKTRACE_LOG_WARNING, "Failed to seek to the first packet offset in the trace file."); } uint64_t fileOffset = pTraceFileInfo->header.first_packet_offset; uint64_t packetSize = 0; while(1 == fread(&packetSize, sizeof(uint64_t), 1, pTraceFileInfo->pFile)) { // success! pTraceFileInfo->packetCount++; fileOffset += packetSize; fseek(pTraceFileInfo->pFile, fileOffset, SEEK_SET); } if (pTraceFileInfo->packetCount == 0) { if (ferror(pTraceFileInfo->pFile) != 0) { perror("File Read error:"); emit OutputMessage(VKTRACE_LOG_ERROR, "There was an error reading the trace file."); return false; } else if (feof(pTraceFileInfo->pFile) != 0) { emit OutputMessage(VKTRACE_LOG_WARNING, "Reached the end of the file."); } emit OutputMessage(VKTRACE_LOG_WARNING, "There are no trace packets in this trace file."); pTraceFileInfo->pPacketOffsets = NULL; } else { pTraceFileInfo->pPacketOffsets = VKTRACE_NEW_ARRAY(vktraceviewer_trace_file_packet_offsets, pTraceFileInfo->packetCount); // rewind to first packet and this time, populate the packet offsets if (fseek(pTraceFileInfo->pFile, first_offset, SEEK_SET) != 0) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to rewind trace file to gather packet offsets."); return false; } unsigned int packetIndex = 0; fileOffset = first_offset; while(1 == fread(&packetSize, sizeof(uint64_t), 1, pTraceFileInfo->pFile)) { // the fread confirms that this packet exists // NOTE: We do not actually read the entire packet into memory right now. pTraceFileInfo->pPacketOffsets[packetIndex].fileOffset = fileOffset; // rewind slightly fseek(pTraceFileInfo->pFile, -1*(long)sizeof(uint64_t), SEEK_CUR); // allocate space for the packet and read it in pTraceFileInfo->pPacketOffsets[packetIndex].pHeader = (vktrace_trace_packet_header*)vktrace_malloc(packetSize); if (1 != fread(pTraceFileInfo->pPacketOffsets[packetIndex].pHeader, packetSize, 1, pTraceFileInfo->pFile)) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to read in a trace packet."); return false; } // adjust pointer to body of the packet pTraceFileInfo->pPacketOffsets[packetIndex].pHeader->pBody = (uintptr_t)pTraceFileInfo->pPacketOffsets[packetIndex].pHeader + sizeof(vktrace_trace_packet_header); // now seek to what should be the next packet fileOffset += packetSize; packetIndex++; } if (fseek(pTraceFileInfo->pFile, first_offset, SEEK_SET) != 0) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to rewind trace file to restore position."); return false; } } return true; }
bool MMatchClient::OnCommand(MCommand* pCommand) { bool ret = MClient::OnCommand(pCommand); if ( (pCommand->m_pCommandDesc->IsFlag(MCDT_PEER2PEER)==true) ) { // Peer Network 안타고 OnCommand 불린경우 CommUID를 PlayerUID로 치환 if (pCommand->GetSenderUID() == GetUID()) { pCommand->SetSenderUID(GetPlayerUID()); } else { // Peer의 패킷 시리얼은 여기서 체크한다. MMatchPeerInfo* pPeer = FindPeer(pCommand->GetSenderUID()); if (pPeer) { if (!pPeer->CheckCommandValidate(pCommand)) { // 암호화안한 데이타는 무시 if (pCommand->m_pCommandDesc->IsFlag(MCCT_NON_ENCRYPTED) == false) { return false; } } } } } switch(pCommand->GetID()) { case MC_MATCH_RESPONSE_LOGIN: { int nResult; char nServerMode; unsigned char nUGradeID, nPGradeID; MUID uidPlayer; char szServerName[256]; char szAccountID[MAX_USERID_STRING_LEN]; bool bEnabledSurvivalMode; bool bEnabledDuelTournament; pCommand->GetParameter(&nResult, 0, MPT_INT); pCommand->GetParameter(szServerName, 1, MPT_STR, sizeof(szServerName) ); pCommand->GetParameter(&nServerMode, 2, MPT_CHAR); pCommand->GetParameter(szAccountID, 3, MPT_STR, MAX_USERID_STRING_LEN ); pCommand->GetParameter(&nUGradeID, 4, MPT_UCHAR); pCommand->GetParameter(&nPGradeID, 5, MPT_UCHAR); pCommand->GetParameter(&uidPlayer, 6, MPT_UID); pCommand->GetParameter(&bEnabledSurvivalMode, 7, MPT_BOOL); pCommand->GetParameter(&bEnabledDuelTournament, 8, MPT_BOOL); // pCommand->GetParameter(szRandomValue, 7, MPT_STR, sizeof(szRandomValue) ); // MCommandParameter* pParam1 = pCommand->GetParameter(7); // if (pParam1->GetType() != MPT_BLOB) // { // break; // } // void* pBlob1 = pParam1->GetPointer(); // unsigned char *szRandomValue = (unsigned char*)MGetBlobArrayElement(pBlob1, 0); MCommandParameter* pParam = pCommand->GetParameter(9); if (pParam->GetType()!=MPT_BLOB) break; void* pBlob = pParam->GetPointer(); if( NULL == pBlob ) break; int nCount = MGetBlobArrayCount(pBlob); unsigned char* pbyGuidReqMsg = (unsigned char*)MGetBlobArrayElement(pBlob, 0); OnResponseMatchLogin(pCommand->GetSenderUID(), nResult, szServerName, MMatchServerMode(nServerMode), szAccountID, MMatchUserGradeID(nUGradeID), MMatchPremiumGradeID(nPGradeID), uidPlayer, bEnabledSurvivalMode, bEnabledDuelTournament, pbyGuidReqMsg); } break; case MC_MATCH_OBJECT_CACHE: { unsigned char nType; pCommand->GetParameter(&nType, 0, MPT_UCHAR); MCommandParameter* pParam = pCommand->GetParameter(1); if(pParam->GetType()!=MPT_BLOB) break; void* pBlob = pParam->GetPointer(); if( NULL == pBlob ) break; int nCount = MGetBlobArrayCount(pBlob); OnObjectCache((unsigned int)nType, pBlob, nCount); } break; case MC_AGENT_RESPONSE_LOGIN: { OnResponseAgentLogin(); } break; case MC_AGENT_LOCATETO_CLIENT: { MUID uidAgent; char szIP[64]; int nPort, nUDPPort; if (pCommand->GetParameter(&uidAgent, 0, MPT_UID) == false) break; if (pCommand->GetParameter(szIP, 1, MPT_STR, sizeof(szIP) ) == false) break; if (pCommand->GetParameter(&nPort, 2, MPT_INT) == false) break; if (pCommand->GetParameter(&nUDPPort, 3, MPT_INT) == false) break; OnLocateAgentToClient(uidAgent, szIP, nPort, nUDPPort); } break; case MC_AGENT_TUNNELING_TCP: { MUID uidSender, uidReceiver; if (pCommand->GetParameter(&uidSender, 0, MPT_UID)==false) break; if (pCommand->GetParameter(&uidReceiver, 1, MPT_UID)==false) break; MCommandParameter* pParam = pCommand->GetParameter(2); if (pParam->GetType()!=MPT_BLOB) break; void* pBlob = pParam->GetPointer(); if( NULL == pBlob ) break; int nCount = MGetBlobArrayCount(pBlob); OnTunnelingTCP(uidSender, pBlob, nCount); } break; case MC_AGENT_TUNNELING_UDP: { MUID uidSender, uidReceiver; if (pCommand->GetParameter(&uidSender, 0, MPT_UID)==false) break; if (pCommand->GetParameter(&uidReceiver, 1, MPT_UID)==false) break; MCommandParameter* pParam = pCommand->GetParameter(2); if (pParam->GetType()!=MPT_BLOB) break; void* pBlob = pParam->GetPointer(); if( NULL == pBlob ) break; int nCount = MGetBlobArrayCount(pBlob); OnTunnelingUDP(uidSender, pBlob, nCount); } break; case MC_AGENT_ALLOW_TUNNELING_TCP: { OnAllowTunnelingTCP(); } break; case MC_AGENT_ALLOW_TUNNELING_UDP: { OnAllowTunnelingUDP(); } break; case MC_AGENT_ERROR: { int nError; if (pCommand->GetParameter(&nError, 0, MPT_INT) == false) break; OnAgentError(nError); } break; case MC_VERSION: OutputMessage("MAIET MatchClient Version", MZMOM_LOCALREPLY); break; case MC_NET_ENUM: break; case MC_NET_RESPONSE_INFO: break; case MC_PEER_UDPTEST: { OnUDPTest(pCommand->GetSenderUID()); } break; case MC_PEER_UDPTEST_REPLY: { OnUDPTestReply(pCommand->GetSenderUID()); } break; case MC_AGENT_DEBUGTEST: { } break; default: if (!ret) { return false; } } return true; }
// // WinProcCallback // INT_PTR WINAPI WinProcCallback( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) // Routine Description: // Simple Windows callback for handling messages. // This is where all the work is done because the example // is using a window to process messages. This logic would be handled // differently if registering a service instead of a window. // Parameters: // hWnd - the window handle being registered for events. // message - the message being interpreted. // wParam and lParam - extended information provided to this // callback by the message sender. // For more information regarding these parameters and return value, // see the documentation for WNDCLASSEX and CreateWindowEx. { LRESULT lRet = 1; static HDEVNOTIFY hDeviceNotify; static HWND hEditWnd; static ULONGLONG msgCount = 0; switch (message) { case WM_CREATE: // // This is the actual registration., In this example, registration // should happen only once, at application startup when the window // is created. // // If you were using a service, you would put this in your main code // path as part of your service initialization. // if (!DoRegisterDeviceInterfaceToHwnd( WceusbshGUID, hWnd, &hDeviceNotify)) { // Terminate on failure. ErrorHandler(TEXT("DoRegisterDeviceInterfaceToHwnd")); ExitProcess(1); } // // Make the child window for output. // hEditWnd = CreateWindow(TEXT("EDIT"),// predefined class NULL, // no window title WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 0, 0, // set size in WM_SIZE message hWnd, // parent window (HMENU)1, // edit control ID (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL); // pointer not needed if (hEditWnd == NULL) { // Terminate on failure. ErrorHandler(TEXT("CreateWindow: Edit Control")); ExitProcess(1); } // Add text to the window. SendMessage(hEditWnd, WM_SETTEXT, 0, (LPARAM)TEXT("Registered for USB device notification...\n")); break; case WM_SETFOCUS: SetFocus(hEditWnd); break; case WM_SIZE: // Make the edit control the size of the window's client area. MoveWindow(hEditWnd, 0, 0, // starting x- and y-coordinates LOWORD(lParam), // width of client area HIWORD(lParam), // height of client area TRUE); // repaint window break; case WM_DEVICECHANGE: { // // This is the actual message from the interface via Windows messaging. // This code includes some additional decoding for this particular device type // and some common validation checks. // // Note that not all devices utilize these optional parameters in the same // way. Refer to the extended information for your particular device type // specified by your GUID. // PDEV_BROADCAST_DEVICEINTERFACE b = (PDEV_BROADCAST_DEVICEINTERFACE)lParam; TCHAR strBuff[256]; // Output some messages to the window. switch (wParam) { case DBT_DEVICEARRIVAL: msgCount++; StringCchPrintf( strBuff, 256, TEXT("Message %d: DBT_DEVICEARRIVAL\n"), msgCount); break; case DBT_DEVICEREMOVECOMPLETE: msgCount++; StringCchPrintf( strBuff, 256, TEXT("Message %d: DBT_DEVICEREMOVECOMPLETE\n"), msgCount); break; case DBT_DEVNODES_CHANGED: msgCount++; StringCchPrintf( strBuff, 256, TEXT("Message %d: DBT_DEVNODES_CHANGED\n"), msgCount); break; default: msgCount++; StringCchPrintf( strBuff, 256, TEXT("Message %d: WM_DEVICECHANGE message received, value %d unhandled.\n"), msgCount, wParam); break; } OutputMessage(hEditWnd, wParam, (LPARAM)strBuff); } break; case WM_CLOSE: if (!UnregisterDeviceNotification(hDeviceNotify)) { ErrorHandler(TEXT("UnregisterDeviceNotification")); } DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: // Send all other messages on to the default windows handler. lRet = DefWindowProc(hWnd, message, wParam, lParam); break; } return lRet; }
bool ZBirdDummyClient::OnCommand(MCommand* pCommand) { switch(pCommand->GetID()) { case MC_LOCAL_INFO: { } break; case MC_NET_CONNECT: { char szAddress[256]; pCommand->GetParameter(szAddress, 0, MPT_STR, sizeof(szAddress) ); char szIP[256]; int nPort; SplitIAddress(szIP, &nPort, szAddress); SOCKET socket; int nReturn = Connect(&socket, szIP, nPort); if(nReturn!=MOK) { OutputMessage("Can't connect to communicator", MZMOM_ERROR); // OutputMessage(MGetErrorString(nReturn), MZMOM_ERROR); OutputMessage( ZErrStr(nReturn), MZMOM_ERROR ); break; } } break; case MC_NET_DISCONNECT: Disconnect(m_Server); break; case MC_MATCH_RESPONSE_LOGIN: { int nResult; MUID uidPlayer; pCommand->GetParameter(&nResult, 0, MPT_INT); pCommand->GetParameter(&uidPlayer, 3, MPT_UID); OnResponseMatchLogin(pCommand->GetSenderUID(), nResult, uidPlayer); } break; case MC_MATCH_RESPONSE_RECOMMANDED_CHANNEL: { MUID uidChannel; char szChannelName[256]; pCommand->GetParameter(&uidChannel, 0, MPT_UID); pCommand->GetParameter(szChannelName, 1, MPT_STR, sizeof(szChannelName) ); OnResponseRecommandedChannel(uidChannel, szChannelName); } break; case MC_MATCH_STAGE_JOIN: { MUID uidChar, uidStage; char szStageName[256]; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); pCommand->GetParameter(szStageName, 2, MPT_STR, sizeof(szStageName) ); OnStageJoin(uidChar, uidStage, szStageName); } break; case MC_MATCH_STAGE_LEAVE: { MUID uidChar, uidStage; pCommand->GetParameter(&uidChar, 0, MPT_UID); pCommand->GetParameter(&uidStage, 1, MPT_UID); OnStageLeave(uidChar, uidStage); } break; } if (m_fnOnCommandCallBack) m_fnOnCommandCallBack(this, pCommand); return false; }
bool Screen3D::Create(HWND hwnd, DisplayModeInfo& m, float viewdistance) { if( NULL == ( D3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return false; D3DDISPLAYMODE d3ddm; if( FAILED( D3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) return false; hWnd = hwnd; //Get the client rectangle dimensions of the window. RECT WindowRect; GetClientRect(hwnd, &WindowRect); if( m.Width == -1 || m.Height == -1) { DisplayMode.Width = WindowRect.right - WindowRect.left; DisplayMode.Height = WindowRect.bottom - WindowRect.top; } else { DisplayMode.Width = m.Width; DisplayMode.Height = m.Height; } OutputMessage( "Attempting Resolution: %dx%d\n", DisplayMode.Width, DisplayMode.Height); // Set up the structure used to create the D3DDevice. ZeroMemory( &d3dpp, sizeof(d3dpp) ); if ( DisplayMode.Fullscreen ) { d3dpp.Windowed = FALSE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //D3DSWAPEFFECT_COPY ; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;//D3DPRESENT_INTERVAL_ONE ; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT ; } else { d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; } d3dpp.BackBufferWidth = DisplayMode.Width ; d3dpp.BackBufferHeight = DisplayMode.Height; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; OutputMessage( "BackBuffer: %d\n", d3ddm.Format ); //Get the depth/stencil caps //check for 32bit depth buffer if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) )) { d3dpp.AutoDepthStencilFormat = D3DFMT_D32; } //second choice is 24bit buffer with 8 bit stencil else if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24S8) )) { d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; } //third choice is 24bit buffer with 4 bit stencil else if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X4S4) )) { d3dpp.AutoDepthStencilFormat = D3DFMT_D24X4S4; } //fourth choice is 24bit buffer with 8 bits wasted else if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) )) { d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8; } //fifth choice is 16bit buffer else if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) ) ) { d3dpp.AutoDepthStencilFormat = D3DFMT_D16; } //last choice is 15bit depth buffer with 1 bit stencil else if( SUCCEEDED ( D3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D15S1) ) ) { d3dpp.AutoDepthStencilFormat = D3DFMT_D15S1; } OutputMessage( "DepthStencil: %d\n", d3dpp.AutoDepthStencilFormat ); // Create the D3DDevice HRESULT hr; DWORD VertexFlags=0; if(true) VertexFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; else VertexFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING; // Set default settings //UINT AdapterToUse=D3DADAPTER_DEFAULT; //D3D->GetAdapterCount()-1 //D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL; //D3DDEVTYPE_REF #ifdef NVPERFHUD UINT AdapterToUse=D3D->GetAdapterCount()-1; D3DDEVTYPE DeviceType=D3DDEVTYPE_REF; #else UINT AdapterToUse=D3DADAPTER_DEFAULT; //D3D->GetAdapterCount()-1 D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL; //D3DDEVTYPE_REF #endif // Look for 'NVIDIA NVPerfHUD' adapter // If it is present, override default settings for (UINT Adapter=0;Adapter<D3D->GetAdapterCount();Adapter++) { D3DADAPTER_IDENTIFIER9 Identifier; HRESULT Res; Res = D3D->GetAdapterIdentifier(Adapter,0,&Identifier); if (strcmp(Identifier.Description,"NVIDIA NVPerfHUD") == 0) { AdapterToUse=Adapter; DeviceType=D3DDEVTYPE_REF; break; } } if( FAILED( hr = D3D->CreateDevice( AdapterToUse,//D3DADAPTER_DEFAULT, DeviceType,//D3DDEVTYPE_HAL, hwnd, VertexFlags , &d3dpp, &D3DDevice ) ) ) { OutputDXError( hr, "D3D Device Init Failed "); return false; } else { //We have a mixed device, so figure out the level of T&L support D3DCAPS9 tlcaps; D3DDevice->GetDeviceCaps(&tlcaps); // initialize m_pd3dDevice before using //check the shader version if( D3DSHADER_VERSION_MAJOR( tlcaps.VertexShaderVersion ) < 1 ) TLSupport = S3D_STANDARD; //Major version is 1, so check minor versions else if(D3DSHADER_VERSION_MINOR( tlcaps.VertexShaderVersion ) < 1 ) TLSupport = S3D_VS_1_0; //Vertex shader 1.0 else TLSupport = S3D_VS_1_1; //Vertex shader 1.1 or above } //set up the projection matrix D3DXMATRIX matProj; D3DXMatrixPerspectiveFovLH( &matProj, RADIAN(60), (float)DisplayMode.Width/(float)DisplayMode.Height, 1.0f, viewdistance ); D3DDevice->SetTransform( D3DTS_PROJECTION, &matProj ); //figure out the field of view CalculateFOV(); // initial render state D3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); D3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); D3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); D3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); D3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); D3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); SetLinearTextureFiltering(); //init the texture manager TM.Init(this); TM.RestoreTextures(); InitialAvailableMem = D3DDevice->GetAvailableTextureMem(); //Init the font manager FM.Init( *this ); //return OK return true; }
int main (int argc, char **argv) { #ifndef _WIN32 #ifdef TRUSTED_USER_SECURITY struct passwd *p = getpwuid (getuid ()); #endif #endif struct _pgsql_drv_storage *store; char file[PATH_MAX+1]; int i, ch; #ifndef HAVE_GETOPT int optind = 1; #endif /* Read dspam.conf */ agent_config = read_config(NULL); if (!agent_config) { LOG(LOG_ERR, ERR_AGENT_READ_CONFIG); exit(EXIT_FAILURE); } if (!_ds_read_attribute(agent_config, "Home")) { LOG(LOG_ERR, ERR_AGENT_DSPAM_HOME); _ds_destroy_config(agent_config); exit(EXIT_FAILURE); } #ifndef _WIN32 #ifdef TRUSTED_USER_SECURITY if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) { fprintf(stderr, ERR_TRUSTED_MODE "\n"); _ds_destroy_config(agent_config); exit(EXIT_FAILURE); } #endif #endif for(i=0; i<argc; i++) { if (!strncmp (argv[i], "--profile=", 10)) { if (!_ds_match_attribute(agent_config, "Profile", argv[i]+10)) { LOG(LOG_ERR, ERR_AGENT_NO_SUCH_PROFILE, argv[i]+10); _ds_destroy_config(agent_config); exit(EXIT_FAILURE); } else { _ds_overwrite_attribute(agent_config, "DefaultProfile", argv[i]+10); } break; } } open_ctx = open_mtx = NULL; signal (SIGINT, dieout); signal (SIGPIPE, dieout); signal (SIGTERM, dieout); /* Process command line */ ch = 0; #ifdef HAVE_GETOPT while((ch = getopt(argc, argv, "h")) != -1) #else while ( argv[optind] && argv[optind][0] == '-' && (ch = argv[optind][1]) && argv[optind][2] == '\0' ) #endif { switch(ch) { case 'h': /* print help, and then exit. usage exits for us */ usage(); break; #ifndef HAVE_GETOPT default: fprintf(stderr, "%s: unknown option \"%s\".\n", argv[0], argv[optind] + 1); usage(); #endif } #ifndef HAVE_GETOPT optind++; #endif } /* reset our option array and index to where we are after getopt */ argv += optind; argc -= optind; if (argc == 0) { fprintf(stderr,"Must specify an output file\n"); usage(); } memset((void *)file, 0, PATH_MAX+1); strncpy(file, argv[0], PATH_MAX); open_ctx = dspam_create(NULL,NULL,_ds_read_attribute(agent_config, "Home"), DSM_TOOLS, 0); if (open_ctx == NULL) { fprintf(stderr, "Could not initialize context: %s\n", strerror (errno)); exit(EXIT_FAILURE); } set_libdspam_attributes(open_ctx); if (dspam_attach(open_ctx, NULL)) { fprintf(stderr,"Failed to init link to PostgreSQL\n"); dspam_destroy(open_ctx); exit(EXIT_FAILURE); } store = (struct _pgsql_drv_storage *)(open_ctx->storage); GenSQL(store->dbh,file); //PQfinish(store->dbh); OutputMessage(open_ctx,file); if (open_ctx != NULL) dspam_destroy (open_ctx); if (open_mtx != NULL) dspam_destroy (open_mtx); _ds_destroy_config(agent_config); exit (EXIT_SUCCESS); }
void CError::PrintErrW ( std::string err, int result ) { OutputMessage (); m_ErrorExtra = ""; }
//----------------------------------------------------------------------------- void vktraceviewer_QTraceFileLoader::loadTraceFile(const QString& filename) { // open trace file and read in header memset(&m_traceFileInfo, 0, sizeof(vktraceviewer_trace_file_info)); m_traceFileInfo.pFile = fopen(filename.toStdString().c_str(), "rb"); bool bOpened = (m_traceFileInfo.pFile != NULL); if (!bOpened) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to open file."); } else { m_traceFileInfo.filename = vktrace_allocate_and_copy(filename.toStdString().c_str()); if (populate_trace_file_info(&m_traceFileInfo) == FALSE) { emit OutputMessage(VKTRACE_LOG_ERROR, "Unable to populate trace file info from file."); bOpened = false; } else { // Make sure trace file version is supported if (m_traceFileInfo.header.trace_file_version < VKTRACE_TRACE_FILE_VERSION_MINIMUM_COMPATIBLE) { emit OutputMessage(VKTRACE_LOG_ERROR, QString("Trace file version %1 is older than minimum compatible version (%2).\nYou'll need to make a new trace file, or use an older replayer.").arg(m_traceFileInfo.header.trace_file_version).arg(VKTRACE_TRACE_FILE_VERSION_MINIMUM_COMPATIBLE)); bOpened = false; } #ifdef USE_STATIC_CONTROLLER_LIBRARY m_pController = vtvCreateQController(); if (bOpened) #else if (!load_controllers(&m_traceFileInfo)) { emit OutputMessage(VKTRACE_LOG_ERROR, "Failed to load necessary debug controllers."); bOpened = false; } else if (bOpened) #endif { connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, const QString&)), this, SIGNAL(OutputMessage(VktraceLogLevel, const QString&))); connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, uint64_t, const QString&)), this, SIGNAL(OutputMessage(VktraceLogLevel, uint64_t, const QString&))); // interpret the trace file packets for (uint64_t i = 0; i < m_traceFileInfo.packetCount; i++) { vktraceviewer_trace_file_packet_offsets* pOffsets = &m_traceFileInfo.pPacketOffsets[i]; switch (pOffsets->pHeader->packet_id) { case VKTRACE_TPI_MESSAGE: m_traceFileInfo.pPacketOffsets[i].pHeader = vktrace_interpret_body_as_trace_packet_message(pOffsets->pHeader)->pHeader; break; case VKTRACE_TPI_MARKER_CHECKPOINT: break; case VKTRACE_TPI_MARKER_API_BOUNDARY: break; case VKTRACE_TPI_MARKER_API_GROUP_BEGIN: break; case VKTRACE_TPI_MARKER_API_GROUP_END: break; case VKTRACE_TPI_MARKER_TERMINATE_PROCESS: break; //TODO processing code for all the above cases default: { vktrace_trace_packet_header* pHeader = m_pController->InterpretTracePacket(pOffsets->pHeader); if (pHeader == NULL) { bOpened = false; emit OutputMessage(VKTRACE_LOG_ERROR, QString("Unrecognized packet type: %1").arg(pOffsets->pHeader->packet_id)); m_traceFileInfo.pPacketOffsets[i].pHeader = NULL; break; } m_traceFileInfo.pPacketOffsets[i].pHeader = pHeader; } } // break from loop if there is an error if (bOpened == false) { break; } } #ifdef USE_STATIC_CONTROLLER_LIBRARY vtvDeleteQController(&m_pController); #else m_controllerFactory.Unload(&m_pController); #endif } } // TODO: We don't really want to close the trace file yet. // I think we want to keep it open so that we can dynamically read from it. // BUT we definitely don't want it to get locked open, so we need a smart // way to open / close from it when reading. fclose(m_traceFileInfo.pFile); m_traceFileInfo.pFile = NULL; } // populate the UI based on trace file info emit TraceFileLoaded(bOpened, m_traceFileInfo, m_controllerFilename); emit Finished(); }
void CDOutput::OpenFilePtrs(std::map<string,bool> &BlockDefined,CDCalMode &cCalMode) { char SourceFileName[FILE_NAME_LENGTH]; char FscFileName[FILE_NAME_LENGTH]; char MatFileName[FILE_NAME_LENGTH]; char TallyFileName[FILE_NAME_LENGTH]; char CycTallyFileName[FILE_NAME_LENGTH]; char PlotFileName[FILE_NAME_LENGTH]; char InnerProductFileName[FILE_NAME_LENGTH]; ///////////////// Only output when MyId==0 for parallel /////////////////// # ifdef _IS_PARALLEL_ if(!OParallel.p_bIsMaster) { return ; } # endif ///////////////////////// If it is point burnup, return //////////////////// //if(CalMode.RmcCalcMode == CalMode.PointBurnMode) if(cCalMode.p_nRmcCalcMode == cCalMode.PointBurnMode) { return; } ///////////////////////// Open all kinds of output files //////////////////// if(BlockDefined["MATERIAL"] == true) { strcpy(MatFileName, p_chInputFileName); strcat(MatFileName,".material"); p_fpMatFilePtr = fopen(MatFileName,"w"); if (p_fpMatFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen mat print file \"%s\" failed.\n",MatFileName);},CDOutput::_ERROR); } } if(BlockDefined["TALLY"] == true || BlockDefined["BURNUP"] == true) { strcpy(TallyFileName, p_chInputFileName); strcat(TallyFileName,".Tally"); p_fpTallyFilePtr = fopen(TallyFileName,"w"); if (p_fpTallyFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen Tally print file \"%s\" failed.\n",TallyFileName);},CDOutput::_ERROR); } if(p_bIsTallyPrintPerCyc) { strcpy(CycTallyFileName, p_chInputFileName); strcat(CycTallyFileName,".CycTally"); p_fpCycTallyFilePtr = fopen(CycTallyFileName,"w"); if (p_fpCycTallyFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen CycTally print file \"%s\" failed.\n",CycTallyFileName);},CDOutput::_ERROR); } } } if(BlockDefined["CONVERGENCE"] == true) { strcpy(FscFileName, p_chInputFileName); strcat(FscFileName,".fsc"); p_fpFscFilePtr = fopen(FscFileName,"w"); if (p_fpFscFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen Convergence print file \"%s\" failed.\n",FscFileName);},CDOutput::_ERROR); } } if(p_bIsSrcPrint == true) { strcpy(SourceFileName, p_chInputFileName); strcat(SourceFileName,".source"); p_fpSourceFilePtr = fopen(SourceFileName,"w"); if (p_fpSourceFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen Source print file \"%s\" failed.\n",SourceFileName);},CDOutput::_ERROR); } } if(BlockDefined["PLOT"] == true) { strcpy(PlotFileName, p_chInputFileName); strcat(PlotFileName,".plot"); p_fpPlotFilePtr = fopen(PlotFileName,"w"); if (p_fpPlotFilePtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen Plot print file \"%s\" failed.\n",p_fpPlotFilePtr);},CDOutput::_ERROR); } } if(cCalMode.p_nRmcCalcMode == cCalMode.QuasiStaticSMode || cCalMode.p_nRmcCalcMode == cCalMode.QuasiStaticDMode) { strcpy(InnerProductFileName, p_chInputFileName); strcat(InnerProductFileName,".innerproduct"); p_fpInnerProductPtr = fopen(InnerProductFileName,"w"); if (p_fpInnerProductPtr == NULL) { OutputMessage([&](){sprintf(p_sPrintStr,"\nOpen InnerProduct print file \"%s\" failed.\n",p_fpInnerProductPtr);},CDOutput::_ERROR); } } return; }
void MMatchClient::OutputLocalInfo(void) { OutputMessage("MAIET Match Client", MZMOM_LOCALREPLY); OutputMessage(MZMOM_LOCALREPLY, "UID : %u:%u", m_This.High, m_This.Low); OutputMessage(MZMOM_LOCALREPLY, "Connected Communicator : %u:%u", m_Server.High, m_Server.Low); }