[Bf-blender-cvs] [bad8b91fd3c] blender2.8: Correct core profile way of getting color depth

Dalai Felinto noreply at git.blender.org
Fri May 19 14:18:15 CEST 2017


Commit: bad8b91fd3c7c6f458f0830520b21fe628565cf2
Author: Dalai Felinto
Date:   Fri May 19 14:10:10 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBbad8b91fd3c7c6f458f0830520b21fe628565cf2

Correct core profile way of getting color depth

===================================================================

M	source/blender/gpu/intern/gpu_extensions.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index fb6c2ef9b6e..b1876e93876 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -163,15 +163,24 @@ void gpu_extensions_init(void)
 	glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GG.maxubosize);
 
 #ifdef WITH_LEGACY_OPENGL
-	GLint r, g, b;
 	glGetIntegerv(GL_RED_BITS, &r);
 	glGetIntegerv(GL_GREEN_BITS, &g);
 	glGetIntegerv(GL_BLUE_BITS, &b);
-	GG.colordepth = r + g + b; /* assumes same depth for RGB */
 #else
-	GG.colordepth = 24; /* cheat. */
-	/* TODO: get this value another way */
+#ifndef NDEBUG
+	GLint ret;
+	glBindFramebuffer(GL_FRAMEBUFFER, 0);
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &ret);
+	/* We expect FRONT_LEFT to be the default buffer. */
+	BLI_assert(ret == GL_NONE);
+#endif
+
+	GLint r, g, b;
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &r);
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, &g);
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, &b);
 #endif
+	GG.colordepth = r + g + b; /* Assumes same depth for RGB. */
 
 	if (GLEW_VERSION_3_2 || GLEW_ARB_texture_multisample) {
 		glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);




More information about the Bf-blender-cvs mailing list