void gameoverScene::render(void)
{
	//타임매니져 렌더
	//TIMEMANAGER->render(getMemDC());
	_bg->render(getMemDC(), 0, 0);
	
	if (_blindAlpha != 0.f) _blindImg->alphaRender(getMemDC(), 0, 0, 0, 0, WINSIZEX, WINSIZEY, false, (BYTE)_blindAlpha, false);


	this->getBackBuffer()->render(getHDC(), 0, 0);
}
Example #2
0
void gameStudy::render()
{
	//백버퍼에서 뿌려준다
	
	PatBlt(getMemDC(), 0, 0, WINSIZEX, WINSIZEY, WHITENESS);
	IMAGEMANAGER->findImage("background2")->render(getMemDC());
	//======================
	//이 사이에서 그려주면 됨.

	SCENEMANAGER->render();

	//======================
	//TIMEMANAGER->render(getMemDC());
	this->getBackBuffer()->render(getHDC(), 0, 0);
}
void MFCGraphicsOperations::makeOpenGLContextCurrent(os::Viewport* view, os::OpenGLContext* ctx)
{
	if (view == nullptr && ctx == nullptr)
	{
		if (!wglMakeCurrent(nullptr, nullptr))
		{
			mprintf(("Failed to make OpenGL context current!\n"));
		}
		return;
	}

	Assertion(view != nullptr, "Both viewport of context must be valid at this point!");
	Assertion(ctx != nullptr, "Both viewport of context must be valid at this point!");

	auto mfcCtx = reinterpret_cast<MFCOpenGLContext*>(ctx);
	auto mfcView = reinterpret_cast<MFCViewport*>(view);

	if (!wglMakeCurrent(mfcView->getHDC(), mfcCtx->getHandle()))
	{
		mprintf(("Failed to make OpenGL context current!\n"));
	}
}
std::unique_ptr<os::OpenGLContext> MFCGraphicsOperations::createOpenGLContext(os::Viewport* port, const os::OpenGLContextAttributes& ctx)
{
	auto mfcView = reinterpret_cast<MFCViewport*>(port);

	auto temp_ctx = wglCreateContext(mfcView->getHDC());
	if (!temp_ctx)
	{
		mprintf(("Unable to create fake context for OpenGL W32!\n"));
		return nullptr;
	}

	if (!wglMakeCurrent(mfcView->getHDC(), temp_ctx))
	{
		mprintf(("Unable to make current thread for OpenGL W32!\n"));
		if (!wglDeleteContext(temp_ctx))
		{
			mprintf(("Failed to delete render context!"));
		}
		return nullptr;
	}

	if (!gladLoadWGLLoader(gladWGLLoader, mfcView->getHDC()))
	{
		mprintf(("Failed to load WGL functions!\n"));
		wglMakeCurrent(nullptr, nullptr);
		if (!wglDeleteContext(temp_ctx))
		{
			mprintf(("Failed to delete render context!"));
		}
		return nullptr;
	}

	if (!GLAD_WGL_ARB_create_context)
	{
		// No support for 3.x
		if (ctx.major_version >= 3)
		{
			mprintf(("Can't create requested OpenGL context!\n"));
			wglMakeCurrent(nullptr, nullptr);
			if (!wglDeleteContext(temp_ctx))
			{
				mprintf(("Failed to delete fake context!"));
			}
			return nullptr;
		}
		// Major version is low enough -> just use the fake context
		return std::unique_ptr<os::OpenGLContext>(new MFCOpenGLContext(temp_ctx));
	}
	
	SCP_vector<int> attrib_list;
	attrib_list.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
	attrib_list.push_back(ctx.major_version);

	attrib_list.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
	attrib_list.push_back(ctx.minor_version);

	if (GLAD_WGL_ARB_create_context_profile)
	{
		attrib_list.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
		attrib_list.push_back(ctx.profile == os::OpenGLProfile::Core ?
			WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
	}

	int flags = 0;
	if (ctx.flags[os::OpenGLContextFlags::Debug])
	{
		flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
	}
	if (ctx.flags[os::OpenGLContextFlags::ForwardCompatible])
	{
		flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
	}
	if (flags != 0)
	{
		attrib_list.push_back(WGL_CONTEXT_FLAGS_ARB);
		attrib_list.push_back(flags);
	}

	attrib_list.push_back(0);

	auto attrib_ctx = wglCreateContextAttribsARB(mfcView->getHDC(), nullptr, attrib_list.data());

	// We don't need the fake context anymore
	wglMakeCurrent(nullptr, nullptr);
	if (!wglDeleteContext(temp_ctx))
	{
		mprintf(("Failed to delete fakse context!"));
	}
	
	if (attrib_ctx == nullptr)
	{
		mprintf(("Failed to create OpenGL context!\n"));
		return nullptr;
	}
	if (!wglMakeCurrent(mfcView->getHDC(), attrib_ctx))
	{
		mprintf(("Unable to make current thread for OpenGL W32!\n"));
		if (!wglDeleteContext(attrib_ctx))
		{
			mprintf(("Failed to delete render context!"));
		}
		return nullptr;
	}

	if (!gladLoadWGLLoader(gladWGLLoader, mfcView->getHDC()))
	{
		mprintf(("Failed to load WGL functions!\n"));
		wglMakeCurrent(nullptr, nullptr);
		if (!wglDeleteContext(temp_ctx))
		{
			mprintf(("Failed to delete render context!"));
		}
		return nullptr;
	}

	return std::unique_ptr<os::OpenGLContext>(new MFCOpenGLContext(attrib_ctx));
}