#1. Engine System
+ WinMain - EngineSystem (현재 글)
+ EngineCore
+ EngineError
+ MainNode
#2. FrameWork
+ Grahpics
+ Image - SpriteData
+ Layer
+ Input
+ Game
+ Manager
+ Game Interface
+ Utility
#3. Testing Module
+ 2D Image Test
+ 2D Animation Test
+ Game UI Test
-----------------------------------------------------------------------
이번 글에서는 엔진이 시작하기 까지의 Main 함수의 구성과 Engine System Class에 대해서 살펴보도록 하겠습니다.
아래의 winMain을 살펴보시면 간단하게 다음과 같습니다.
#include "stdafx.h" | |
// winmain.cpp : 응용 프로그램에 대한 진입점을 정의합니다. | |
#define _CRTDBG_MAP_ALLOC // for detecting memory leaks | |
#define WIN32_LEAN_AND_MEAN | |
#include <stdlib.h> // for detecting memory leaks | |
#include <crtdbg.h> // for detecting memory leaks | |
#include "engineSystem.h" | |
// Function prototypes | |
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int); | |
EngineSystem engine; | |
//global | |
HWND g_hWndEngine = nullptr; | |
Graphics* g_Graphics = nullptr; | |
MainNode* g_MainNode = nullptr; | |
WNDCLASSEX g_wcx; | |
bool g_EngineShutDown = false; | |
//============================================================================= | |
// Starting point for a Windows application | |
//============================================================================= | |
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, | |
LPSTR lpCmdLine, int nCmdShow) | |
{ | |
// Check for memory leak if debug build | |
#if defined(DEBUG) | defined(_DEBUG) | |
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); | |
#endif | |
if (!engine.engineStart(hInstance, nCmdShow)) | |
return 1; | |
return engine.run(); | |
} |
메인의 구성은 간단하게 EngineSystem Class 하나를 갖고 있고
WINAPI WinMain( ) 함수가 실행되면서 프로그램의 진입점이 정의되어 있습니다.
그리고 그 외 갖가지 글로벌 변수들에 대한 초기화가 이루어져 있습니다.
글로벌 변수들에 대한 설명은 추후 stdafx.h (미리 컴파일 된 헤더) 를 설명 할때 같이 설명하도록 하겠습니다.
// Check for memory leak if debug build
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
는 메무리 누수가 발생했을 시 디버그 모드 환경에서 결과를 출력하기 위해 사용하는 함수 입니다.
프로그램이 종료 시 프로젝트에서 누수 된 메모리 주소영역들이 우르르 나오게 됩니다.
해당 누수 된 메모리를 체이스 하는 방법에 대해서는 별도의 글로 적어놓도록 하겠습니다.
if (!engine.engineStart(hInstance, nCmdShow))
return 1;
위와 같이 EngineStart 함수를 호출하고 return 받은 값이 true 이면
아래의 return engine.run();
함수를 호출하여 엔진을 Run 시킵니다.
이번 글에서는 간단히 메인만 남겨두고 계속해서 다음 글로 적어나가도록 하겠습니다.
(왠만하면 클래스 별로 글을 나눠서 올릴 예정입니다)
'MyProject > SephyEngine' 카테고리의 다른 글
June_Engine #1_EngineError.h (0) | 2017.04.07 |
---|---|
June_Engine #1_EngineCore.cpp (2) (0) | 2017.04.07 |
June_Engine #1_EngineCore.h (1) (0) | 2017.04.06 |
June_Engine #1_EngineSystem (0) | 2017.04.06 |
June_Engine #1_메뉴얼(Manual) (0) | 2017.04.05 |