本文整理汇总了C++中Init函数的典型用法代码示例。如果您正苦于以下问题:C++ Init函数的具体用法?C++ Init怎么用?C++ Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
VBOSquare::VBOSquare(Vector3<float> position, float size, int numDivisions) {
Init();
m_position = position;
m_size = size;
m_numDivisions = numDivisions;
//m_vboMesh = new VBO();
int numVertices = 4 + (m_numDivisions-1)*4 + (m_numDivisions-1)*(m_numDivisions-1);
int numIndices = m_numDivisions*m_numDivisions*6;
m_vertices = new Vertex[numVertices];
m_indices = new GLushort[numIndices];
//float sizeby2 = m_size/2.0f;
m_divisionSize = m_size/m_numDivisions;
//Consider only the first decimals
//m_divisionSize = floor(m_divisionSize * 1000.0f) / 1000.0f;
int cont = 0;
for(float i=0; i<=m_divisionSize * m_numDivisions; i+=m_divisionSize){
for(float j=0; j<=m_divisionSize * m_numDivisions; j+=m_divisionSize){
m_vertices[cont].x = m_position.GetX() +i; m_vertices[cont].y = m_position.GetY() +j ; m_vertices[cont].z = m_position.GetZ();
m_vertices[cont].v = (i) / m_size; m_vertices[cont].u = (j) / m_size;
cont++;
}
}
cont = 0; //counts the number of squares rendered
int coluns = 0; //counts the coluns rendered
//numIndices = 18;
//numVertices = 8;
for(int i=0; i<numIndices; i+=6){
m_indices[i] = cont + coluns;
m_indices[i+1] = cont + coluns + 1 + m_numDivisions;
m_indices[i+2] = cont + coluns + 2 + m_numDivisions;
m_indices[i+3] = cont + coluns + 2 + m_numDivisions;
m_indices[i+4] = cont + coluns + 1;
m_indices[i+5] = cont + coluns;
cont++;
//If it reaches the limit of the square, it adds two to the count
if(cont % m_numDivisions == 0)
coluns++;
}
/*
m_indices[0] = 0;
m_indices[1] = 2;
m_indices[2] = 3;
m_indices[3] = 3;
m_indices[4] = 1;
m_indices[5] = 0;
*/
m_vboMesh = new VBO(m_vertices, numVertices, m_indices, numIndices);
}
示例2: SDLSoundChannel
SoundChannel *SoundChannel::Create(const ByteArray &inBytes,const SoundTransform &inTransform)
{
if (!Init())
return 0;
return new SDLSoundChannel(inBytes,inTransform);
}
示例3: Create
ConnectArgsDialog::ConnectArgsDialog(wxWindow *parent,wxWindowID id,const wxString &caption,const wxPoint &pos,const wxSize &size,long style)
{
Create(parent,id,caption,pos,size,style);
Init();
}
示例4: XTransition
//---------------------------------------------------------------------------------------------------------------
XFadeInOut::XFadeInOut( BOOL bHighReso, BOOL bTransIn, float fSec )
: XTransition( bHighReso, fSec, bTransIn )
{
Init();
}
示例5: m_bFullScreen
//.........这里部分代码省略.........
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle = WS_OVERLAPPEDWINDOW; // Windows Style
}
AdjustWindowRectEx(&rectWindow, dwStyle, false, dwExStyle); // Adjust Window To true Requested Size
// Create The Window
if (!(m_hWnd=CreateWindowEx(dwExStyle, // Extended Style For The Window
"OpenGL", // Class Name
lpszTitle, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
m_hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
nBits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
nZBuffer, // 16/32Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(m_hDC=GetDC(m_hWnd))) // Did We Get A Device Context?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
if (!(PixelFormat=ChoosePixelFormat(m_hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
if(!SetPixelFormat(m_hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
if (!(hRC=wglCreateContext(m_hDC))) // Are We Able To Get A Rendering Context?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
if(!wglMakeCurrent(m_hDC,hRC)) // Try To Activate The Rendering Context
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
ShowWindow(m_hWnd, SW_SHOW); // Show The Window
SetForegroundWindow(m_hWnd); // Slightly Higher Priority
SetFocus(m_hWnd); // Sets Keyboard Focus To The Window
Resize(nWidth, nHeight); // Set Up Our Perspective GL Screen
if (!Init()) // Initialize Our Newly Created GL Window
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
return true; // Success
}
示例6: ThreadProcMain
void CKEventThread::ThreadProcMain(void)
{
if( Init() )
{
while( !m_bWantStop )
{
// Figure out how long we can remain in poll/WFMO, possibly forever
waittimer_t nTimeout = INFTIM;
if( m_nTimers )
{
assert( m_ppTimers[1] );
nTimeout = m_ppTimers[1]->GetTimeout() - CKTimer::CurrentTime();
if( nTimeout < 0 || nTimeout > 0x7FFFFFFF ) nTimeout = 0; // Wrap - it's late
}
#ifdef _UNIX
int rc = poll( m_pWaitObjs, m_nSocks, nTimeout );
if( rc < 0 )
{
dbgout( "poll() failed: error = %i (%s)", errno, strerror(errno) );
break;
}
#endif
#ifdef _WIN32
DWORD rc = ::WaitForMultipleObjects( m_nSocks, m_pWaitObjs, FALSE, nTimeout );
if( rc == WAIT_FAILED )
{
dbgout( "WFMO failed: error = %u", ::GetLastError() );
break;
}
rc = (rc == WAIT_TIMEOUT) ? 0 : 1;
#endif
if( rc == 0 && m_nTimers )
{
assert( m_nTimers && m_nTimerAlloc >= 2 && m_ppTimers[1] );
CKTimer* pTimer = m_ppTimers[1];
if( pTimer->GetMode() == CKTimer::Repeating )
{
pTimer->m_next += pTimer->m_interval;
}
else
{
pTimer->m_mode = CKTimer::Disabled;
m_ppTimers[1] = m_ppTimers[m_nTimers--];
}
Heapify( CKTimer::CurrentTime(), 1 );
pTimer->GetResponse()->OnTimer();
}
if( rc > 0 )
{
UINT n;
for( n = 0; n < m_nSocks; n++ )
{
assert( WAITOBJ_IS_VALID( m_pWaitObjs[n] ) && NULL != m_ppSocks[n] );
int err = SOCKERR_NONE;
waitevents_t wevt;
CKSocket* pSock = m_ppSocks[n];
#ifdef _UNIX
wevt = m_pWaitObjs[n].revents;
if( (wevt & (POLLIN|POLLERR)) && (pSock->m_uSelectFlags & SF_ACCEPT) == SF_ACCEPT )
{
wevt = XPOLLACC;
}
if( (wevt & (POLLOUT|POLLERR)) && (pSock->m_uSelectFlags & SF_CONNECT) == SF_CONNECT )
{
socklen_t errlen = sizeof(err);
#if defined(_SOLARIS) && (_SOLARIS < 58)
getsockopt( pSock->GetHandle(), SOL_SOCKET, SO_ERROR, (char*)&err, &errlen );
#else
getsockopt( pSock->GetHandle(), SOL_SOCKET, SO_ERROR, &err, &errlen );
#endif
wevt = XPOLLCNX;
}
if( (wevt & POLLERR) )
{
wevt = pSock->m_uSelectFlags;
}
#endif
#ifdef _WIN32
::WSAEnumNetworkEvents( pSock->GetHandle(), m_pWaitObjs[n], &wevt );
if( wevt.lNetworkEvents & FD_CONNECT )
{
err = wevt.iErrorCode[FD_CONNECT_BIT];
}
if( wevt.lNetworkEvents & FD_CLOSE )
{
wevt.lNetworkEvents = FD_READ;
DelStream( pSock );
pSock->GetNotify()->OnClosed();
}
#endif
if( WAIT_EVENT_READ( wevt ) )
{
pSock->GetNotify()->OnReadReady();
}
else if( WAIT_EVENT_WRITE( wevt ) )
{
//.........这里部分代码省略.........
示例7: memset
CAAUParameter::CAAUParameter(AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element)
{
memset(this, 0, sizeof(CAAUParameter));
Init (au, param, scope, element);
}
示例8: LoadWaterTexture
Water::Water(IDirect3DDevice9 *device, std::string fileName)
:m_device(device)
{
LoadWaterTexture(fileName);
Init();
}
示例9: Iterator
Iterator() {
Init();
}
示例10: CService
CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn)
{
Init();
nServices = nServicesIn;
}
示例11: Init
INLINE Dictionary<TKey, TValue>::Dictionary(Dictionary<TKey, TValue> const &dict) {
Init();
operator=(dict);
}
示例12: Init
void SurfaceTextureBuffer::RestoreDeviceData()
{
Init();
}
示例13: Init
// 支持version = 1.1 版本
BOOL CCheckRuleXMLParse::LoadNew(const CString &strFilePath,
CheckRuleArray &arrCheckRuleList)
{
arrCheckRuleList.RemoveAll();
if (!IsFileExist(strFilePath))
return FALSE;
BOOL bResult = TRUE;
// 初始化
Init();
// 打开xml文件
if (!m_pXMLDocument->OpenXMLForDocument(strFilePath))
bResult = FALSE;
// 读取数据
if (bResult)
{
CheckRule checkRule;
CString strValue, strIndex;
IBpXMLNode* pRootNode = m_pXMLDocument->GetRootElement();
pRootNode->GetName(strValue);
if (strValue.Compare(L"CheckRule") == 0)
{
IBpXMLNode *pChildNode = NULL;
int nNodeCount = pRootNode->GetElementCount(), nAttrCount;
for (int i = 1; i <= nNodeCount; i++)
{
IBpXMLNode *pRuleNode = pRootNode->GetElementChildByIndex(i);
if (pRuleNode->GetElementCount() >= 3)
{
pRuleNode->GetAttributeByName(L"id", strValue);
checkRule.nID = _wtoi(strValue);
// 检查类型
pRuleNode->GetAttributeByName(L"ruletype", strValue);
checkRule.nRuleType = _wtoi(strValue);
// 检查描述
pChildNode = pRuleNode->GetElementChildByIndex(1);
pChildNode->GetText(checkRule.strRuleDesc);
DestroyXMLNode(pChildNode);
// 检查名称
pChildNode = pRuleNode->GetElementChildByIndex(2);
pChildNode->GetText(checkRule.strRuleName);
DestroyXMLNode(pChildNode);
// 检查内容
pChildNode = pRuleNode->GetElementChildByIndex(3);
nAttrCount = pChildNode->GetAttributeCount();
checkRule.arrRuleContent.SetSize(nAttrCount);
for (int j = 0; j < nAttrCount; j++)
{
strIndex.Format(L"rc%d", j);
pChildNode->GetAttributeByName(strIndex, strValue);
checkRule.arrRuleContent.SetAt(j, strValue);
}
DestroyXMLNode(pChildNode);
if (pRuleNode->GetElementCount() >= 4)
{
// 检查模型过滤
pChildNode = pRuleNode->GetElementChildByIndex(4);
pChildNode->GetText(strValue);
checkRule.dwMdlFilter = _wtoi(strValue);
DestroyXMLNode(pChildNode);
}
arrCheckRuleList.Add(checkRule);
}
DestroyXMLNode(pRuleNode);
}
}
else
{
AfxMessageBox(L"XML文件不匹配!");
bResult = FALSE;
}
DestroyXMLNode(pRootNode);
}
// 释放资源
Uninit();
return bResult;
}
示例15: SafeDeleteFile
BOOL CCheckRuleXMLParse::Save(const CString &strFilePath, const CheckRuleArray &arrCheckRuleList)
{
// 删除老版本生成的未加密xml
CString strOldXmlPath = strFilePath;
strOldXmlPath.Replace(L".bpxml", L"xml");
if (IsFileExist(strOldXmlPath))
SafeDeleteFile(strOldXmlPath);
// 删除新版本生成的加密bpxml
if (IsFileExist(strFilePath))
SafeDeleteFile(strFilePath);
BOOL bResult = TRUE;
// 初始化
Init();
// 创建xml文件
if (!m_pXMLDocument->CreateDocument(L"CheckRule"))
bResult = FALSE;
// 存储数据
if (bResult)
{
IBpXMLNode* pRootNode = m_pXMLDocument->GetRootElement();
pRootNode->SetAttribute(L"version", L"1.1");
DestroyXMLNode(pRootNode);
CString strValue;
for (int i=0; i<arrCheckRuleList.GetSize(); i++)
{
IBpXMLNode* pRuleNode = m_pXMLDocument->CreateElementNode(L"node");
IBpXMLNode* pChildNode = NULL;
if (pRuleNode != NULL)
{
strValue.Format(L"%d", arrCheckRuleList[i].nID);
pRuleNode->SetAttribute(L"id", strValue);
strValue.Format(L"%d", arrCheckRuleList[i].nRuleType);
pRuleNode->SetAttribute(L"ruletype", strValue);
pChildNode = pRuleNode->AppendNewElementChild(L"ruledesc");
pChildNode->SetText(arrCheckRuleList[i].strRuleDesc);
DestroyXMLNode(pChildNode);
pChildNode = pRuleNode->AppendNewElementChild(L"rulename");
pChildNode->SetText(arrCheckRuleList[i].strRuleName);
DestroyXMLNode(pChildNode);
pChildNode = pRuleNode->AppendNewElementChild(L"rulecontent");
for (int j=0; j<arrCheckRuleList[i].arrRuleContent.GetCount(); j++)
{
strValue.Format(L"rc%d", j);
pChildNode->SetAttribute(strValue, arrCheckRuleList[i].arrRuleContent.GetAt(j));
}
DestroyXMLNode(pChildNode);
pChildNode = pRuleNode->AppendNewElementChild(L"MdlFilter");
strValue.Format(L"%d", arrCheckRuleList[i].dwMdlFilter);
pChildNode->SetText(strValue);
DestroyXMLNode(pChildNode);
DestroyXMLNode(pRuleNode);
}
}
}
// 保存为临时xml文件
CString strTempXMLFile;
GetTempFile(strTempXMLFile, L"xml");
m_pXMLDocument->SaveXML(strTempXMLFile);
// xml文件加密
bResult = EncodeFileEx(strTempXMLFile, strFilePath);
SafeDeleteFile(strTempXMLFile);
// 释放资源
Uninit();
return bResult;
}