コード例 #1
0
ファイル: gl_framebuffer.cpp プロジェクト: CarlKenner/gz3doom
void OpenGLFrameBuffer::Update()
{
	if (!CanUpdate()) 
	{
		GLRenderer->Flush();
		return;
	}

	Begin2D(false);

	DrawRateStuff();
	GLRenderer->Flush();

	if (GetTrueHeight() != GetHeight())
	{
		if (GLRenderer != NULL) 
			GLRenderer->ClearBorders();

		Begin2D(false);
	}
	if (gl_draw_sync || !swapped)
	{
		Swap();
	}
	swapped = false;
	Unlock();
	CheckBench();
}
コード例 #2
0
ファイル: gl_framebuffer.cpp プロジェクト: CarlKenner/gz3doom
void OpenGLFrameBuffer::InitializeState()
{
	static bool first=true;

	if (first)
	{
		glewInit();
	}

	gl_LoadExtensions();
	Super::InitializeState();
	if (first)
	{
		first=false;
		// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
#ifdef _MSC_VER
		gl_PrintStartupLog();
#endif

	}
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glDepthFunc(GL_LESS);
	glShadeModel(GL_SMOOTH);

	glEnable(GL_DITHER);
	glEnable(GL_ALPHA_TEST);
	glDisable(GL_CULL_FACE);
	glDisable(GL_POLYGON_OFFSET_FILL);
	glEnable(GL_POLYGON_OFFSET_LINE);
	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_CLAMP_NV);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_LINE_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glAlphaFunc(GL_GEQUAL,0.5f);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	// This was to work around a bug in some older driver. Probably doesn't make sense anymore.
	glEnable(GL_FOG);
	glDisable(GL_FOG);

	glHint(GL_FOG_HINT, GL_FASTEST);
	glFogi(GL_FOG_MODE, GL_EXP);


	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int trueH = GetTrueHeight();
	int h = GetHeight();
	glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); 

	Begin2D(false);
	GLRenderer->Initialize();
}
コード例 #3
0
void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type)
{
	int w = SCREENWIDTH;
	int h = SCREENHEIGHT;

	ReleaseScreenshotBuffer();
	ScreenshotBuffer = new BYTE[w * h * 3];

	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer);
	glPixelStorei(GL_PACK_ALIGNMENT, 4);
	pitch = -w*3;
	color_type = SS_RGB;
	buffer = ScreenshotBuffer + w * 3 * (h - 1);
}
コード例 #4
0
ファイル: gl_framebuffer.cpp プロジェクト: Accusedbold/zdoom
void OpenGLFrameBuffer::InitializeState()
{
	static bool first=true;

	if (first)
	{
		ogl_LoadFunctions();
	}

	gl_LoadExtensions();
	Super::InitializeState();

	if (first)
	{
		first=false;
		gl_PrintStartupLog();
	}

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glDepthFunc(GL_LESS);

	glEnable(GL_DITHER);
	glDisable(GL_CULL_FACE);
	glDisable(GL_POLYGON_OFFSET_FILL);
	glEnable(GL_POLYGON_OFFSET_LINE);
	glEnable(GL_BLEND);
	glEnable(GL_DEPTH_CLAMP);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_LINE_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int trueH = GetTrueHeight();
	int h = GetHeight();
	glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); 

	Begin2D(false);
	GLRenderer->Initialize();
}
コード例 #5
0
ファイル: gl_framebuffer.cpp プロジェクト: CarlKenner/gz3doom
void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type)
{
	int w = SCREENWIDTH;
	int h = SCREENHEIGHT;

	ReleaseScreenshotBuffer();
	ScreenshotBuffer = new BYTE[w * h * 3];

	// Stereo3d might have an incomplete framebuffer bound, so unbind it for screenshot.
	int currentFramebuffer = 0;
	glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFramebuffer);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer);
	glPixelStorei(GL_PACK_ALIGNMENT, 4);
	pitch = -w*3;
	color_type = SS_RGB;
	buffer = ScreenshotBuffer + w * 3 * (h - 1);

	// Restore offscreen hud image, if any, for stereo 3d
	if (currentFramebuffer != 0)
		glBindFramebuffer(GL_FRAMEBUFFER, currentFramebuffer);
}