示例#1
0
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
0
文件: SDLSound.cpp 项目: Glidias/NME
SoundChannel *SoundChannel::Create(const ByteArray &inBytes,const SoundTransform &inTransform)
{
   if (!Init())
      return 0;
   return new SDLSoundChannel(inBytes,inTransform);
}
示例#3
0
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
0
//---------------------------------------------------------------------------------------------------------------
XFadeInOut::XFadeInOut( BOOL bHighReso, BOOL bTransIn, float fSec )
	: XTransition( bHighReso, fSec, bTransIn )
{
	Init();
}
示例#5
0
文件: GL.cpp 项目: wernight/cuckoo
/*	This Code Creates Our OpenGL Window.  Parameters Are:
 *	lpszTitle		- Title to Appear at the Top of the Window
 *	nWidth			- Width of the GL Window or Fullscreen Mode
 *	nHeight			- Height of the GL Window or Fullscreen Mode
 *	nBits			- Number of Bits to Use for Color (8/16/24/32)
 *	nZBuffer		- Number of Bits to Use for Z-Buffer (16/32)
 *	bFullScreen		- Use Fullscreen Mode (true) Or Windowed Mode (false)
 */
bool CGL::Create(char* lpszTitle, int nWidth, int nHeight, int nBits=16, int nZBuffer=16, bool bFullScreen=true) : m_bFullScreen(bFullScreen)
{
	GLuint		PixelFormat;							// Holds The Results After Searching For A Match
	WNDCLASS	wc;										// Windows Class Structure
	DWORD		dwExStyle;								// Window Extended Style
	DWORD		dwStyle;								// Window Style
	RECT		rectWindow(0, nWidth, 0, nHeight);		// Grabs Rectangle Upper Left / Lower Right Values

	m_hInstance			= GetModuleHandle(NULL);		// Grab An Instance For Our Window
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
	wc.lpfnWndProc		= (WNDPROC) WndProc;			// WndProc Handles Messages
	wc.cbClsExtra		= 0;							// No Extra Window Data
	wc.cbWndExtra		= 0;							// No Extra Window Data
	wc.hInstance		= m_hInstance;					// Set The Instance
	wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);	// Load The Default Icon
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);	// Load The Arrow Pointer
	wc.hbrBackground	= NULL;							// No Background Required For GL
	wc.lpszMenuName		= NULL;							// We Don't Want A Menu
	wc.lpszClassName	= "OpenGL";						// Set The Class Name

	if (!RegisterClass(&wc))							// Attempt To Register The Window Class
	{
		MessageBox(m_hWnd,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return false;									// Return false
	}
	
	if (m_bFullScreen)									// Attempt Fullscreen Mode?
	{
		DEVMODE dmScreenSettings;						// Device Mode
		memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));	// Makes Sure Memory's Cleared
		dmScreenSettings.dmSize		 = sizeof(dmScreenSettings);	// Size Of The Devmode Structure
		dmScreenSettings.dmPelsWidth  = nWidth;			// Selected Screen Width
		dmScreenSettings.dmPelsHeight = nHeight;		// Selected Screen Height
		dmScreenSettings.dmBitsPerPel = nBits;			// Selected Bits Per Pixel
		dmScreenSettings.dmFields	  = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

		// Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
		if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
		{
			// If The Mode Fails, Offer Two Options.  Quit Or Use Windowed Mode.
			if (MessageBox(m_hWnd,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
				m_bFullScreen = false;					// Windowed Mode Selected.  Fullscreen = false
			else
			{
				// Pop Up A Message Box Letting User Know The Program Is Closing.
				MessageBox(m_hWnd,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
				return false;							// Return false
			}
		}
	}

	if (m_bFullScreen)									// Are We Still In Fullscreen Mode?
	{
		dwExStyle = WS_EX_APPWINDOW;					// Window Extended Style
		dwStyle = WS_POPUP;								// Windows Style
		ShowCursor(false);								// Hide Mouse Pointer
	}
	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
0
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 ) )
					{
						pSock->GetNotify()->OnWriteReady();
					}
					else if( WAIT_EVENT_ACCEPT( wevt ) )
					{
						CKListenSocket* pListen = (CKListenSocket*)pSock;
						sockaddr_in sa;
						socklen_t salen = sizeof(sa);
						sockobj_t sock = accept( pListen->GetHandle(), (sockaddr*)&sa, &salen );
						if( INVALID_SOCKET != sock )
						{
#ifdef _WIN32
							// Cancel selections (they are inherited in Win32)
							::WSAEventSelect( sock, 0, 0 );
#endif
							CKTcpSocket* pNew = new CKTcpSocket();
							pNew->m_sock = sock;
							pListen->m_pAcceptNotify->OnConnection( pNew );
						}
					}
					else if( WAIT_EVENT_CONNECT( wevt ) )
					{
						pSock->GetNotify()->OnConnectDone( err );
					}
					else if( WAIT_EVENT_EXCEPT( wevt ) )
					{
						pSock->GetNotify()->OnExceptReady();
					}
				}
			}
		}
	}
	Exit();
}
CAAUParameter::CAAUParameter(AudioUnit au, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement element)
{
	memset(this, 0, sizeof(CAAUParameter));
	Init (au, param, scope, element);
}
示例#8
0
Water::Water(IDirect3DDevice9 *device, std::string fileName)
	:m_device(device)
{
	LoadWaterTexture(fileName);
	Init();
}
 Iterator() {
     Init();
 }
