DirectDraw 어플리케이션 구현

31433 
Created at 2008-01-04 00:19:09 
251   0   0   0  
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.


Tags: DirectDraw DirectDraw Sample Source DirectDraw 샘플 DirectX DirectX 게임 기본 소스 DirectX 게임 프로그래밍 DirectX 어플리케이션 샘플 윈도우즈 Share on Facebook Share on X

◀ PREVIOUS
정규식으로 문자열 바꿔주기
▶ NEXT
mysql의 백업과 복구 (backup & restore)
  Comments 0
Login for comment
SIMILAR POSTS

파이어폭스에서 이전 세션 사용여부를 묻는 다이얼로그 안뜨게 하기 (created at 2008-02-14)

윈도우즈 PC에 SVN설치하여 협업환경 구성하는 방법 (created at 2008-02-19)

WindowsXP에서 공유기 없이 PC를 이용한 인터넷 연결 공유 하는 방법 (created at 2008-03-27)

블로그를 쉽게 할 수 있도록 도와주는 블로깅툴 - Windows Live Writer (created at 2007-10-10)

인터넷익스플로러 로딩속도 향샹법 (created at 2008-04-10)

오류 보고(MS전송)창 나타나지 않게 하기 (created at 2008-04-10)

입력도구모음 없애기 (created at 2008-04-10)

<시작>에서 문서메뉴 삭제하기 (created at 2008-04-10)

폴더창 속도향상하기 (created at 2008-04-10)

다운로드 갯수 변경하는 방법 (created at 2008-04-10)

<시작>에서 도움말메뉴 삭제하기 (created at 2008-04-10)

윈도우 창이 뜨는 속도 높이기 (created at 2008-04-10)

TComboBox Readonly로 만드는 방법 (created at 2007-08-09)

마이크로소프트 윈도우7 (WIndows 7) 미공개 바탕화면 (created at 2007-08-09)

비스타에 이은 마이크로소프트 윈도우 차기 버전「윈도우 7」 (created at 2007-08-09)

쓰기 불편해 XP로 U턴하는 이용자 늘어, 윈도비스타 '징검다리 OS' 되나 (created at 2007-08-09)

델파이에서 URL Encoding 하는 방법 (created at 2007-08-09)

한글을 유니코드 또는 UTF-8포멧으로 변환하는 방법 (created at 2007-08-09)

듀얼모니터를 쓸때 태스크바가 하나 밖에 없어서 불편했던 사람들을 위한 - 듀얼모니터용 프로그램 울트라몬 (UltraMon) (created at 2007-08-08)

유니코드를 안시로, 안시를 유니코드로 변환하는 방법 (created at 2008-06-14)

Exchange Server 인증서 때문에 Windows Mobile 디바이스와 ActiveSync가 되지 않는 경우 해결법 (created at 2007-07-24)

FindFirstFileEx를 이용하여 폴더 내의 파일 찾아내기 (created at 2008-06-16)

PC 부팅할때 Num Lock 키 해제하는 방법 (created at 2007-07-21)

MFC에서 디스크 포멧(Disk Format)하기 (created at 2007-07-20)

소켓을 생성하여 CSocket에 Attach하는 방법 (created at 2007-07-19)

소켓 프로그래밍 기본 흐름 - Socket Programming Basic Flow (created at 2007-07-16)

OWL(One World Language)의 다른 종류 (created at 2007-07-11)

OWL(One World Language)은 무엇인가? (created at 2007-07-11)

온톨로지(ontology)란 무엇인가? (created at 2007-07-11)

웹페이지 속도 빠르게 하는 방법 10가지 (created at 2007-06-21)

OTHER POSTS IN THE SAME CATEGORY

특정 디스크 드라이브 숨기기 및 엑세스 금지하게 하기 (created at 2008-04-10)

WindowsXP에서 공유기 없이 PC를 이용한 인터넷 연결 공유 하는 방법 (created at 2008-03-27)

윈도우즈 PC에 SVN설치하여 협업환경 구성하는 방법 (created at 2008-02-19)

파이어폭스에서 이전 세션 사용여부를 묻는 다이얼로그 안뜨게 하기 (created at 2008-02-14)

iso8601 포멧으로 time string 만들기 (created at 2008-02-13)

배열(array)을 문자열(string)으로 만들어주는 친절한 함수 (created at 2008-02-11)

문자열(string)을 배열(array)로 만들어주는 방법 (created at 2008-02-11)

웹서버 데몬 업그래이드 (created at 2008-02-10)

정규식 (Regular Expression) 특수문자 처리 (created at 2008-01-30)

특정 포탈에서 접속한 사용자만 접속 막는 방법 (created at 2008-01-16)

정규식(Regular Expression) 표현 방법 및 예제 (created at 2008-01-15)

RegExp 사용법 (created at 2008-01-15)

