Back to index

nux  3.0.0
RenderingPipe.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #include "GLResource.h"
00024 #include "IOpenGLBaseTexture.h"
00025 #include "IOpenGLTexture2D.h"
00026 #include "IOpenGLRectangleTexture.h"
00027 #include "RenderingPipe.h"
00028 #include "GraphicsEngine.h"
00029 
00030 namespace nux
00031 {
00032 
00033   struct TexWrapMapping
00034   {
00035     TexWrap tex_wrap_mode;
00036     unsigned int opengl_wrap_mode;
00037   };
00038 
00039   struct TexWrapMapping TexWrapMappingArray [] =
00040   {
00041     {TEXWRAP_REPEAT,                        GL_REPEAT},
00042     {TEXWRAP_CLAMP,                         GL_CLAMP},
00043     {TEXWRAP_CLAMP_TO_EDGE,                 GL_CLAMP_TO_EDGE},
00044     {TEXWRAP_CLAMP_TO_BORDER,               GL_CLAMP_TO_BORDER},
00045     {TEXWRAP_MIRRORED_REPEAT,               GL_MIRRORED_REPEAT},
00046 #ifndef NUX_OPENGLES_20
00047     {TEXWRAP_MIRROR_CLAMP_EXT,              GL_MIRROR_CLAMP_EXT},
00048     {TEXWRAP_MIRROR_CLAMP_TO_EDGE_EXT,      GL_MIRROR_CLAMP_TO_EDGE_EXT},
00049     {TEXWRAP_MIRROR_CLAMP_TO_BORDER_EXT,    GL_MIRROR_CLAMP_TO_BORDER_EXT},
00050 #endif
00051     {TEXWRAP_UNKNOWN,                       0}
00052   };
00053 
00054   GLenum TexWrapGLMapping(TexWrap tex_wrap_mode)
00055   {
00056     int i = 0;
00057 
00058     while (TexWrapMappingArray[i].tex_wrap_mode != TEXWRAP_UNKNOWN)
00059     {
00060       if (TexWrapMappingArray[i].tex_wrap_mode == tex_wrap_mode)
00061       {
00062         return TexWrapMappingArray[i].opengl_wrap_mode;
00063       }
00064 
00065       ++i;
00066     }
00067 
00068     nuxAssertMsg(0, "[TexWrapGLMapping] Invalid texture wrap mode.");
00069     return GL_CLAMP;
00070   }
00071 
00072   struct TexFilterMapping
00073   {
00074     TexFilter tex_filter_mode;
00075     unsigned int opengl_filter_mode;
00076   };
00077 
00078   struct TexFilterMapping TexFilterMappingArray [] =
00079   {
00080     {TEXFILTER_LINEAR,                  GL_LINEAR},
00081     {TEXFILTER_NEAREST,                 GL_NEAREST},
00082     {TEXFILTER_NEAREST_MIPMAP_NEAREST,  GL_NEAREST_MIPMAP_NEAREST},
00083     {TEXFILTER_LINEAR_MIPMAP_NEAREST,   GL_LINEAR_MIPMAP_NEAREST},
00084     {TEXFILTER_NEAREST_MIPMAP_LINEAR,   GL_NEAREST_MIPMAP_LINEAR},
00085     {TEXFILTER_LINEAR_MIPMAP_LINEAR,    GL_LINEAR_MIPMAP_LINEAR},
00086     {TEXFILTER_UNKNOWN,                 0},
00087   };
00088 
00089   GLenum TexFilterGLMapping(TexFilter tex_filter_mode)
00090   {
00091     int i = 0;
00092 
00093     while (TexFilterMappingArray[i].tex_filter_mode != TEXFILTER_UNKNOWN)
00094     {
00095       if (TexFilterMappingArray[i].tex_filter_mode == tex_filter_mode)
00096       {
00097         return TexFilterMappingArray[i].opengl_filter_mode;
00098       }
00099 
00100       ++i;
00101     }
00102 
00103     nuxAssertMsg(0, "[TexFilterGLMapping] Invalid texture filter mode.");
00104     return GL_REPEAT;
00105   }
00106 
00107   struct RopBlendMapping
00108   {
00109     RopBlend rop_blend_mode;
00110     unsigned int opengl_blend_op;
00111   };
00112 
00113   struct RopBlendMapping RopBlendMappingArray [] =
00114   {
00115     {ROPBLEND_ZERO,                             GL_ZERO},
00116     {ROPBLEND_ONE,                              GL_ONE},
00117     {ROPBLEND_SRC_COLOR,                        GL_SRC_COLOR},
00118     {ROPBLEND_ONE_MINUS_SRC_COLOR,              GL_ONE_MINUS_SRC_COLOR},
00119     {ROPBLEND_DST_COLOR,                        GL_DST_COLOR},
00120     {ROPBLEND_ONE_MINUS_DST_COLOR,              GL_ONE_MINUS_DST_COLOR},
00121     {ROPBLEND_SRC_ALPHA,                        GL_SRC_ALPHA},
00122     {ROPBLEND_ONE_MINUS_SRC_ALPHA,              GL_ONE_MINUS_SRC_ALPHA},
00123     {ROPBLEND_DST_ALPHA,                        GL_DST_ALPHA},
00124     {ROPBLEND_ONE_MINUS_DST_ALPHA,              GL_ONE_MINUS_DST_ALPHA},
00125     {ROPBLEND_CONSTANT_COLOR,                   GL_CONSTANT_COLOR},
00126     {ROPBLEND_ONE_MINUS_CONSTANT_COLOR,         GL_ONE_MINUS_CONSTANT_COLOR},
00127     {ROPBLEND_CONSTANT_ALPHA,                   GL_CONSTANT_ALPHA},
00128     {ROPBLEND_ONE_MINUS_CONSTANT_ALPHA,         GL_ONE_MINUS_CONSTANT_ALPHA},
00129     {ROPBLEND_SRC_ALPHA_SATURATE,               GL_SRC_ALPHA_SATURATE},
00130     {ROPBLEND_UNKNOWN,                          0},
00131   };
00132 
00133   GLenum RopBlendGLMapping(RopBlend rop_blend_mode)
00134   {
00135     int i = 0;
00136 
00137     while (RopBlendMappingArray[i].rop_blend_mode != ROPBLEND_UNKNOWN)
00138     {
00139       if (RopBlendMappingArray[i].rop_blend_mode == rop_blend_mode)
00140       {
00141         return RopBlendMappingArray[i].opengl_blend_op;
00142       }
00143 
00144       ++i;
00145     }
00146 
00147     nuxAssertMsg(0, "[RopBlendGLMapping] Invalid texture ROP operation.");
00148     return ROPBLEND_ONE;
00149   }
00150 
00151   TexCoordXForm::TexCoordXForm()
00152   {
00153     u0 = v0 = u1 = v1 = 0.0f;
00154     uscale  = 1.0f;
00155     vscale  = 1.0f;
00156     uoffset = 0.0f;
00157     voffset = 0.0f;
00158     flip_u_coord = false;
00159     flip_v_coord = false;
00160     uwrap = TEXWRAP_CLAMP;
00161     vwrap = TEXWRAP_CLAMP;
00162     min_filter = TEXFILTER_NEAREST;
00163     mag_filter = TEXFILTER_NEAREST;
00164     m_tex_coord_type = TexCoordXForm::OFFSET_SCALE_COORD;
00165   }
00166 
00167   void TexCoordXForm::FlipUCoord(bool b)
00168   {
00169     flip_u_coord = b;
00170   }
00171 
00172   void TexCoordXForm::FlipVCoord(bool b)
00173   {
00174     flip_v_coord = b;
00175   }
00176 
00177   void TexCoordXForm::FlipUVCoord(bool flip_u, bool flip_v)
00178   {
00179     flip_u_coord = flip_u;
00180     flip_v_coord = flip_v;
00181   }
00182 
00183   void TexCoordXForm::SetFilter(TexFilter minfitter, TexFilter magfilter)
00184   {
00185     min_filter = minfitter;
00186     mag_filter = magfilter;
00187   }
00188 
00189   void TexCoordXForm::SetWrap(TexWrap u_wrap, TexWrap v_wrap)
00190   {
00191     uwrap = u_wrap;
00192     vwrap = v_wrap;
00193   }
00194 
00195   void TexCoordXForm::SetTexCoordType(TexCoordType tex_coord_type)
00196   {
00197     m_tex_coord_type = tex_coord_type;
00198   }
00199 
00200   void QRP_Compute_Texture_Coord(int quad_width, int quad_height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm &texxform)
00201   {
00202     float tex_width = tex->GetWidth();
00203     float tex_height = tex->GetHeight();
00204 
00205     if (tex->Type().IsDerivedFromType(IOpenGLTexture2D::StaticObjectType))
00206     {
00207       if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_SCALE_COORD)
00208       {
00209         // Scale and offset the texture coordinates.
00210         // With a scale of 1.0 for both uscale and vscale, the texture is scaled over the entire surface of the quad.
00211         // If the texture and the quad have the same size, then the texture is mapped 1 to 1 with the pixels of the quad.
00212         texxform.u0 = texxform.uoffset;
00213         texxform.v0 = texxform.voffset;
00214         texxform.u1 = texxform.uoffset + texxform.uscale * (tex_width / (float)quad_width)   * quad_width / tex_width;
00215         texxform.v1 = texxform.voffset + texxform.vscale * (tex_height / (float)quad_height) * quad_height / tex_height;
00216       }
00217       else if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_COORD)
00218       {
00219         // Offset the texture coordinates but preserve the proportion of the of the texture over the quad.
00220         // If the texture size is smaller than the quad, it will be tiled over it.
00221         texxform.u0 = texxform.uoffset;
00222         texxform.v0 = texxform.voffset;
00223         texxform.u1 = texxform.uoffset + quad_width / tex_width;
00224         texxform.v1 = texxform.voffset + quad_height / tex_height;
00225       }
00226       else if (texxform.m_tex_coord_type == TexCoordXForm::UNNORMALIZED_COORD)
00227       {
00228         texxform.u0 /= (float) tex_width;
00229         texxform.v0 /= (float) tex_height;
00230         texxform.u1 /= (float) tex_width;
00231         texxform.v1 /= (float) tex_height;
00232       }
00233       else if (texxform.m_tex_coord_type == TexCoordXForm::NORMALIZED_COORD || texxform.m_tex_coord_type == TexCoordXForm::FIXED_COORD)
00234       {
00235         // Use provided texture coordinates as is.
00236       }
00237     }
00238     else if (tex->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType))
00239     {
00240       if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_SCALE_COORD)
00241       {
00242         texxform.u0 = int(texxform.uoffset * tex_width);
00243         texxform.v0 = int(texxform.voffset * tex_height);
00244         texxform.u1 = texxform.u0 + tex_width * texxform.uscale;
00245         texxform.v1 = texxform.v0 + tex_height * texxform.vscale;
00246       }
00247       else if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_COORD)
00248       {
00249         texxform.u0 = texxform.uoffset;
00250         texxform.v0 = texxform.voffset;
00251         texxform.u1 = texxform.u0 + quad_width;
00252         texxform.v1 = texxform.v0 + quad_height;
00253       }
00254       else if (texxform.m_tex_coord_type == TexCoordXForm::NORMALIZED_COORD)
00255       {
00256         texxform.u0 *= (float) tex_width;
00257         texxform.v0 *= (float) tex_height;
00258         texxform.u1 *= (float) tex_width;
00259         texxform.v1 *= (float) tex_height;
00260       }
00261       else if (texxform.m_tex_coord_type == TexCoordXForm::UNNORMALIZED_COORD || texxform.m_tex_coord_type == TexCoordXForm::FIXED_COORD)
00262       {
00263         // Use provided texture coordinates as is.
00264       }
00265     }
00266 
00267     if (texxform.flip_u_coord)
00268     {
00269       float temp = texxform.u0;
00270       texxform.u0 = texxform.u1;
00271       texxform.u1 = temp;
00272     }
00273 
00274     if (texxform.flip_v_coord)
00275     {
00276       float temp = texxform.v0;
00277       texxform.v0 = texxform.v1;
00278       texxform.v1 = temp;
00279     }
00280 
00281     if (tex->Type().IsDerivedFromType(IOpenGLRectangleTexture::StaticObjectType))
00282     {
00283       // A chance to avoid some potential errors! Rectangle textures support only GL_CLAMP, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER.
00284       // See http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt
00285       if (texxform.uwrap != TEXWRAP_CLAMP ||
00286         texxform.uwrap != TEXWRAP_CLAMP_TO_EDGE ||
00287         texxform.uwrap != TEXWRAP_CLAMP_TO_BORDER ||
00288         texxform.vwrap != TEXWRAP_CLAMP ||
00289         texxform.vwrap != TEXWRAP_CLAMP_TO_EDGE ||
00290         texxform.vwrap != TEXWRAP_CLAMP_TO_BORDER)
00291       {
00292         texxform.uwrap = TEXWRAP_CLAMP;
00293         texxform.vwrap = TEXWRAP_CLAMP;
00294       }
00295     }
00296 
00297 #ifdef NUX_OPENGLES_20
00298     // Enforce OpenGL ES 2.0 texture restrictions
00299     // 1. There is neither CLAMP nor CLAMP_TO_BORDER
00300     // 2. For NPOT textures, only CLAMP_TO_EDGE is supported
00301     // 3. For NPOT textures, only NEAREST and LINEAR are supported
00302     //
00303     // The last two constraints are relaxed by the GL_OES_texture_npot
00304     // extension which unfortunately is not supported by all implementations.
00305     //
00306     // Notes: we have mapped GL_CLAMP to GL_CLAMP_TO_EDGE in OpenGLMapping.h
00307     // so we also "support" TEXWRAP_CLAMP.
00308     if (texxform.uwrap == TEXWRAP_CLAMP_TO_BORDER ||
00309         texxform.vwrap == TEXWRAP_CLAMP_TO_BORDER ||
00310         (!tex->IsPowerOfTwo() &&
00311          ((texxform.uwrap != TEXWRAP_CLAMP &&
00312            texxform.uwrap != TEXWRAP_CLAMP_TO_EDGE) ||
00313           (texxform.vwrap != TEXWRAP_CLAMP &&
00314            texxform.vwrap != TEXWRAP_CLAMP_TO_EDGE))))
00315     {
00316       texxform.uwrap = TEXWRAP_CLAMP_TO_EDGE;
00317       texxform.vwrap = TEXWRAP_CLAMP_TO_EDGE;
00318     }
00319 
00320     if (!tex->IsPowerOfTwo() &&
00321         ((texxform.min_filter != TEXFILTER_NEAREST &&
00322           texxform.min_filter != TEXFILTER_LINEAR) ||
00323          (texxform.mag_filter != TEXFILTER_NEAREST &&
00324           texxform.mag_filter != TEXFILTER_LINEAR)))
00325     {
00326       texxform.min_filter = TEXFILTER_LINEAR;
00327       texxform.mag_filter = TEXFILTER_LINEAR;
00328     }
00329 #endif
00330 
00331     tex->SetWrap(TexWrapGLMapping(texxform.uwrap), TexWrapGLMapping(texxform.vwrap), GL_CLAMP);
00332     tex->SetFiltering(TexFilterGLMapping(texxform.min_filter), TexFilterGLMapping(texxform.mag_filter));
00333   }
00334 
00335 
00336   void GraphicsEngine::QRP_Color(int x, int y, int width, int height, const Color &color)
00337   {
00338 #ifndef NUX_OPENGLES_20
00339     if (UsingGLSLCodePath())
00340       QRP_GLSL_Color(x, y, width, height, color, color, color, color);
00341     else
00342       QRP_ASM_Color(x, y, width, height, color, color, color, color);
00343 #else
00344     QRP_GLSL_Color(x, y, width, height, color, color, color, color);
00345 #endif
00346   }
00347 
00348   void GraphicsEngine::QRP_Color(int x, int y, int width, int height, const Color &c0, const Color &c1, const Color &c2, const Color &c3)
00349   {
00350 #ifndef NUX_OPENGLES_20
00351     if (UsingGLSLCodePath())
00352       QRP_GLSL_Color(x, y, width, height, c0, c1, c2, c3);
00353     else
00354       QRP_ASM_Color(x, y, width, height, c0, c1, c2, c3);
00355 #else
00356     QRP_GLSL_Color(x, y, width, height, c0, c1, c2, c3);
00357 #endif
00358   }
00359 
00360   void GraphicsEngine::QRP_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0)
00361   {
00362 #ifndef NUX_OPENGLES_20
00363     if (UsingGLSLCodePath())
00364       QRP_GLSL_1Tex(x, y, width, height, DeviceTexture, texxform0, color0);
00365     else
00366       QRP_ASM_1Tex(x, y, width, height, DeviceTexture, texxform0, color0);
00367 #else
00368     QRP_GLSL_1Tex(x, y, width, height, DeviceTexture, texxform0, color0);
00369 #endif
00370   }
00371 
00372   void GraphicsEngine::QRP_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &c0, int pixel_size)
00373   {
00374 #ifndef NUX_OPENGLES_20
00375     if (UsingGLSLCodePath())
00376       QRP_GLSL_Pixelate(x, y, width, height, DeviceTexture, texxform, c0, pixel_size);
00377     else
00378       QRP_ASM_Pixelate(x, y, width, height, DeviceTexture, texxform, c0, pixel_size);
00379 #else
00380     QRP_GLSL_Pixelate(x, y, width, height, DeviceTexture, texxform, c0, pixel_size);
00381 #endif
00382   }
00383 
00384   // Render the texture alpha into RGB and modulated by a color.
00385   void GraphicsEngine::QRP_ColorModTexAlpha(int x, int y, int width, int height,
00386     ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color)
00387   {
00388 #ifndef NUX_OPENGLES_20
00389     if (UsingGLSLCodePath())
00390       QRP_GLSL_ColorModTexAlpha(x, y, width, height, DeviceTexture, texxform, color);
00391     else
00392       QRP_ASM_ColorModTexAlpha(x, y, width, height, DeviceTexture, texxform, color);
00393 #else
00394     QRP_GLSL_ColorModTexAlpha(x, y, width, height, DeviceTexture, texxform, color);
00395 #endif
00396   }
00397 
00398   // Blend 2 textures together
00399   void GraphicsEngine::QRP_2Tex(int x, int y, int width, int height,
00400     ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
00401     ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
00402   {
00403 #ifndef NUX_OPENGLES_20
00404     if (UsingGLSLCodePath())
00405       QRP_GLSL_2Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00406     else
00407       QRP_ASM_2Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00408 #else
00409     QRP_GLSL_2Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00410 #endif
00411   }
00412 
00413 
00414   void GraphicsEngine::QRP_2TexMod(int x, int y, int width, int height,
00415     ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
00416     ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
00417   {
00418 #ifndef NUX_OPENGLES_20
00419     if (UsingGLSLCodePath())
00420       QRP_GLSL_2TexMod(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00421     else
00422       QRP_ASM_2TexMod(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00423 #else
00424     QRP_GLSL_2TexMod(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1);
00425 #endif
00426   }
00427 
00428   void GraphicsEngine::QRP_4Tex(int x, int y, int width, int height,
00429     ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
00430     ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1,
00431     ObjectPtr<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm &texxform2, const Color &color2,
00432     ObjectPtr<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm &texxform3, const Color &color3)
00433   {
00434 #ifndef NUX_OPENGLES_20
00435     if (UsingGLSLCodePath())
00436       QRP_GLSL_4Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1,
00437       DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3);
00438     else
00439       QRP_ASM_4Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1,
00440       DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3);
00441 #else
00442     QRP_GLSL_4Tex(x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1,
00443       DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3);
00444 #endif
00445   }
00446 
00447   void GraphicsEngine::QRP_Triangle(int x0, int y0,
00448     int x1, int y1,
00449     int x2, int y2,
00450     Color c0)
00451   {
00452 #ifndef NUX_OPENGLES_20
00453     if (UsingGLSLCodePath())
00454       QRP_GLSL_Triangle(x0, y0, x1, y1, x2, y2, c0, c0, c0);
00455     else
00456       QRP_ASM_Triangle(x0, y0, x1, y1, x2, y2, c0, c0, c0);
00457 #else
00458     QRP_GLSL_Triangle(x0, y0, x1, y1, x2, y2, c0, c0, c0);
00459 #endif
00460   }
00461 
00462   void GraphicsEngine::QRP_Triangle(int x0, int y0,
00463     int x1, int y1,
00464     int x2, int y2,
00465     Color c0, Color c1, Color c2)
00466   {
00467 #ifndef NUX_OPENGLES_20
00468     if (UsingGLSLCodePath())
00469       QRP_GLSL_Triangle(x0, y0, x1, y1, x2, y2, c0, c1, c2);
00470     else
00471       QRP_ASM_Triangle(x0, y0, x1, y1, x2, y2, c0, c1, c2);
00472 #else
00473     QRP_GLSL_Triangle(x0, y0, x1, y1, x2, y2, c0, c1, c2);
00474 #endif
00475   }
00476 
00477   void GraphicsEngine::QRP_Line(int x0, int y0,
00478     int x1, int y1, Color c0)
00479   {
00480 #ifndef NUX_OPENGLES_20
00481     if (UsingGLSLCodePath())
00482       QRP_GLSL_Line(x0, y0, x1, y1, c0, c0);
00483     else
00484       QRP_ASM_Line(x0, y0, x1, y1, c0, c0);
00485 #else
00486     QRP_GLSL_Line(x0, y0, x1, y1, c0, c0);
00487 #endif
00488   }
00489 
00490   void GraphicsEngine::QRP_Line(int x0, int y0,
00491     int x1, int y1, Color c0, Color c1)
00492   {
00493 #ifndef NUX_OPENGLES_20
00494     if (UsingGLSLCodePath())
00495       QRP_GLSL_Line(x0, y0, x1, y1, c0, c1);
00496     else
00497       QRP_ASM_Line(x0, y0, x1, y1, c0, c1);
00498 #else
00499     QRP_GLSL_Line(x0, y0, x1, y1, c0, c1);
00500 #endif
00501   }
00502 
00503   void GraphicsEngine::QRP_QuadWireframe(int x0, int y0, int width, int height,
00504     Color c0,
00505     Color c1,
00506     Color c2,
00507     Color c3)
00508   {
00509 #ifndef NUX_OPENGLES_20
00510     if (UsingGLSLCodePath())
00511       QRP_GLSL_QuadWireframe(x0, y0, width, height, c0, c1, c2, c3);
00512     else
00513       QRP_ASM_QuadWireframe(x0, y0, width, height, c0, c1, c2, c3);
00514 #else
00515     QRP_GLSL_QuadWireframe(x0, y0, width, height, c0, c1, c2, c3);
00516 #endif
00517   }
00518 
00519   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetBlurTexture(
00520     int x, int y,
00521     int buffer_width, int buffer_height,
00522     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform,
00523     const Color& c0,
00524     float sigma, int num_pass)
00525   {
00526 #ifndef NUX_OPENGLES_20
00527     if (UsingGLSLCodePath())
00528       return QRP_GLSL_GetBlurTexture(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00529     else
00530       return QRP_ASM_GetBlurTexture(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00531 #else
00532     return QRP_GLSL_GetBlurTexture(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00533 #endif
00534   }
00535 
00536   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetAlphaTexture(
00537     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& c0)
00538   {
00539 #ifndef NUX_OPENGLES_20
00540     if (UsingGLSLCodePath())
00541       return QRP_GLSL_GetAlphaTexture(device_texture, texxform, c0);
00542     else
00543       return QRP_ASM_GetAlphaTexture(device_texture, texxform, c0);
00544 #else
00545     return QRP_GLSL_GetAlphaTexture(device_texture, texxform, c0);
00546 #endif
00547   }
00548 
00549   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetColorMatrixTexture(
00550     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform,
00551     const Color& c0, Matrix4 color_matrix, Vector4 offset)
00552   {
00553 #ifndef NUX_OPENGLES_20
00554     if (UsingGLSLCodePath())
00555       return QRP_GLSL_GetColorMatrixTexture(device_texture, texxform, c0, color_matrix, offset);
00556     else
00557       return QRP_ASM_GetColorMatrixTexture(device_texture, texxform, c0, color_matrix, offset);
00558 #else
00559     return QRP_GLSL_GetColorMatrixTexture(device_texture, texxform, c0, color_matrix, offset);
00560 #endif
00561   }
00562 
00563   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetPower(
00564     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& c0, const Vector4 &exponent)
00565   {
00566 #ifndef NUX_OPENGLES_20
00567     if (UsingGLSLCodePath())
00568       return QRP_GLSL_GetPower(device_texture, texxform, c0, exponent);
00569     else
00570       return QRP_ASM_GetPower(device_texture, texxform, c0, exponent);
00571 #else
00572     return QRP_GLSL_GetPower(device_texture, texxform, c0, exponent);
00573 #endif
00574   }
00575 
00576   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetLQBlur(
00577     int x, int y,
00578     int buffer_width, int buffer_height,
00579     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform,
00580     const Color& c0)
00581   {
00582 #ifndef NUX_OPENGLES_20
00583     if (UsingGLSLCodePath())
00584       return QRP_GLSL_GetLQBlur(x, y, buffer_width, buffer_height, device_texture, texxform, c0);
00585     else
00586       return QRP_ASM_GetLQBlur(x, y, buffer_width, buffer_height, device_texture, texxform, c0);
00587 #else
00588     return QRP_GLSL_GetLQBlur(x, y, buffer_width, buffer_height, device_texture, texxform, c0);
00589 #endif
00590   }
00591 
00592   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetHQBlur(
00593     int x, int y, int buffer_width, int buffer_height,
00594     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform,
00595     const Color& c0,
00596     float sigma, int num_pass)
00597   {
00598 #ifndef NUX_OPENGLES_20
00599     if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion() >= 2))
00600       return QRP_GLSL_GetHQBlur(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00601     else
00602       return QRP_ASM_GetBlurTexture(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00603 #else
00604     return QRP_GLSL_GetBlurTexture(x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass);
00605 #endif
00606   }
00607 
00608   void GraphicsEngine::QRP_DisturbedTexture(
00609     int x, int y, int width, int height,
00610     ObjectPtr<IOpenGLBaseTexture> distorsion_texture, TexCoordXForm &texxform0, const Color& c0,
00611     ObjectPtr<IOpenGLBaseTexture> src_device_texture, TexCoordXForm &texxform1, const Color& c1)
00612   {
00613 #ifndef NUX_OPENGLES_20
00614     if (UsingGLSLCodePath())
00615       QRP_GLSL_DisturbedTexture(x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1);
00616     else
00617     {
00618       // NUXTODO
00619       //QRP_ASM_DisturbedTexture(x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1);
00620     }
00621 #else
00622     QRP_GLSL_DisturbedTexture(x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1);
00623 #endif
00624   }
00625 
00626   ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetPixelBlocks(
00627     ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& color, int pixel_size)
00628   {
00629 #ifndef NUX_OPENGLES_20
00630     if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion() >= 2))
00631       return QRP_GLSL_GetPixelBlocks(device_texture, texxform, color, pixel_size);
00632     else
00633       return QRP_ASM_GetPixelBlocks(device_texture, texxform, color, pixel_size);
00634 #else
00635     return QRP_GLSL_GetPixelBlocks(device_texture, texxform, color, pixel_size);
00636 #endif
00637   }
00638 
00639   void GraphicsEngine::QRP_GetCopyTexture(
00640     int width, int height,
00641     ObjectPtr<IOpenGLBaseTexture>& dst_device_texture,
00642     ObjectPtr<IOpenGLBaseTexture>& src_device_texture,
00643     TexCoordXForm &texxform0, const Color& c0)
00644   {
00645 #ifndef NUX_OPENGLES_20
00646     if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion() >= 2))
00647       return QRP_GLSL_GetCopyTexture(width, height, dst_device_texture, src_device_texture, texxform0, c0);
00648     else
00649       return QRP_ASM_GetCopyTexture(width, height, dst_device_texture, src_device_texture, texxform0, c0);
00650 #else
00651     return QRP_GLSL_GetCopyTexture(width, height, dst_device_texture, src_device_texture, texxform0, c0);
00652 #endif
00653   }
00654 }
00655