Gl Graph
Gl Graph Source of drawabledata.cpp
#include <drawabledata.h> #include "glscene.h" #include <GL/gl.h> #include <stdio.h> DrawableData::DrawableData() { debug=false; } DrawableData::~DrawableData() { } void DrawableData::init(GlScene * glScene) { this->glScene=glScene; this->glCamera=glScene->getCamera(); this->glVersion=glScene->getVersion(); init(); setChanged(); } void DrawableData::setColor(float c1,float c2,float c3) { color[0]=c1; color[1]=c2; color[2]=c3; } void DrawableData::setColor( int c1,int c2,int c3) { color[0]=c1/255.0f; color[1]=c2/255.0f; color[2]=c3/255.0f; } float DrawableData::getMaxSize() { float x = getMaxX() - getMinX(); float y = getMaxY() - getMinY(); float z = getMaxZ() - getMinZ(); return sqrt(x * x + y * y + z * z); } Vec3f DrawableData::getCenter() { float x = (getMaxX() - getMinX()) / 2; float y = (getMaxY() - getMinY()) / 2; float z = (getMaxZ() - getMinZ()) / 2; Vec3f v(x, y, z); return v; } void DrawableData::onClick(Vec3f &point,Vec3f &xvect,Vec3f &yvect,Vec3f &zvect) { if (debug) { std::cout << "onClick :point" << point << "xvect" << xvect << "yvect" << yvect << "zvect" << zvect << std::endl; } } void DrawableData::printGlError(const char *msg) { GLenum err=glGetError(); if (err==GL_NO_ERROR) return; else if (err==GL_INVALID_ENUM) printf("%s :GL_INVALID_ENUM\n",msg); else if (err==GL_INVALID_VALUE) printf("%s :GL_INVALID_VALUE\n",msg); else if (err==GL_INVALID_OPERATION) printf("%s :GL_INVALID_OPERATION\n",msg); else if (err==GL_INVALID_FRAMEBUFFER_OPERATION) printf("%s :GL_INVALID_FRAMEBUFFER_OPERATION\n",msg); else if (err==GL_OUT_OF_MEMORY) printf("%s :GL_OUT_OF_MEMORY\n",msg); else if (err==GL_STACK_UNDERFLOW) printf("%s :GL_STACK_UNDERFLOW\n",msg); else if (err==GL_STACK_OVERFLOW) printf("%s :GL_STACK_OVERFLOW\n",msg); else printf("%s :ERR %i\n",msg,err); }