윈도우 환경에서 mysql 자동 백업하기 (created at 2008-01-04)

shell script를 이용한 mysql 자동 백업(backup) (created at 2008-01-04)

mysql의 백업과 복구 (backup & restore) (created at 2008-01-04)

정규식으로 문자열 바꿔주기 (created at 2007-12-18)

윈도우 버젼 쉽게 알아보기 (created at 2007-12-06)

xp 예약종료 하는 명령어 (created at 2007-12-06)

단축키로 웹페이지에 접속하기 (created at 2007-12-06)

절대 보이지 않는 숨김 파일 및 폴더 표시 (created at 2007-12-06)

마우스 움직임 속도 빠르게 하는 방법 (created at 2007-12-06)

컴퓨터에서 전기가 흐를때 (created at 2007-12-06)

데몬 SCSI 오류 OR 재부팅오류 해결법입니다 (created at 2007-12-06)

Windows 임시 폴더 자동 삭제 (created at 2007-12-06)

XP에서 Internet Explorer 다시 설치 방법 (created at 2007-12-06)

응용프로그램을 빠르게 실행하자 (created at 2007-12-06)

기존 비밀번호 몰라도 사용자의 암호 변경방법 (created at 2007-12-06)

로그인 비번 잊어먹었을때 (created at 2007-12-06)

간단하게 배워보는 DOS 명령어 (created at 2007-12-06)

Windows 부팅시 속도 향상시키는 방법 (created at 2007-12-06)

UPDATES

글루코사민 vs. 콘드로이친: 무엇이 더 나은 관절 건강 보조제일까? (created at 2024-04-22)

광주 5·18 민주화운동 알린 테리 앤더슨 前 AP 기자 (created at 2024-04-22)

햄과 소세지가 우리 몸에 일으키는 부작용 (updated at 2024-04-22)

콘드로이친의 염증 감소효과 (updated at 2024-04-22)

코사민 DS - 글루코사민+콘드로이친 복합물이 함유된 퇴행성 관절 건강보조제 (updated at 2024-04-22)

삼겹살 먹을때 환상조합 (created at 2024-04-22)

일본 여중생의 특이한 취향 (created at 2024-04-22)

우리가 먹는 약물이 바꿔버린 생태계 (created at 2024-04-21)

일본에서 그린 상상속의 사무직과 현실속의 사무직 (updated at 2024-04-21)

북한 미대생들이 그린 북한 최고존엄 김정은 (created at 2024-04-21)

입사 후 1년도 되지 않은 회사에서 구조조정에 의한 퇴직 불응에 따른 해고 처리시 대응 가능한 방법 (updated at 2024-04-20)

한고은님의 옛날 사진 (updated at 2024-04-20)

소녀대 - Bye Bye Girl (updated at 2024-04-13)

대한민국 날씨 근황 (created at 2024-04-13)

성일종 인재육성 강조하며 이토 히로부미 언급 - 인재 키운 선례? (updated at 2024-04-13)

일제강점기가 더 살기 좋았을지도 모른다는 조수연 국민의힘 후보 - 친일파? (updated at 2024-04-13)

Marshall Ha님의 샤오미 SU7 시승기 - 테슬라의 일론 머스크님이 긴장할만한 느낌 (updated at 2024-04-09)

윙크하는 귀염둥이 반려견들 (created at 2024-04-08)

달콤 살벌한 고백 (created at 2024-04-08)

북한 최정예 공수부대 훈련 모습 (updated at 2024-04-02)

맛있었던 친구 어머니의 주먹밥이 먹고 싶어요 (created at 2024-04-02)

자리 마음에 안든다고 6급 공무원 패는 농협 조합장 (created at 2024-03-26)

85세 딸 짜장면 사주는 102세 어머니 (created at 2024-03-26)

1990년대 감각파 도둑 (created at 2024-03-26)

치매에 걸린 69살의 브루스 윌리스가 전부인 데미무어를 보고 한 말 (updated at 2024-03-22)

경제는 대통령이 살리는 것이 아닙니다 라던 윤석열대통령 - 상황 안좋아지자 여러 전략을 펼쳤지만, 부작용 속출했던 2024년의 봄 (updated at 2024-03-13)

극빈의 생활을 하고 배운것이 없는 사람은 자유가 뭔지도 모를 뿐 아니라 왜 개인에게 필요한지에 대한 필요성을 못느낀다는 윤석열 대통령 (updated at 2024-03-08)

조선일보를 안본다는 사람들이 말하는 그 이유 - 천황폐하, 전두환 각하, 김일성 장군 만세? (created at 2024-03-07)

광폭타이어를 장착하면 성능이 좋아질거라는 착각 (updated at 2024-03-03)

면허시험장에서 면허갱신하면 하루만에 끝나나? (updated at 2024-03-03)