gpucalc::GLGraphicCore Class Reference

Declaration of OpenGL GraphicCore. More...

#include <gl_graphic_core.h>

Inheritance diagram for gpucalc::GLGraphicCore:

Inheritance graph

List of all members.

Public Member Functions

void addAcceptableShaderSystemID (const std::string &ShaderSystemID)
 Method for manual adding acceptable ShaderSystem ID.
void bind (FrameBuffer *framebuffer)
void bind (Texture *texture)
void checkErrors (const std::string &where)
 Perform error checking.
FrameBuffercreate (const std::string &FrameBufferName)
 Creates FrameBuffer with given name.
Texturecreate (const std::string &TextureName, TextureUsage Usage)
 Creates Texture with given name and type of usage.
void destroy (FrameBuffer *fb)
 Delete framebuffer and free memeory in GPU-side.
void destroy (Texture *texture)
 Delete texture and free memory in GPU-side.
void draw (float TexCoordX, float TexCoordY)
 Draw quad with given texture coords.
FrameBuffergetActiveFrameBuffer () const
 Returns active FrameBuffer.
TexturegetActiveTexture () const
const std::string & getClassName () const
 Returns name of class of our object.
FrameBuffergetFrameBufferByName (const std::string &FrameBufferName) const
 Finds and return previously created FrameBuffer.
const std::string & getObjectName () const
 Returns name of our object.
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
TexturegetTextureByName (const std::string &TextureName) const
 Finds and return previously created Texture.
Vendor getVendor () const
 Returns vendor type.
 GLGraphicCore ()
void initialize (const Data &data, Texture &texture)
 Reinitalizes previously created texture with new Data.
bool isAcceptSystem (const ShaderSystem *System) const
 Check for ShaderSystem acceptance.
bool isFrameBufferCreated (const std::string &FrameBufferName) const
 Check for existence.
bool isLocked () const
 returns state of object.
bool isTextureCreated (const std::string &TextureName) const
 Check for existence.
GLint maxFramebufferAttachmentPoints () const
 Returns maximal number of attachment points.
GLint maxTextureSize () const
 Returns maximal size of texture.
void setMatrixMode (float Width, float Height)
 Setting up model view matrices, setting up viewport for correct rendering quad.
void start (int argc, char *argv[])
 Starts our GraphicCore.
void stop ()
 Stops our GraphicCore.
void unbind (FrameBuffer *framebuffer)
void unbind (Texture *texture)
 ~GLGraphicCore ()

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Private Types

typedef std::set< std::string > AcceptableShaderSystemIDSet
typedef std::map< std::string,
GLFrameBuffer * > 
GLFrameBufferMap
 Defines type for our framebuffer storage.
typedef std::map< std::string,
GLTexture * > 
GLTextureMap
 Defines type for our texture storage.

Private Member Functions

void ConvertToATITexture (const Data &data, GLTexture &texture)
void ConvertToNVTexture (const Data &data, GLTexture &texture)
void ConvertToTexture (const Data &data, GLTexture &texture)
Vendor FindCorrectVendor (const std::string &GLVendorString)

Private Attributes

AcceptableShaderSystemIDSet mAcceptableShaderSystemIDSet
FrameBuffermActiveFrameBuffer
TexturemActiveTexture
float mGLDefaultHeight
float mGLDefaultWidth
GLFrameBufferMap mGLFrameBufferMap
 Stores all framebuffers.
GLint mGLMaxFrameBufferAttachmentPoints
GLint mGLMaxTextureSize
GLTextureMap mGLTextureMap
 Stores all textures.
int mGLUTWindow
Vendor mGLVendor
bool mIsStarted

Friends

class GLGraphicCorePlugin


Detailed Description

Declaration of OpenGL GraphicCore.

Todo:
Create GPU-side timer, using extension GL_EXT_timer_query.

Definition at line 77 of file gl_graphic_core.h.


Member Typedef Documentation

typedef std::set<std::string> gpucalc::GLGraphicCore::AcceptableShaderSystemIDSet [private]

Definition at line 233 of file gl_graphic_core.h.

typedef std::map<std::string, GLFrameBuffer *> gpucalc::GLGraphicCore::GLFrameBufferMap [private]

Defines type for our framebuffer storage.

Definition at line 222 of file gl_graphic_core.h.

typedef std::map<std::string, GLTexture *> gpucalc::GLGraphicCore::GLTextureMap [private]

Defines type for our texture storage.

Definition at line 208 of file gl_graphic_core.h.


Constructor & Destructor Documentation

gpucalc::GLGraphicCore::GLGraphicCore (  ) 

gpucalc::GLGraphicCore::~GLGraphicCore (  ) 

Definition at line 59 of file gl_graphic_core.cpp.