示例#10
0
文件: protocol.cpp 项目: 21coin/21
CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn)
{
    Init();
    nServices = nServicesIn;
}
示例#11
0
/**
Class constructor
*/
CDbStructure::CDbStructure()
	{
	Init();	
	}
示例#12
0
文件: protocol.cpp 项目: 21coin/21
CAddress::CAddress() : CService()
{
    Init();
}
示例#13
0
VBOSquare::VBOSquare(float size){
	Init();

	m_size = size;

}
示例#14
0
VBOSquare::VBOSquare(){
	Init();

}
示例#15
0
INLINE Dictionary<TKey, TValue>::Dictionary(Dictionary<TKey, TValue> const &dict) {
    Init();
    operator=(dict);
}
void SurfaceTextureBuffer::RestoreDeviceData()
{
	Init();
}
示例#17
0
INLINE void Dictionary<TKey, TValue>::Init(UInt32 const &len) {
    Init();                                                             // 先初始化自带 Buffer ,下面的代码再扩容
    Resize(len);
}
示例#18
0
// 支持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;
}
示例#19
0
文件: Asteroid.cpp 项目: BigEd/Cores
Asteroid::Asteroid()
{
	Init();
}
示例#20
0
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;
}
示例#21
0
CAAUParameter::CAAUParameter (AudioUnitParameter &inParam)
{
	memset(this, 0, sizeof(CAAUParameter));
	Init (inParam.mAudioUnit, inParam.mParameterID, inParam.mScope, inParam.mElement);
}
示例#22
0
void Splat::Reset() {
	splatCD.Reset(this, TRUE);	// reset all pb2's
	DeleteReference(2);
	DeleteReference(3);
	Init();
	}
