Gl Graph
Gl Graph Source of glimagerenderer.cpp
#include "glimagerenderer.h" GlImageRenderer::GlImageRenderer(unsigned int width,unsigned int height) : GlRenderer(width,height,debug) { this->filename=std::string("out.png"); this->scene= new GlScene(width,height); } GlImageRenderer::GlImageRenderer(unsigned int width,unsigned int height,std::string filename) : GlRenderer(width,height,false) { this->filename=filename; this->scene= new GlScene(width,height); } static int singleBufferAttributess[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 1, /* Request a single buffered color buffer */ GLX_GREEN_SIZE, 1, /* with the maximum number of color bits */ GLX_BLUE_SIZE, 1, /* for each component */ None }; void GlImageRenderer::init(DrawableSet * set) { /* Open a connection to the X server */ dpy = XOpenDisplay(NULL); if (dpy == NULL) { printf("Unable to open a connection to the X server\n"); exit(EXIT_FAILURE); } /* Request a suitable framebuffer configuration - try for a double ** buffered configuration first */ fbConfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), singleBufferAttributess, &numReturned); if (fbConfigs == NULL) { printf("glXChooseFBConfig Failed\n"); } /* Create a GLX context for OpenGL rendering */ context = glXCreateNewContext(dpy, fbConfigs[0], GLX_RGBA_TYPE, NULL, True); /* Create a Pbuffer*/ int attrib_list[5]; attrib_list[0]= GLX_PBUFFER_WIDTH; attrib_list[1]= this->width; attrib_list[2]= GLX_PBUFFER_HEIGHT; attrib_list[3]= this->height; attrib_list[4]= None; GLXPbuffer glxBuff = glXCreatePbuffer (dpy, fbConfigs[0], (int *)&attrib_list); glXMakeContextCurrent(dpy, glxBuff, glxBuff, context); int argc = 0; glutInit(&argc, 0); scene->setKeepProportionXY(true); scene->init(set); set->init(this->scene); } void GlImageRenderer::run() { scene->updateView(); scene->setOpenglPojectionMatrix(); scene->clearBuffer(); scene->loadIdentity(); scene->drawText(); scene->setOpenglModelViewMatrix(); scene->draw(); writePng(); }