00060  {
00061   if (mIsStarted)
00062   {
00063    stop();
00064   }
00065  }


Member Function Documentation

void gpucalc::GLGraphicCore::addAcceptableShaderSystemID ( const std::string &  ShaderSystemID  )  [virtual]

Method for manual adding acceptable ShaderSystem ID.

This method is useful when we use specific ShaderSystem with ID different from standart ids.

Implements gpucalc::GraphicCore.

Definition at line 432 of file gl_graphic_core.cpp.

00433  {
00434   mAcceptableShaderSystemIDSet.insert(ShaderSystemID);
00435  }

void gpucalc::Object::addSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue,
size_t  Size 
) [inline, protected, inherited]

Definition at line 254 of file object.h.

00255    {
00256     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00257     if (i != mSpecificParameters.end())
00258     {
00259      mSpecificParameters.erase(i);
00260     }
00261     mSpecificParameters[ParameterName] = Any(ParameterValue, Size);
00262    }

void gpucalc::GLGraphicCore::bind ( FrameBuffer framebuffer  )  [virtual]

Implements gpucalc::GraphicCore.

Definition at line 334 of file gl_graphic_core.cpp.

00335  {
00336   assert(framebuffer && "FrameBuffer does not created!!!");
00337   if (framebuffer != mActiveFrameBuffer)
00338   {
00339    GLFrameBuffer * glFrameBuffer = static_cast<GLFrameBuffer *>(framebuffer);
00340    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glFrameBuffer->mGLFrameBufferID);
00341    mActiveFrameBuffer = framebuffer;
00342   }
00343  }

void gpucalc::GLGraphicCore::bind ( Texture texture  )  [virtual]

Implements gpucalc::GraphicCore.

Definition at line 310 of file gl_graphic_core.cpp.

00311  {
00312   assert(texture && "Texture does not created!!!");
00313   if (texture != mActiveTexture)
00314   {
00315    GLTexture * glTexture = static_cast<GLTexture *>(texture);
00316    glBindTexture(glTexture->getGLTextureTarget(), glTexture->getGLTextureID());
00317    mActiveTexture = texture;
00318   }
00319  }

void gpucalc::GLGraphicCore::checkErrors ( const std::string &  where  )  [virtual]

Perform error checking.

Parameters:
where - string contains name of function, which calls this method.

Implements gpucalc::GraphicCore.

Definition at line 357 of file gl_graphic_core.cpp.

00358  {
00359   GLenum err_code = glGetError();
00360   switch (err_code)
00361   {
00362    case GL_NO_ERROR:
00363     return;
00364 
00365    case GL_INVALID_ENUM:
00366        Except<ERR_RENDERINGAPI_ERROR>(this, "Enum argument out of range!", where, __FILE__, __LINE__);
00367     return;
00368 
00369    case GL_INVALID_VALUE:
00370     Except<ERR_RENDERINGAPI_ERROR>(this, "Numeric argument out of range!", where, __FILE__, __LINE__);
00371     return;
00372 
00373    case GL_INVALID_OPERATION:
00374     Except<ERR_RENDERINGAPI_ERROR>(this, "Operation illegal in current state!", where, __FILE__, __LINE__);
00375     return;
00376 
00377    case GL_STACK_OVERFLOW:
00378     Except<ERR_RENDERINGAPI_ERROR>(this, "Command would cause a stack overflow!", where, __FILE__, __LINE__);
00379     return;
00380 
00381    case GL_STACK_UNDERFLOW:
00382     Except<ERR_RENDERINGAPI_ERROR>(this, "Command would cause a stack underflow!", where, __FILE__, __LINE__);
00383     return;
00384 
00385    case GL_OUT_OF_MEMORY:
00386     Except<ERR_RENDERINGAPI_ERROR>(this, "Not enough memory left to execute command!", where, __FILE__, __LINE__);
00387     return;
00388 
00389    case GL_TABLE_TOO_LARGE:
00390     Except<ERR_RENDERINGAPI_ERROR>(this, "The specified table is too large!", where, __FILE__, __LINE__);
00391     return;
00392 
00393    default:
00394     Except<ERR_RENDERINGAPI_ERROR>(this, "Unknown error or no error!", where, __FILE__, __LINE__);
00395     return;
00396   }
00397  }

void gpucalc::GLGraphicCore::ConvertToATITexture ( const Data data,
GLTexture texture 
) [private]

Definition at line 580 of file gl_graphic_core.cpp.