示例#23
0
文件: crypto.cpp 项目: Jovasa/kvazaar
Crypto_Handle InitC(){
    AESDecoder* AESdecoder = Init();
    return AESdecoder;
}
示例#24
0
bool wxNativeFontInfo::FromUserString(const wxString& s)
{
    // reset to the default state
    Init();

    // ToUserString() will quote the facename if it contains spaces, commas
    // or semicolons: we must be able to understand that quoted text is
    // a single token:
    wxString toparse(s);

    // parse a more or less free form string
    wxStringTokenizer tokenizer(toparse, wxT(";, "), wxTOKEN_STRTOK);

    wxString face;
    unsigned long size;
    bool weightfound = false, pointsizefound = false;
#if wxUSE_FONTMAP
    bool encodingfound = false;
#endif
    bool insideQuotes = false;

    while ( tokenizer.HasMoreTokens() )
    {
        wxString token = tokenizer.GetNextToken();

        // normalize it
        token.Trim(true).Trim(false).MakeLower();
        if (insideQuotes)
        {
            if (token.StartsWith("'") ||
                token.EndsWith("'"))
            {
                insideQuotes = false;

                // add this last token to the facename:
                face += " " + token;

                // normalize facename:
                face = face.Trim(true).Trim(false);
                face.Replace("'", "");

                continue;
            }
        }
        else
        {
            if (token.StartsWith("'"))
                insideQuotes = true;
        }

        // look for the known tokens
        if ( insideQuotes )
        {
            // only the facename may be quoted:
            face += " " + token;
            continue;
        }
        if ( token == wxT("underlined") || token == _("underlined") )
        {
            SetUnderlined(true);
        }
        else if ( token == wxT("strikethrough") || token == _("strikethrough") )
        {
            SetStrikethrough(true);
        }
        else if ( token == wxT("light") || token == _("light") )
        {
            SetWeight(wxFONTWEIGHT_LIGHT);
            weightfound = true;
        }
        else if ( token == wxT("bold") || token == _("bold") )
        {
            SetWeight(wxFONTWEIGHT_BOLD);
            weightfound = true;
        }
        else if ( token == wxT("italic") || token == _("italic") )
        {
            SetStyle(wxFONTSTYLE_ITALIC);
        }
        else if ( token.ToULong(&size) )
        {
            SetPointSize(size);
            pointsizefound = true;
        }
        else
        {
#if wxUSE_FONTMAP
            // try to interpret this as an encoding
            wxFontEncoding encoding = wxFontMapper::Get()->CharsetToEncoding(token, false);
            if ( encoding != wxFONTENCODING_DEFAULT &&
                 encoding != wxFONTENCODING_SYSTEM )    // returned when the recognition failed
        {
            SetEncoding(encoding);
                encodingfound = true;
        }
            else
        {
#endif // wxUSE_FONTMAP

                // assume it is the face name
            if ( !face.empty() )
            {
                face += wxT(' ');
            }

            face += token;

            // skip the code which resets face below
            continue;

#if wxUSE_FONTMAP
        }
#endif // wxUSE_FONTMAP
        }

        // if we had had the facename, we shouldn't continue appending tokens
        // to it (i.e. "foo bold bar" shouldn't result in the facename "foo
        // bar")
        if ( !face.empty() )
        {
            wxString familyStr;
            if ( face.EndsWith(" family", &familyStr) )
            {
                // it's not a facename but rather a font family
                wxFontFamily family;
                if ( familyStr == "decorative" )
                    family = wxFONTFAMILY_DECORATIVE;
                else if ( familyStr == "roman" )
                    family = wxFONTFAMILY_ROMAN;
                else if ( familyStr == "script" )
                    family = wxFONTFAMILY_SCRIPT;
                else if ( familyStr == "swiss" )
                    family = wxFONTFAMILY_SWISS;
                else if ( familyStr == "modern" )
                    family = wxFONTFAMILY_MODERN;
                else if ( familyStr == "teletype" )
                    family = wxFONTFAMILY_TELETYPE;
                else
                    return false;

                SetFamily(family);
            }
            // NB: the check on the facename is implemented in wxFontBase::SetFaceName
            //     and not in wxNativeFontInfo::SetFaceName thus we need to explicitly
            //     call here wxFontEnumerator::IsValidFacename
            else if (
#if wxUSE_FONTENUM
                    !wxFontEnumerator::IsValidFacename(face) ||
#endif // wxUSE_FONTENUM
                    !SetFaceName(face) )
            {
                SetFaceName(wxNORMAL_FONT->GetFaceName());
            }

            face.clear();
        }
    }

    // we might not have flushed it inside the loop
    if ( !face.empty() )
    {
        // NB: the check on the facename is implemented in wxFontBase::SetFaceName
        //     and not in wxNativeFontInfo::SetFaceName thus we need to explicitly
        //     call here wxFontEnumerator::IsValidFacename
        if (
#if wxUSE_FONTENUM
                !wxFontEnumerator::IsValidFacename(face) ||
#endif // wxUSE_FONTENUM
                !SetFaceName(face) )
            {
                SetFaceName(wxNORMAL_FONT->GetFaceName());
            }
    }

    // set point size to default value if size was not given
    if ( !pointsizefound )
        SetPointSize(wxNORMAL_FONT->GetPointSize());

    // set font weight to default value if weight was not given
    if ( !weightfound )
        SetWeight(wxFONTWEIGHT_NORMAL);

#if wxUSE_FONTMAP
    // set font encoding to default value if encoding was not given
    if ( !encodingfound )
        SetEncoding(wxFONTENCODING_SYSTEM);
#endif // wxUSE_FONTMAP

    return true;
}
示例#25
0
文件: GL.cpp 项目: wernight/cuckoo
/*	This Code Creates Our OpenGL Window.  Parameters Are:
 *	lpszTitle		- Title to Appear at the Top of the Window
 *	hWndParent		- Parent HWND where the screne will be drawn
 *	nZBuffer		- Number of Bits to Use for Z-Buffer (16/32)
 */
