Пример #1
0
	bool BaseManager::create(int _width, int _height)
	{
		const unsigned int width = _width;
		const unsigned int height = _height;
		bool windowed = true;

		// регистрируем класс окна
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);

		// создаем главное окно
		hWnd = CreateWindow(wc.lpszClassName, TEXT("OpenGL3 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}

	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
		HINSTANCE instance = ::GetModuleHandleA(buf);
		HICON hIconSmall = static_cast<HICON>(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE));
		HICON hIconBig = static_cast<HICON>(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 256, 256, LR_DEFAULTSIZE));
		if (hIconSmall)
			::SendMessageA(hWnd, WM_SETICON, 0, (LPARAM)hIconSmall);
		if (hIconBig)
			::SendMessageA(hWnd, WM_SETICON, 1, (LPARAM)hIconBig);
	#endif

		hInstance = wc.hInstance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		if (!createRender(width, height, windowed))
		{
			return false;
		}

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Пример #2
0
	bool BaseManager::create()
	{
		const unsigned int width = 1024;
		const unsigned int height = 768;
		bool windowed = true;

		// регистрируем класс окна
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);

		// создаем главное окно
		hWnd = CreateWindow(wc.lpszClassName, TEXT("Direct3D9 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}

	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		// берем имя нашего экзешника
		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
		// берем инстанс нашего модуля
		HINSTANCE instance = ::GetModuleHandleA(buf);
		// побыстрому грузим иконку
		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
		}
	#endif

		hInstance = wc.hInstance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		createRender(width, height, windowed);

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Пример #3
0
	bool MyGUIRenderClick::create(IDirect3DDevice9 * pDevice)
	{
		createRender(pDevice);

		createGui();

		_windowResized();		

		return true;
	}
Пример #4
0
SynthComponent::SynthComponent(SynthScene* scene, const String& name, AudioComponent* audioComponent)
	: SynthObject(scene, name)
	, PROPERTY_INIT(position, Vector2::ZERO)
	, PROPERTY_INIT(localAabbMin, Vector2::ZERO)
	, PROPERTY_INIT(localAabbMax, Vector2::ZERO)
	, mAudioComponent(audioComponent)
	, mRenderNode(NULL)
	, mRenderRect(NULL)
	, mRenderText(NULL)
{
	createRender();

	// TODO update AABB

	propertyChangedEvent += Delegate<void(PropertyOwner*, PropertyBase*)>(this, &SynthComponent::onPropertyChanged);
}
Пример #5
0
	bool BaseManager::create(HWND hWnd)
	{

		this->hWnd = hWnd;

		createRender();

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		windowResized();

		return true;
	}
Пример #6
0
	bool BaseManager::create()
	{
		const unsigned int width = 1024;
		const unsigned int height = 768;
		bool windowed = true;

		mpHGE = hgeCreate(HGE_VERSION);
		if (!mpHGE)
			return false;

		mpHGE->System_SetState(HGE_WINDOWED, windowed);
		mpHGE->System_SetState(HGE_SCREENWIDTH, width);
		mpHGE->System_SetState(HGE_SCREENHEIGHT, height);
		mpHGE->System_SetState(HGE_USESOUND, false);
		mpHGE->System_SetState(HGE_HIDEMOUSE, false);
		mpHGE->System_SetState(HGE_SHOWSPLASH, true);
		mpHGE->System_SetState(HGE_FPS, 100);
		mpHGE->System_SetState(HGE_LOGFILE, "hge.log");
		mpHGE->System_SetState(HGE_FRAMEFUNC, frame);

		if (!mpHGE->System_Initiate())
			return false;
		
		hWnd = mpHGE->System_GetState(HGE_HWND);
		//hgeSprite			*portalSprite;
		//HTEXTURE hPortal = mpHGE->Texture_Load("resources/gems.png");
		//portalSprite = new hgeSprite(hPortal, 0, 31, 32, 32);
		//portalSprite->Render(0, 0);
		/*
		
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);


		hWnd = CreateWindow(wc.lpszClassName, TEXT("Direct3D9 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}
		*/
	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32

		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);

		HINSTANCE instance = ::GetModuleHandleA(buf);

		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
		}
	#endif

		hInstance = instance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		createRender(width, height, windowed);

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Пример #7
0
	bool BaseManager::create(int _width, int _height)
	{
		// initialize SDL
		if (SDL_Init(SDL_INIT_VIDEO) != 0)
		{
			std::cerr << "Failed to initialize SDL2.";
			exit(1);
		}
		// initialize SDL_image
#ifndef EMSCRIPTEN
		if (IMG_Init(~0) == 0)
		{
			std::cerr << "Failed to initialize SDL_image.";
			exit(1);
		}
#endif
		//chdir("/");
		SDL_Surface *image = nullptr;
		std::string fileName = "/MyGUI_Media/DejaVuSansFontGenerated_15.png";
		image = IMG_Load(fileName.c_str());
		if (image == nullptr)
		{
			std::cerr << "Failed to load " << fileName << " image" << std::endl;
			exit(-1);
		}
//		fileName = "test.png";
//		image = IMG_Load(fileName.c_str());
//		if (image == nullptr)
//		{
//			std::cerr << "Failed to load " << fileName << " image" << std::endl;
//			exit(-1);
//		}

		const unsigned int width = _width;
		const unsigned int height = _height;
		bool windowed = true;

		// create window and position it at the center of the screen
		SDL_DisplayMode currDisp;
		MYGUI_ASSERT(SDL_GetCurrentDisplayMode(0, &currDisp) == 0, "Failed to retrieve screen info.");
		int left = (currDisp.w - width) / 2;
		int top = (currDisp.h - height) / 2;

		mWindow = SDL_CreateWindow("OpenGLES Render Window", left, top, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
		MYGUI_ASSERT(mWindow != nullptr, "Failed to create SDL window.");
		mContext = SDL_GL_CreateContext(mWindow);
		MYGUI_ASSERT(mContext != nullptr, "Failed to create SDL context.");
		mWindowOn = true;

		if (!createRender(width, height, windowed))
		{
			return false;
		}

		createGui();

		createInput();

		createPointerManager();

		// this needs to be called before createScene() since some demos require
		// screen size to properly position the widgets
		_windowResized(width, height);

		createScene();

		return true;
	}