MAIN
여행
지식
낙서연구
Q&A
정보구름
 



L I N K S
KURAPA.COM MAPS
세고비아 길버드 Blog
홈미디어센타 X-Revo
고구마킬러 ㄲㅏㄲㅣ
DaDa의 원초적 잡화
아하! 무진장 알뜰정보
바조의 짜바스크립
일하는엄마 - 워킹맘
네이버,구글맵 지도 검색
세상을 살아가며 궁금한것들
CTICKET - 인생의 쿠폰
Super Coder's Page
똑똑한 검색 ReportBank
MSN Web Messenger
포토웤스(PHOTOWORKS)

믹시
Scouter for KURAPA.COM

0


Translator
Francais (French) Deutsch (German) Espanol (Spanish) Italiano (Italian) Portugues (Portugese) 日本語 (Japanese) 한국말 (Korean) ??中文 (Chinese) العربية (Arabic) Русский язык (Russian) English



전체글 수: 1
DirectDraw 어플리케이션 구현
2008-01-03 15:19:42
CodeGuru를 탐험하던 도중 유용한 article이 있어 이를 복사한다. 이를 이용하면 간단하게 DirectDraw 어플리케이션을 구현 할 수 있었다.

첨부의 모듈을 이용하면 라이브러리 링크도 할 필요 없다. (지가 알아서 링크도 해주도록 원소스를 살짝 수정했음)

다음과 같은 순서로 프로그램을 만들어보도록 하자.

1. DirectX를 설치한다.

2. Tools -> include 디렉토리와 lib 디렉토리 세팅을 한다. (설치된 디렉토리로 친절하게 세팅해준다)

3. 다이얼로그 기반 MFC 어플리케이션을 생성한다.

4. 첨부의 파일을 생성된 프로젝트의 로컬 디렉토리에 복사하고 프로젝트에 추가 시킨다.

5. 메인어플리케이션 상단에
  1)   # include "DirecControl.h"를 선언한다
  2)   다음을 글로벌 베리어블로 선언한다.

       CDirectControl m_Control

  3)  InitInstance()모듈 알맹이를 싹 지우고 다음과 같이 모듈을 써준다.

BOOL CtestApp::InitInstance()
{
    m_pMainWnd = m_Control.CreateFullScreen(800,600,16);
    if (!m_pMainWnd)
        return FALSE;

    m_Control.CreateOffScreenSurface( (LPCTSTR)"1",IDB_BITMAP1);
    m_Control.GetSurface( (LPCTSTR)"1")->SetRender(TRUE);

    return TRUE;
}

  4)  OnIdle 이벤트를 메인 어플에 추가해준다. 그리고 하기와 같이 기술해 준다.

BOOL CtestApp::OnIdle(LONG lCount)
{
    MSG msg;
    if(::PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)){
        if (msg.message == WM_QUIT)
            PostQuitMessage(0);
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    m_Control.Render(TRUE,TRUE,TRUE);


---------------------

The code itself is fairly limited to displaying bitmaps on the screen (FULLSCREEN MODE) using DirectDraw but it shows the concepts of using wrappers to make your programs far easier to use. I could have put it all in a DLL but realised that this would not be simple for you all to use. Anyway, here is how you use the libraries.

1. Include the following header into your Application Header or StdAfx.h. E.g


#include "DirectControl.h"

2. Create an instance of the CDirectControl Object. For example:


CDirectControl m_Control;

Please note that this should be placed either as a global variable or inside the Application class header (i.e. not temporary)

3. In the App Init Instance call the following code:


 m_pMainWnd = m_Control.CreateFullScreen(800,600,16);

 if (!m_pMainWnd)

  return FALSE;

Replace the 800 and 600 with the required x & y resolutions that you want to use. Replace the 16 with the bits-per-pixel required. My program does not maintain or handle the Palette because I was only really using hi-color modes for

the bitmaps.

4. You can now use the Controller to create bitmaps (from the resource) using the code :


m_Control.CreateOffScreenSurface("My Bitmap",IDB_IMAGE);

The first parameter is the object identifier that I use to manipulate or select the object at a further time. The second parameter is the resource id of the bitmap.

You also need to tell the controller that the bitmap is available to be rendered. The default is false so you need to set the visibility by using the code:


m_Control.GetSurface("My Bitmap")->SetRender(TRUE);

5. The bitmaps are defaulted to the top left of the screen (x=0,y=0) but you can alter its position by using:


m_Control.GetSurface("My Bitmap")->SetPosition(10,10);

Relating to the x & y screen co-ordinates. The program automatically clips to the screen.

6. Once you have created your bitmap/s you can render the screen by calling:


 m_Control.Render(TRUE,FALSE,FALSE);

The first parameter decides if you want to clear the screen first before rendering. The second decides whether you want to render any bitmaps that have been flagged renderable. the third parameter decides whether you want to update the Screen. I did it this way because you dont want to update the screen all the time e.g. if you want to use one

bitmap , change its position and render it again then update the screen.

Ok. What I suggest is that you look at the example project I have done. If anyone wishes to expand it further etc. I would welcome and more additional source code or comments. Please dont laugh at my code. I just wanted Direct X to be easy for everyone. Enjoy.



추천 : 0, 조회 : 3,167
코멘트 0 | 트랙백 0 | 첨부파일 2
글자의 색상을 지정합니다 글자의 배경색상을 지정합니다
글자를 진하게 합니다 글자를 기울이게 합니다 밑줄을 긋습니다 취소선을 긋습니다
link를 만듭니다 이미지를 추가합니다 동영상/플래쉬등을 추가합니다 html 코드를 직접 입력합니다
이모티콘을 추가합니다 글박스를 만들거나 글숨김 기능을 추가합니다 html 코드를 직접 입력합니다
html모드로 변환합니다.
 
번호
제목
글쓴이
일자
추천
조회
1
2008-01-03
0
3,168


 
Copyright 2000-2008 KURAPA.COM All Rights Reserved.