bool CGL::Create(char* lpszTitle, HWND hWndParent, int nZBuffer=16) : m_bFullScreen(false)
{
	GLuint		PixelFormat;							// Holds The Results After Searching For A Match
	WNDCLASS	wc;										// Windows Class Structure
	DWORD		dwExStyle;								// Window Extended Style
	DWORD		dwStyle;								// Window Style
	RECT		rectWindow;								// Grabs Rectangle Upper Left / Lower Right Values
	int			nWidth,
				nHeight;

	// Get window size
	GetClientRect(hWndParent, &rectWindow);
	nWidth  = rectWindow.right-rectWindow.left;
	nHeight = rectWindow.bottom-rectWindow.top;

	m_hInstance			= GetModuleHandle(NULL);		// Grab An Instance For Our Window
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
	wc.lpfnWndProc		= (WNDPROC) WndProc;			// WndProc Handles Messages
	wc.cbClsExtra		= 0;							// No Extra Window Data
	wc.cbWndExtra		= 0;							// No Extra Window Data
	wc.hInstance		= m_hInstance;					// Set The Instance
	wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);	// Load The Default Icon
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);	// Load The Arrow Pointer
	wc.hbrBackground	= NULL;							// No Background Required For GL
	wc.lpszMenuName		= NULL;							// We Don't Want A Menu
	wc.lpszClassName	= "OpenGL";						// Set The Class Name

	if (!RegisterClass(&wc))							// Attempt To Register The Window Class
	{
		MessageBox(m_hWnd,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return false;									// Return false
	}
	
	dwExStyle = WS_EX_APPWINDOW;						// Window Extended Style
	//dwStyle = WS_OVERLAPPEDWINDOW;					// Windows Style
	dwStyle = WS_DISABLED | WS_VISIBLE | WS_CHILD;		// 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
}
示例#26
0
INLINE Dictionary<TKey, TValue>::Dictionary() {                                // 至少创建含有 Dictionary_OriginalNodeLength 个元素存放空间的 Buffer
    Init();
}
示例#27
0
ConnectArgsDialog::ConnectArgsDialog()
{
   Init();
}
示例#28
0
INLINE Dictionary<TKey, TValue>::Dictionary(UInt32 const &len) {
    assert ( sizeof(Byte*) + sizeof(Node) * len + sizeof(Node*) * len <= 0xFFFFFFFFu ); // x64下最多允许一次 new 出 4g 的内存空间
    if (len <= Dictionary_OriginalNodeLength)
        Init();
    Init(len);
}
dgCollisionCylinder::dgCollisionCylinder(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height)
	:dgCollisionConvex(allocator, signature, m_cylinderCollision)
{
	Init (radio0, radio1, height);
}
示例#30
0
Vertex::Vertex(void)
{
    Init(0.0f,0.0f,0.0f);
}