1. 엔진 초기화.

engine-1.jpg



목표 :
신규 프로젝트를 생성하여 엔진의 생성과 소멸을 각 단계별로 알아본다.
엔진 초기화에 필요한 각 함수들의 원리를 파악한다.


결과 :
신규프로젝트 를 통해 엔진의 생성과 소멸을 익힌다.


엔진생성 과 소멸.

1> epp_enginecore.h 파일을 include 하고, engine 라이브러리 를 링크 한다.
; 라이브러리 링크는 멀티스래드용 엔진라이브러리와 싱글스래드용 엔진라이브러리를 링크 할 수 있다.

#include "..\\epp_include\\epp_enginecore.h"
#ifdef _DEBUG
        #ifdef _THREAD
                 #pragma comment(lib, "..\\epp_lib\\eppenginecore_mtd.lib")
         #else
                  #pragma comment(lib, "..\\epp_lib\\eppenginecore_d.lib")
         #endif
#else
         #ifdef _THREAD
                  #pragma comment(lib, "..\\epp_lib\\eppenginecore_mt.lib")
         #else
                  #pragma comment(lib, "..\\epp_lib\\eppenginecore.lib")
         #endif
#endif

2> namespace EPP 선언.

3> 엔진의 인스턴스를 생성.
; bool      create_engine_core();

4> 엔진 create 함수를 호출하여 엔진 내부의 각종 manager 들을 생성한다.
; bool      g_engine_core.create(); 

5> g_engine_core.simulate_physic_scene(0); 함수 호출
;내부적으로 물리 시뮬레이션을 시작한다는 의미. 이 함수를 호출 하지 않을경우 어플리케이션 종료시
스래드가 종료되지 않아서 스래드의 종료를 계속해서 기다리는 현상이 나타난다.

6> 엔진의 인스턴스를 삭제하기 전에 destroy 함수를 호출하여, 엔진 내부의 각종 manager 들을 소멸시킨다.
; void      g_engine_core.destroy();

7> 엔진의 인스턴스를 삭제 한다.
; void      destroy_engine_core();


실제 소스코드

--- 생성 --
bool create()
{
            if(!create_engine_core()) return false;

            if( !g_engine_core.create(m_hWnd,false, true, true) ){
                      g_engine_core.destroy();
                     destroy_engine_core();
                      return false;
            }

            g_engine_core.simulate_physic_scene(0);

            return true;
 }

--- 소멸 --
void destroy()
{
           g_engine_core.destroy();
           destroy_engine_core();
}

Download
engine_core_create.cpp


* PARAMETER
bool create(HWND p_hWnd, bool p_bMemload = false, bool p_bWindow = true, 
                     bool p_bPresentationInterval = false, bool p_bCreateScreen = true, int p_nWidth = -1, int p_nHeight = -1);

; engine_core 를 생성하는 함수.
p_hWnd : 윈도우 핸들
p_bMemload : 패킹된 리소스파일(엔진에서 제공되는 패킹형태) 에서 파일들을 로드할 경우.
p_bWindow : 창모드 혹은 전체화면 모드 설정.
p_bPresentionInterval : 수직동기화 설정. false 이면 수직동기 설정.
p_bCreateScreen : rendering buffer 를 생성할경우 true 를 설정. (화면효과나 각종 화면이펙트 사용시 true 설정한다.)
p_nWidth : 생성될 rendering buffer 의 가로 크기. (-1 이면 자동으로 윈도우 크기만큼 설정)
p_nHeight : 생성될 rendering buffer 의 세로 크기. (-1 이면 자동으로 윈도우 크기만큼 설정)