기본 콘텐츠로 건너뛰기

라벨이 Processing인 게시물 표시

Data Conversions

Data Conversions By VGirish  | 28 Jun 2002 These are a few samples of data conversions which you can use for a quick reference Introduction Here are a few data conversions with small examples :- Decimal Conversions Decimal To Hex  Collapse // Use _itoa( ) function and set radix to 16. char hexstring[ 10 ]; int number = 30 ; itoa( number, hexstring, 16 ); // In hexstring is 1e. Hex To Decimal  Collapse // You can use strtol function and you can specify base. char * hexstring= " ABCDEF" ; char * p; int number = strtol(hexstring, &p, 16 ); // A function that does this bool HexToDecimal ( char * HexNumber, int& Number) { char * pStopString; Number = strtol (HexNumber, &pStopString, 16 ); return ( bool )(Number != LONG_MAX); } Decimal to time  Collapse char *DecToTime( float fTime, char *szTime) { int nHrs, nMin, nSec; fTime *= 3600 ; nHrs = ( int )fTime / 3600 ; nMin = ( int )(fTime - nHrs * 3600 ) / 60...

[MFC]SHBrowseForFolder 폴더를 선택

[code cpp] BROWSEINFO bi; TCHAR szDir[MAX_PATH]; LPITEMIDLIST pidl; LPMALLOC pMalloc; if (SUCCEEDED(SHGetMalloc(&pMalloc))) { ZeroMemory(&bi,sizeof(bi)); bi.hwndOwner = this->m_hWnd; // GetDlgItem(IDC_MYGROUPBOX1)->m_hWnd; // bi.hwndOwner = NULL; bi.pszDisplayName = 0; bi.pidlRoot = 0; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; bi.lpfn = NULL;//BrowseCallbackProc; pidl = SHBrowseForFolder(&bi); if (pidl) { if (SHGetPathFromIDList(pidl,szDir)) { GetDlgItem(IDC_EDIT_FOLDER)->SetWindowText(szDir); // MessageBox(szDir,"Picked",MB_OK); } // In C++: pMalloc->Free(pidl); pMalloc->Release(); pMalloc->Free(pidl); pMalloc->Release(); } } [/code]

[XML]Quick notes on how to use RapidXML

There’s a C++ XML library called RapidXML which is perfect for most non-enterprise uses of XML. I wouldn’t call this a tutorial, but I hope this ends up helping someone. The documentation isn’t very explicit on how to output an XML declaration, for example. How to create your XML from scratch and then output this XML into a string, with an XML declaration: [code xml]<?xml version="1.0" encoding="utf-8"?> <rootnode version="1.0" type="example">   <childnode/> </rootnode>[/code][code cpp]using namespace rapidxml;   xml_document<> doc;   // xml declaration xml_node<>* decl = doc.allocate_node(node_declaration); decl->append_attribute(doc.allocate_attribute("version", "1.0")); decl->append_attribute(doc.allocate_attribute("encoding", "utf-8")); doc.append_node(decl);   // root node xml_node<>* root = doc.allocate_node(node_element, "rootnode"); root-...

프로그래머에게 유용한 사이트들

OpenGL 오픈지엘 - 오픈지엘 공식 사이트, 생각외로 뉴스가 잘 올라온다. NeHe Tutorial - OpenGL Tutorial. 내용도 좋지만, 각 플랫폼, 언어별로 구현된 소스가 유용. OpenGL man page - OpenGL MAN 페이지. 일종의 매뉴얼. OpenGL Manual - SGI 의 OpenGL 1.2 매뉴얼 GL4Java - 자바를 위한 OpenGL OpenGL Win32 Tutorial - OpenGL Win32 Toturial GLUT3 - glut3 소스 및 다운로드. glut for win32 - Glut for Win32 DLL Download OpenGL Gamedev - OpenGL Gamedev FAQ & Mailing list cannon_smash - OpenGL 로 만든 오픈소스 탁구게임 OpenGL FAQ - OpenGL FAQ OpenGL Reference Manual - 온라인북 OpenGL Programming Guide - 온라인북 OpenGL 수퍼 바이블 - 온라인북 OpenGL 튜토리얼 링크 - OpenGL 튜토리얼 링크 OpenGL 게임개발 FAQ - OpenGL 게임개발 FAQ GLVelocity - OpenGL 관련 소스 및 뉴스, 토론 등등 DelphiGL - Delphi 로 하는 OpenGL Yindo - 차세대 웹 애플리케이션 Dip2K's OpenGL - 여러 GL 관련 예제가 있는 국내 OpenGL 관련 사이트 GLScene - OpenGL Solution for Delphi FLTK - OpenGL 그래픽 유저인터페이스 라이브러리(LGPL) Quesa - Apple Quick Draw 3D Open-source Implementation GLdomain - 파티클, 그라비티 등에 관한 튜토리얼 게임튜토리얼 - 오픈지엘 튜토리얼 및 MP3 라이브러리, 쓰레드 예제 등등이 있다. Delphi3D - 델파이와 OpenGL를 사용한 최신 그래픽 기술에 관한 정보   ...

MFC::Class 접근

CTestApp, CMainFrame, CTestDoc, CTestView ◎ CTestApp에서 CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CTestDoc* pDoc = (CTestDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument(); CTestView* pView = (CTestView*)((CMainFrame*)AfxGetMainWnd())->GetActiveView(); ◎ CMainFrame에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CTestDoc* pDoc = (CTestDoc*)GetActiveDocument(); CTestView* pView = (CTestView*)GetActiveView(); ◎ CTestDoc에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); CTestView* pView = (CTestView*)((CMainFrame*)AfxGetMainWnd())->GetActiveView(); ◎ CTestView에서 CTestApp* pApp = (CTestApp*)AfxGetApp(); CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();             or (CMainFrame*)GetParent(); CTestDoc* pDoc = (CTestDoc*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument();          or (CTestDoc*)GetDocument();

윈도우 상에서 시간 측정하기

이 글은 마이크로소프트웨어 99 년 2 월의 " 이보다 더 정확할 순 없다 ! 윈도우 환경에서 시간측정하는법 " 이란 기사에서 참고한 것입니다 .   윈도우 상에서 시간 측정하기     윈도우 상에서 시간을 측정하기 위한 방법에는 몇가지가 있는데 , clock() 함수를 사용하거나 WM_TIMER 메시지를 사용한다거나 , 일반 타이머보다 더 높은 정확도를 위해 멀티미디어 타이머를 사용할 수 있다 . clock() 함수를 사용하는 방법은 "C/C++ 관련 내용 " 의 " 정렬 (Sort)" 부분에서 볼 수 있다 . WM_TIMER 의 경우는 초당 클럭수가 18.3 이므로 1/18.3 즉 , 약 55 ms 정도의 정확도를 가진다 . 그리고 멀티미디어 타이머의 경우는 최소시간 간격이 1ms 이고 , 10ms 이내의 이벤트 지연시간을 가지는 타이머 이벤트는 CPU 자원을 많이 소모하기 때문에 주의해야 한다 . 앞서 설명한 멀티미디어 타이머는 최소 시간간격이 1ms 로 , 그 이하의 시간을 측정하는데는 적합하지 않다 . 더구나 CPU 의 성능이 높아지면서 1ms 는 무척 긴 시간이 돼 버렸다 . 1ms 동안 많은 명령을 수행할 수 있기 때문에 네트웍 패킷의 전송시간이나 특정 루틴의 시간을 측정하기 위해서는 멀티미디어 타이머는 도움이 되지 않는다 . 이러한 경우에 Win32 API 에서 제공하는 QueryPerformanceFrequency 와 QueryPerformanceCounter , 이 두 개의 함수가 유용하게 쓰인다 .  QueryPerformanceFrequency 는 1 초 동안 카운터가 증가하는 값을 얻어내는데 , 시스템이 이 두 함수들을 지원하지 않으면 QueryPerformanceFrequency 의 값이 0 이 되고 결과값도 0 이 돌아온다 . 다음 코드는 VC++ 에서 카운터를 사용한 예이다 . //------------...