summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Fischer <tjfischer98@gmail.com>2018-06-10 16:37:40 +0200
committerUli Schlachter <psychon@znc.in>2018-06-10 16:37:40 +0200
commit97dc700ee637decc53c3b43fac4311dc88d65040 (patch)
tree04045ad3882faae6a461ae2ef8207e7be24c4da2
parent1019b266a4e7cc0e8e7d1a271cd85a2a364cb3ff (diff)
Improve opengl tutorial
Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r--opengl.mdwn28
1 files changed, 26 insertions, 2 deletions
diff --git a/opengl.mdwn b/opengl.mdwn
index 4573512..bc64ba3 100644
--- a/opengl.mdwn
+++ b/opengl.mdwn
@@ -51,6 +51,28 @@ To maintain backward compatibility and providing an incremental porting path, th
#include <GL/glx.h>
#include <GL/gl.h>
+ /*
+ Attribs filter the list of FBConfigs returned by glXChooseFBConfig().
+ Visual attribs further described in glXGetFBConfigAttrib(3)
+ */
+ static int visual_attribs[] =
+ {
+ GLX_X_RENDERABLE, True,
+ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_ALPHA_SIZE, 8,
+ GLX_DEPTH_SIZE, 24,
+ GLX_STENCIL_SIZE, 8,
+ GLX_DOUBLEBUFFER, True,
+ //GLX_SAMPLE_BUFFERS , 1,
+ //GLX_SAMPLES , 4,
+ None
+ };
+
void draw()
{
glClearColor(0.2, 0.4, 0.9, 1.0);
@@ -95,15 +117,17 @@ To maintain backward compatibility and providing an incremental porting path, th
{
int visualID = 0;
- /* Query framebuffer configurations */
+ /* Query framebuffer configurations that match visual_attribs */
GLXFBConfig *fb_configs = 0;
int num_fb_configs = 0;
- fb_configs = glXGetFBConfigs(display, default_screen, &num_fb_configs);
+ fb_configs = glXChooseFBConfig(display, default_screen, visual_attribs, &num_fb_configs);
if(!fb_configs || num_fb_configs == 0)
{
fprintf(stderr, "glXGetFBConfigs failed\n");
return -1;
}
+
+ printf("Found %d matching FB configs", num_fb_configs);
/* Select first framebuffer config and query visualID */
GLXFBConfig fb_config = fb_configs[0];