00581  {
00582   assert(mIsStarted && "GLGraphicCore is not started!!!");
00583   switch (data.getNumberOfComponents())
00584   {
00585    case 1:
00586     texture.mGLTextureFormat = GL_LUMINANCE;
00587     break;
00588     
00589    case 2:
00590     texture.mGLTextureFormat = GL_LUMINANCE_ALPHA;
00591     break;
00592 
00593    case 3:
00594     texture.mGLTextureFormat = GL_RGB;
00595     break;
00596 
00597    case 4:
00598     texture.mGLTextureFormat = GL_RGBA;
00599     break;
00600 
00601    default:
00602     Except<ERR_INVALIDPARAMS>(this, "Wrong number of components!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00603     break;
00604   }
00605 
00606 
00607   switch (data.getArrayDataType())
00608   {
00609    case Array1D:
00610     texture.mGLTextureTarget = GL_TEXTURE_1D;
00611     break;
00612     
00613    case Array2D:
00614     texture.mGLTextureTarget = GL_TEXTURE_RECTANGLE_ARB; // it is the same value that GL_TEXTURE_RECTANGLE_NV
00615     break;
00616 
00617    case Array3D:
00618     texture.mGLTextureTarget = GL_TEXTURE_3D;
00619     break;
00620 
00621    default:
00622     Except<ERR_INVALIDPARAMS>(this, "Wrong array data type!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00623     break;
00624   }
00625 
00626 
00627   switch (data.getValueType())
00628   {
00629    case FloatType:
00630     texture.mGLTextureType = GL_FLOAT;
00631     switch (texture.getNumberOfComponents())
00632     {
00633      case 1:
00634       texture.mGLTextureInternalFormat = GL_LUMINANCE_FLOAT32_ATI;
00635       break;
00636 
00637      case 2:
00638       texture.mGLTextureInternalFormat = GL_LUMINANCE_ALPHA_FLOAT32_ATI;
00639       break;
00640 
00641      case 3:
00642       texture.mGLTextureInternalFormat = GL_RGB_FLOAT32_ATI;
00643       break;
00644 
00645      case 4:
00646       texture.mGLTextureInternalFormat = GL_RGBA_FLOAT32_ATI;
00647       break;
00648 
00649      default:
00650       break;
00651     }
00652     break;
00653 
00654 
00655    case UnsignedCharType:
00656     texture.mGLTextureType = GL_UNSIGNED_BYTE;
00657     switch (texture.getNumberOfComponents())
00658     {
00659      case 1:
00660       texture.mGLTextureInternalFormat = GL_LUMINANCE8;
00661       break;
00662 
00663      case 2:
00664       texture.mGLTextureInternalFormat = GL_LUMINANCE8_ALPHA8;
00665       break;
00666 
00667      case 3:
00668       texture.mGLTextureInternalFormat = GL_RGB8;
00669       break;
00670 
00671      case 4:
00672       texture.mGLTextureInternalFormat = GL_RGBA8;
00673       break;
00674 
00675      default:
00676       break;
00677     }
00678     break;
00679 
00680 
00681    default:
00682     Except<ERR_NOT_IMPLEMENTED>(this, "ValueType is not implemented!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00683     break;
00684   }
00685  }

void gpucalc::GLGraphicCore::ConvertToNVTexture ( const Data data,
GLTexture texture 
) [private]

Definition at line 471 of file gl_graphic_core.cpp.

00472  {
00473   assert(mIsStarted && "GLGraphicCore is not started!!!");
00474   switch (data.getNumberOfComponents())
00475   {
00476    case 1:
00477     texture.mGLTextureFormat = GL_LUMINANCE;
00478     break;
00479     
00480    case 2:
00481     texture.mGLTextureFormat = GL_LUMINANCE_ALPHA;
00482     break;
00483 
00484    case 3:
00485     texture.mGLTextureFormat = GL_RGB;
00486     break;
00487 
00488    case 4:
00489     texture.mGLTextureFormat = GL_RGBA;
00490     break;
00491 
00492    default:
00493     Except<ERR_INVALIDPARAMS>(this, "Wrong number of components!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00494     break;
00495   }
00496 
00497 
00498   switch (data.getArrayDataType())
00499   {
00500    case Array1D:
00501     texture.mGLTextureTarget = GL_TEXTURE_1D;
00502     break;
00503     
00504    case Array2D:
00505     texture.mGLTextureTarget = GL_TEXTURE_RECTANGLE_NV;
00506     break;
00507 
00508    case Array3D:
00509     texture.mGLTextureTarget = GL_TEXTURE_3D;
00510     break;
00511 
00512    default:
00513     Except<ERR_INVALIDPARAMS>(this, "Wrong array data type!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00514     break;
00515   }
00516 
00517 
00518   switch (data.getValueType())
00519   {
00520    case FloatType:
00521     texture.mGLTextureType = GL_FLOAT;
00522     switch (texture.getNumberOfComponents())
00523     {
00524      case 1:
00525       texture.mGLTextureInternalFormat = GL_FLOAT_R32_NV;
00526       break;
00527       
00528      case 2:
00529       texture.mGLTextureInternalFormat = GL_FLOAT_RG32_NV;
00530       break;
00531       
00532      case 3:
00533       texture.mGLTextureInternalFormat = GL_FLOAT_RGB32_NV;
00534       break;
00535 
00536      case 4:
00537       texture.mGLTextureInternalFormat = GL_FLOAT_RGBA32_NV;
00538       break;
00539       
00540      default:
00541       Except<ERR_INVALIDPARAMS>(this, "Wrong number of components!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00542       break;
00543     }
00544     break;
00545 
00546 
00547    case UnsignedCharType:
00548     texture.mGLTextureType = GL_UNSIGNED_BYTE;
00549     switch (texture.getNumberOfComponents())
00550     {
00551      case 1:
00552       texture.mGLTextureInternalFormat = GL_LUMINANCE8;
00553       break;
00554       
00555      case 2:
00556       texture.mGLTextureInternalFormat = GL_LUMINANCE8_ALPHA8;
00557       break;
00558       
00559      case 3:
00560       texture.mGLTextureInternalFormat = GL_RGB8;
00561       break;
00562 
00563      case 4:
00564       texture.mGLTextureInternalFormat = GL_RGBA8;
00565       break;
00566       
00567      default:
00568       break;
00569     }
00570     break;
00571 
00572 
00573    default:
00574     Except<ERR_NOT_IMPLEMENTED>(this, "ValueType is not implemented!", "GLDataConverter::ToNVTexture", __FILE__, __LINE__);
00575     break;
00576   }
00577  }

void gpucalc::GLGraphicCore::ConvertToTexture ( const Data data,
GLTexture texture 
) [private]

Definition at line 438 of file gl_graphic_core.cpp.

00439  {
00440   assert(mIsStarted && "GLGraphicCore is not started!!!");
00441   texture.mGLPointer = data.pointer();
00442 
00443   texture.mActualLengthGPU = data.getActualLengthCPU() / data.getNumberOfComponents();
00444   texture.mDimension = data.getArrayDataType();
00445   texture.mNumberOfComponents = data.getNumberOfComponents();
00446   texture.mTypeSize = data.getTypeSize();
00447 
00448   texture.mSizeX = data.getSizeX();
00449   texture.mSizeY = data.getSizeY();
00450   texture.mSizeZ = data.getSizeZ();
00451 
00452   switch (this->getVendor())
00453   {
00454    case NVIDIA:
00455    case MESA:
00456    case GDI:
00457     ConvertToNVTexture(data, texture);
00458     break;
00459 
00460    case ATI:
00461     ConvertToATITexture(data, texture);
00462     break;
00463 
00464    default:
00465     Except<ERR_NOT_IMPLEMENTED>(this, "Vendors different from ATI, NVIDIA, MESA or GDI are not implemented!",
00466      "GLDataConverter::ConvertToTexture()", __FILE__, __LINE__);
00467   }
00468  }

FrameBuffer * gpucalc::GLGraphicCore::create ( const std::string &  FrameBufferName  )  [virtual]

Creates FrameBuffer with given name.

Parameters:
FrameBufferName - name of our framebuffer.

Implements gpucalc::GraphicCore.

Definition at line 235 of file gl_graphic_core.cpp.

00236  {
00237   assert(mIsStarted && "GLGraphicCore is not started!!!");
00238   GLFrameBufferMap::iterator i = mGLFrameBufferMap.find(FrameBufferName);
00239 
00240   if (i != mGLFrameBufferMap.end())
00241   {
00242    Except<ERR_DUPLICATE_ITEM>(this, "FrameBuffer object with name \"" + FrameBufferName + "\" already exists!",
00243     "GLGraphicCore::createFrameBuffer()", __FILE__, __LINE__);
00244    return 0;
00245   }
00246   else
00247   {
00248    GLFrameBuffer * Result = new GLFrameBuffer(FrameBufferName, static_cast<unsigned int>(mGLMaxFrameBufferAttachmentPoints), this);
00249    Result->initialize();
00250    mGLFrameBufferMap.insert(std::make_pair(FrameBufferName, Result));
00251    LogManager::getSingleton().logMessage(this, "Framebuffer object \"" + FrameBufferName + "\" created.", LML_Trivial);
00252    return Result;
00253   }
00254  }

Texture * gpucalc::GLGraphicCore::create ( const std::string &  TextureName,
TextureUsage  Usage 
) [virtual]

Creates Texture with given name and type of usage.

Parameters:
TextureName - name for our texture
Usage - defines usage of texture: as simple storage of our data, or render target.

Implements gpucalc::GraphicCore.

Definition at line 185 of file gl_graphic_core.cpp.

00186  {
00187   assert(mIsStarted && "GLGraphicCore is not started!!!");
00188   GLTextureMap::iterator i = mGLTextureMap.find(TextureName);
00189   if (i != mGLTextureMap.end())
00190   {
00191    Except<ERR_DUPLICATE_ITEM>(this, "Texture object with name \"" + TextureName + "\" already exists!",
00192     "GLGraphicCore::create()", __FILE__, __LINE__);
00193    return 0;
00194   }
00195   else
00196   {
00197    GLTexture * Result = new GLTexture(TextureName, Usage, this);
00198    mGLTextureMap.insert(GLTextureMap::value_type(TextureName, Result));
00199    LogManager::getSingleton().logMessage(this, "Texture object \"" + TextureName + "\" created.", LML_Trivial);
00200    return Result;
00201   }
00202  }

void gpucalc::GLGraphicCore::destroy ( FrameBuffer fb  )  [virtual]

Delete framebuffer and free memeory in GPU-side.

Implements gpucalc::GraphicCore.

Definition at line 295 of file gl_graphic_core.cpp.

00296  {
00297   assert(mIsStarted && "GLGraphicCore is not started!!!");
00298   if (!removeFromContainer(fb->getObjectName(), mGLFrameBufferMap))
00299   {
00300    Warning<ERR_INVALIDPARAMS>(this, "FrameBuffer object \"" + fb->getObjectName() + "\" was created outside GLGraphicCore!",
00301     "GLGraphicCore::deleteFrameBuffer", __FILE__, __LINE__);
00302 
00303   }
00304   std::string name = fb->getObjectName();
00305   delete fb;
00306   LogManager::getSingleton().logMessage(this, "FrameBuffer \"" + name + "\" deleted.", LML_Trivial);
00307  }

void gpucalc::GLGraphicCore::destroy ( Texture texture  )  [virtual]

Delete texture and free memory in GPU-side.

Implements gpucalc::GraphicCore.

Definition at line 281 of file gl_graphic_core.cpp.

00282  {
00283   assert(mIsStarted && "GLGraphicCore is not started!!!");
00284   if (!removeFromContainer(texture->getObjectName(), mGLTextureMap))
00285   {
00286    Warning<ERR_INVALIDPARAMS>(this, "Texture object \"" + texture->getObjectName() + "\" was created outside GLGraphicCore!!! Destroying anyway.",
00287     "GLGraphicCore::deleteTexture", __FILE__, __LINE__);
00288   }
00289   std::string name = texture->getObjectName();
00290   delete texture;
00291   LogManager::getSingleton().logMessage(this, "Texture \"" + name + "\" deleted.", LML_Trivial);
00292  }

void gpucalc::GLGraphicCore::draw ( float  TexCoordX,
float  TexCoordY 
) [virtual]

Draw quad with given texture coords.

Parameters:
TexCoordX - X texture coordinate.
TexCoordY - Y texture coordinate.
We must set up coorect texture coordinate, because shader must know how to read data from texture samplers. Usually we use 1:1 correlation between texture coords and size of rendering window.

Implements gpucalc::GraphicCore.

Definition at line 166 of file gl_graphic_core.cpp.

00167  {
00168   assert(mIsStarted && "GLGraphicCore is not started!!!");
00169   glBegin(GL_QUADS);
00170   {
00171    glTexCoord2f(0.0f, 0.0f);   glVertex2f(0.0f, 0.0f);
00172    glTexCoord2f(TexCoordX, 0.0f);  glVertex2f(mGLDefaultWidth, 0.0f);
00173    glTexCoord2f(TexCoordX, TexCoordY); glVertex2f(mGLDefaultWidth, mGLDefaultHeight);
00174    glTexCoord2f(0.0f, TexCoordY);  glVertex2f(0.0f, mGLDefaultHeight);
00175   }
00176   glEnd();
00177   glFlush();
00178   glFinish();
00179   this->checkErrors("GLGraphicCore::draw()");
00180   LogManager::getSingleton().logMessage(this, "Texture coords: " +
00181    auxillary::StringUtil::toString(TexCoordX) + " X " + auxillary::StringUtil::toString(TexCoordY), LML_Trivial);
00182  }

Vendor gpucalc::GLGraphicCore::FindCorrectVendor ( const std::string &  GLVendorString  )  [private]

Definition at line 400 of file gl_graphic_core.cpp.

00401  {
00402   if (!(auxillary::StringUtil::toLower(GLVendorString).find("nvidia") == std::string::npos))
00403   {
00404    return NVIDIA;
00405   }
00406 
00407   if (!(auxillary::StringUtil::toLower(GLVendorString).find("ati") == std::string::npos))
00408   {
00409    return ATI;
00410   }
00411 
00412   if (!(auxillary::StringUtil::toLower(GLVendorString).find("mesa") == std::string::npos))
00413   {
00414    return MESA;
00415   }
00416 
00417   if (!(auxillary::StringUtil::toLower(GLVendorString).find("gdi") == std::string::npos))
00418   {
00419    return GDI;
00420   }
00421 
00422   return DEFAULT;
00423  }

FrameBuffer* gpucalc::GLGraphicCore::getActiveFrameBuffer (  )  const [inline, virtual]

Returns active FrameBuffer.

Implements gpucalc::GraphicCore.

Definition at line 124 of file gl_graphic_core.h.

00125    {
00126     return mActiveFrameBuffer;
00127    }

Texture* gpucalc::GLGraphicCore::getActiveTexture (  )  const [inline, virtual]

Implements gpucalc::GraphicCore.

Definition at line 106 of file gl_graphic_core.h.

00107    {
00108     return mActiveTexture;
00109    }

const std::string& gpucalc::Object::getClassName (  )  const [inline, inherited]

Returns name of class of our object.

Definition at line 92 of file object.h.

00093    {
00094     return mClassName;
00095    }

FrameBuffer * gpucalc::GLGraphicCore::getFrameBufferByName ( const std::string &  FrameBufferName  )  const [virtual]

Finds and return previously created FrameBuffer.

Implements gpucalc::GraphicCore.

Definition at line 257 of file gl_graphic_core.cpp.

00258  {
00259   assert(mIsStarted && "GLGraphicCore is not started!!!");
00260   GLFrameBufferMap::const_iterator i = mGLFrameBufferMap.find(FrameBufferName);
00261   if (i != mGLFrameBufferMap.end())
00262   {
00263    return i->second;
00264   }
00265   else
00266   {
00267    Except<ERR_ITEM_NOT_FOUND>(this, "FrameBuffer with name \"" + FrameBufferName + "\" does not exists!",
00268     "GLGraphicCore::getFrameBufferByName()", __FILE__, __LINE__);
00269    return 0;
00270   }
00271  }

const std::string& gpucalc::Object::getObjectName (  )  const [inline, inherited]

Returns name of our object.

Definition at line 101 of file object.h.

00102    {
00103     return mObjectName;
00104    }

void gpucalc::Object::getSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue 
) [inline, inherited]

Method for obtaining some specific parameters, such as texture specific params, and so on.

Parameters:
ParameterName - name of parameter, usually it similar to specific method of some object (for example, GLTextureID)
ParameterValue - contain value of named parameter, it must be allocated and have sufficient size.
Todo:
Think for better realization.

Definition at line 128 of file object.h.

00129    {
00130     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00131     if (i != mSpecificParameters.end())
00132     {
00133      i->second.copyValue(ParameterValue);
00134     }
00135     else
00136     {
00137      Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__);
00138     }
00139    }

Texture * gpucalc::GLGraphicCore::getTextureByName ( const std::string &  TextureName  )  const [virtual]

Finds and return previously created Texture.

If texture cannot be found, exception is thrown.

Implements gpucalc::GraphicCore.

Definition at line 212 of file gl_graphic_core.cpp.

00213  {
00214   assert(mIsStarted && "GLGraphicCore is not started!!!");
00215   GLTextureMap::const_iterator i = mGLTextureMap.find(TextureName);
00216   if (i != mGLTextureMap.end())
00217   {
00218    return i->second;
00219   }
00220   else
00221   {
00222    Except<ERR_ITEM_NOT_FOUND>(this, "Texture with name \"" + TextureName + "\" does not exists!", "GLGraphicCore::getTextureByName()", __FILE__, __LINE__);
00223    return 0;
00224   }
00225  }

Vendor gpucalc::GLGraphicCore::getVendor (  )  const [inline, virtual]

Returns vendor type.

Implements gpucalc::GraphicCore.

Definition at line 160 of file gl_graphic_core.h.

00161    {
00162     assert(mIsStarted && "GLGraphicCore is not started!!!");
00163     return mGLVendor;
00164    }

void gpucalc::GLGraphicCore::initialize ( const Data data,
Texture texture 
) [virtual]

Reinitalizes previously created texture with new Data.

Implements gpucalc::GraphicCore.

Definition at line 205 of file gl_graphic_core.cpp.

00206  {
00207   ConvertToTexture(data, static_cast<GLTexture &>(texture));
00208   texture.initialize();
00209  }

bool gpucalc::GLGraphicCore::isAcceptSystem ( const ShaderSystem System  )  const [virtual]

Check for ShaderSystem acceptance.

We need correct type of ShaderSystem, because some shader systems cannot work with some graphic cores (DX core and GL system).

Implements gpucalc::GraphicCore.

Definition at line 426 of file gl_graphic_core.cpp.

00427  {
00428   return (mAcceptableShaderSystemIDSet.find(System->getObjectName()) != mAcceptableShaderSystemIDSet.end());
00429  }

bool gpucalc::GLGraphicCore::isFrameBufferCreated ( const std::string &  FrameBufferName  )  const [virtual]

Check for existence.

Implements gpucalc::GraphicCore.

Definition at line 274 of file gl_graphic_core.cpp.

00275  {
00276   assert(mIsStarted && "GLGraphicCore is not started!!!");
00277   return (mGLFrameBufferMap.find(FrameBufferName) != mGLFrameBufferMap.end());
00278  }

bool gpucalc::Object::isLocked (  )  const [inline, inherited]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

bool gpucalc::GLGraphicCore::isTextureCreated ( const std::string &  TextureName  )  const [virtual]

Check for existence.

Implements gpucalc::GraphicCore.

Definition at line 228 of file gl_graphic_core.cpp.

00229  {
00230   assert(mIsStarted && "GLGraphicCore is not started!!!");
00231   return (mGLTextureMap.find(TextureName) != mGLTextureMap.end());
00232  }

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

GLint gpucalc::GLGraphicCore::maxFramebufferAttachmentPoints (  )  const [inline, virtual]

Returns maximal number of attachment points.

Implements gpucalc::GraphicCore.

Definition at line 174 of file gl_graphic_core.h.

00175    {
00176     assert(mIsStarted && "GLGraphicCore is not started!!!");
00177     return mGLMaxFrameBufferAttachmentPoints;
00178    }

GLint gpucalc::GLGraphicCore::maxTextureSize (  )  const [inline, virtual]

Returns maximal size of texture.

Implements gpucalc::GraphicCore.

Definition at line 167 of file gl_graphic_core.h.

00168    {
00169     assert(mIsStarted && "GLGraphicCore is not started!!!");
00170     return mGLMaxTextureSize;
00171    }

void gpucalc::GLGraphicCore::setMatrixMode ( float  Width,
float  Height 
) [virtual]

Setting up model view matrices, setting up viewport for correct rendering quad.

Parameters:
Width - width of rendering window.
Height - height of rendering window.

Implements gpucalc::GraphicCore.

Definition at line 149 of file gl_graphic_core.cpp.

00150  {
00151   assert(mIsStarted && "GLGraphicCore is not started!!!");
00152   mGLDefaultWidth = Width;
00153   mGLDefaultHeight = Height;
00154 
00155   glMatrixMode(GL_PROJECTION);
00156   glLoadIdentity();
00157   gluOrtho2D(0.0f, Width, 0.0f, Height);
00158   glMatrixMode(GL_MODELVIEW);
00159   glLoadIdentity();
00160   glViewport(0, 0, Width, Height);
00161   LogManager::getSingleton().logMessage(this, "ViewPort size: " +
00162    auxillary::StringUtil::toString(Width) + " X " + auxillary::StringUtil::toString(Height), LML_Trivial);
00163  }

void gpucalc::GLGraphicCore::start ( int  argc,
char *  argv[] 
) [virtual]

Starts our GraphicCore.

This method initializes graphical libraries, sets up all extensions (OpenGL) and function pointers. Creates rendering window, and configure library for offscreen rendering.

Implements gpucalc::GraphicCore.

Definition at line 68 of file gl_graphic_core.cpp.

00069  {
00070         if (mIsStarted) return;
00071   glutInit(&argc, argv);
00072   mGLUTWindow = glutCreateWindow("GL Graphic Core Window");
00073   glutHideWindow();
00074   LogManager::getSingleton().logMessage(this, "Using \"glut\" library for setting up GL window and context", LML_Trivial);
00075   LogManager::getSingleton().logMessage(this, "glut GL window created successfully", LML_Trivial);
00076   LogManager::getSingleton().logMessage(this, "Using \"glew\" library for obtaining advanced functions and capabilities of OpenGL...", LML_Trivial);
00077   GLenum err = glewInit();
00078   if (err != GLEW_OK)
00079   {
00080    Except<ERR_RENDERINGAPI_ERROR>(this, (char *)glewGetErrorString(err), "GLGraphicCore::start()", __FILE__, __LINE__);
00081   }
00082 
00083   if (GLEW_VERSION_2_0)
00084   {
00085    if (GLEW_VERSION_2_1)
00086    {
00087     LogManager::getSingleton().logMessage(this, "This GPU supports OpenGL 2.1, looking good!");
00088    }
00089    else
00090    {
00091     LogManager::getSingleton().logMessage(this, "This GPU supports OpenGL 2.0.");
00092    }
00093   }
00094   else
00095   {
00096    Warning<ERR_RENDERINGAPI_ERROR>(this, "This GPU does not support OpenGL 2.0 and later, shading may be unavailable.", "GLGraphicCore::start()", __FILE__, __LINE__);
00097   }
00098 
00099   LogManager::getSingleton().logMessage(this, std::string("Renderer: ") +
00100    (char *)glGetString(GL_RENDERER), LML_Trivial);
00101 
00102   LogManager::getSingleton().logMessage(this, std::string("Version:  ") +
00103    (char * )glGetString(GL_VERSION), LML_Trivial);
00104   
00105   std::string GLVendorString = std::string((char *)glGetString(GL_VENDOR));
00106   mGLVendor = this->FindCorrectVendor(GLVendorString);
00107   LogManager::getSingleton().logMessage(this, std::string("Vendor:   ") +
00108    GLVendorString, LML_Trivial);
00109 
00110   this->checkErrors("GLGraphicCore::start()");
00111 
00112   glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &mGLMaxFrameBufferAttachmentPoints);
00113 
00114   LogManager::getSingleton().logMessage(this, "Max number of attachment points is: " +
00115    auxillary::StringUtil::toString(mGLMaxFrameBufferAttachmentPoints));
00116 
00117 
00118   glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &mGLMaxTextureSize);
00119 
00120   LogManager::getSingleton().logMessage(this, "Max size of texture is: " +
00121    auxillary::StringUtil::toString(mGLMaxTextureSize));
00122 
00123 
00124   this->checkErrors("GLGraphicCore::start()");
00125 
00126   mIsStarted = true;
00127 
00128   this->addAcceptableShaderSystemID("GLGLSLShaderSystem");
00129   this->addAcceptableShaderSystemID("GLCgShaderSystem");
00130   LogManager::getSingleton().logMessage(this, "---===========================================---");
00131   LogManager::getSingleton().logMessage(this, "---===       GL Graphic Core started       ===---");
00132   LogManager::getSingleton().logMessage(this, "---===========================================---");
00133  }

void gpucalc::GLGraphicCore::stop (  )  [virtual]

Stops our GraphicCore.

This method deinitializes graphical libraries, deletes and frees resources (rendering window)

Implements gpucalc::GraphicCore.

Definition at line 136 of file gl_graphic_core.cpp.

00137  {
00138   assert(mIsStarted && "GLGraphicCore is not started!!!");
00139   clearContainer(mGLTextureMap);
00140   clearContainer(mGLFrameBufferMap);
00141   glutDestroyWindow(mGLUTWindow);
00142   LogManager::getSingleton().logMessage(this, "---===========================================---");
00143   LogManager::getSingleton().logMessage(this, "---===       GL Graphic Core stopped       ===---");
00144   LogManager::getSingleton().logMessage(this, "---===========================================---");
00145   mIsStarted = false;
00146  }

void gpucalc::GLGraphicCore::unbind ( FrameBuffer framebuffer  )  [virtual]

Implements gpucalc::GraphicCore.

Definition at line 346 of file gl_graphic_core.cpp.

00347  {
00348   assert(framebuffer && "FrameBuffer does not created!!!");
00349   if (framebuffer == mActiveFrameBuffer)
00350   {
00351    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
00352    mActiveFrameBuffer = 0;
00353   }
00354  }

void gpucalc::GLGraphicCore::unbind ( Texture texture  )  [virtual]

Implements gpucalc::GraphicCore.

Definition at line 322 of file gl_graphic_core.cpp.

00323  {
00324   assert(texture && "Texture does not created!!!");
00325   if (texture == mActiveTexture)
00326   {
00327    GLTexture * glTexture = static_cast<GLTexture *>(texture);
00328    glBindTexture(glTexture->getGLTextureTarget(), 0);
00329    mActiveTexture = 0;
00330   }
00331  }

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


Friends And Related Function Documentation

friend class GLGraphicCorePlugin [friend]

Definition at line 83 of file gl_graphic_core.h.


Member Data Documentation

Definition at line 236 of file gl_graphic_core.h.

Definition at line 239 of file gl_graphic_core.h.

Definition at line 242 of file gl_graphic_core.h.

Definition at line 199 of file gl_graphic_core.h.

Definition at line 196 of file gl_graphic_core.h.

Stores all framebuffers.

Each framebuffer in this map has unique name.

Definition at line 230 of file gl_graphic_core.h.

Definition at line 190 of file gl_graphic_core.h.

Definition at line 193 of file gl_graphic_core.h.

Stores all textures.

Each texture in this map has unique name, so we do not need to check texture name in Task::addData

Definition at line 216 of file gl_graphic_core.h.

Definition at line 184 of file gl_graphic_core.h.

Definition at line 187 of file gl_graphic_core.h.

Definition at line 202 of file gl_graphic_core.h.


The documentation for this class was generated from the following files:

Generated on Thu Mar 5 22:36:44 2009 for gpucalc by  doxygen 1.5.6