From 06891ebb351142829f30470a056cfe07ad8cfe63 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Mon, 12 Oct 2015 20:17:34 +1000 Subject: [PATCH] OSMesaMakeCurrent for glewCreateContext in GLEW_OSMESA mode. --- auto/src/glewinfo_tail.c | 13 +++++++++++++ src/visualinfo.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/auto/src/glewinfo_tail.c b/auto/src/glewinfo_tail.c index 1774de7..1999b06 100644 --- a/auto/src/glewinfo_tail.c +++ b/auto/src/glewinfo_tail.c @@ -159,10 +159,23 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params) #if defined(GLEW_OSMESA) OSMesaContext ctx; +static const GLint osmFormat = GL_UNSIGNED_BYTE; +static const GLint osmWidth = 640; +static const GLint osmHeight = 480; +static GLubyte *osmPixels = NULL; + GLboolean glewCreateContext (struct createParams *params) { ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); if (NULL == ctx) return GL_TRUE; + if (NULL == osmPixels) + { + osmPixels = (GLubyte *) calloc(osmWidth*osmHeight*4, 1); + } + if (!OSMesaMakeCurrent(ctx, osmPixels, GL_UNSIGNED_BYTE, osmWidth, osmHeight)) + { + return GL_TRUE; + } return GL_FALSE; } diff --git a/src/visualinfo.c b/src/visualinfo.c index 2cd000a..c24bbaf 100644 --- a/src/visualinfo.c +++ b/src/visualinfo.c @@ -1022,11 +1022,24 @@ void InitContext (GLContext* ctx) ctx->ctx = NULL; } +static const GLint osmFormat = GL_UNSIGNED_BYTE; +static const GLint osmWidth = 640; +static const GLint osmHeight = 480; +static GLubyte *osmPixels = NULL; + GLboolean CreateContext (GLContext* ctx) { if (NULL == ctx) return GL_TRUE; ctx->ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); if (NULL == ctx->ctx) return GL_TRUE; + if (NULL == osmPixels) + { + osmPixels = (GLubyte *) calloc(osmWidth*osmHeight*4, 1); + } + if (!OSMesaMakeCurrent(ctx->ctx, osmPixels, GL_UNSIGNED_BYTE, osmWidth, osmHeight)) + { + return GL_TRUE; + } return GL_FALSE; }