Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: client/deps/glbench/src/glx_stuff.cc

Issue 1168005: Initialization cleanups and couple other minor things: (Closed)
Patch Set: fixes Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/deps/glbench/src/egl_stuff.cc ('k') | client/deps/glbench/src/teartest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/glx_stuff.cc
diff --git a/client/deps/glbench/src/glx_stuff.cc b/client/deps/glbench/src/glx_stuff.cc
index 57b481dd17814bd00ee044b3bad2d89d8fe23b07..758ea29346bb74206d75c94045c9bbb30654567b 100644
--- a/client/deps/glbench/src/glx_stuff.cc
+++ b/client/deps/glbench/src/glx_stuff.cc
@@ -3,11 +3,12 @@
// found in the LICENSE file.
#include <string.h>
+#include <GL/glx.h>
#include "main.h"
#include "xlib_window.h"
-GLXContext glx_context = NULL;
+static GLXContext glx_context = NULL;
#define F(fun, type) type fun = NULL;
LIST_PROC_FUNCTIONS(F)
@@ -17,24 +18,33 @@ bool Init() {
return XlibInit();
}
+VisualID GetVisualID() {
+ int screen = DefaultScreen(xlib_display);
+ int attrib[] = {
+ GLX_DOUBLEBUFFER, True,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DEPTH_SIZE, 1,
+ GLX_STENCIL_SIZE, 1,
+ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+ None
+ };
+ int nelements;
+ GLXFBConfig *fbconfigs = glXChooseFBConfig(xlib_display, screen,
+ attrib, &nelements);
+ CHECK(nelements >= 1);
+ int visual_id;
+ glXGetFBConfigAttrib(xlib_display, fbconfigs[0], GLX_VISUAL_ID, &visual_id);
+ XFree(fbconfigs);
+ return static_cast<VisualID>(visual_id);
+}
+
bool InitContext() {
- XWindowAttributes attributes;
- XGetWindowAttributes(xlib_display, xlib_window, &attributes);
- XVisualInfo visual_info_template;
- visual_info_template.visualid = XVisualIDFromVisual(attributes.visual);
- int visual_info_count = 0;
- XVisualInfo *visual_info_list = XGetVisualInfo(xlib_display, VisualIDMask,
- &visual_info_template,
- &visual_info_count);
- glx_context = 0;
- for (int i = 0; i < visual_info_count; ++i) {
- glx_context = glXCreateContext(xlib_display, visual_info_list + i, 0, True);
- if (glx_context) break;
- }
- XFree(visual_info_list);
- if (!glx_context) {
+ glx_context = glXCreateContext(xlib_display, xlib_visinfo, 0, True);
+ if (!glx_context)
return false;
- }
+
if (!glXMakeCurrent(xlib_display, xlib_window, glx_context)) {
glXDestroyContext(xlib_display, glx_context);
return false;
« no previous file with comments | « client/deps/glbench/src/egl_stuff.cc ('k') | client/deps/glbench/src/teartest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698