nux-1.16.0
|
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 t_u32 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 {TEXWRAP_MIRROR_CLAMP_EXT, GL_MIRROR_CLAMP_EXT}, 00047 {TEXWRAP_MIRROR_CLAMP_TO_EDGE_EXT, GL_MIRROR_CLAMP_TO_EDGE_EXT}, 00048 {TEXWRAP_MIRROR_CLAMP_TO_BORDER_EXT, GL_MIRROR_CLAMP_TO_BORDER_EXT}, 00049 {TEXWRAP_UNKNOWN, 0} 00050 }; 00051 00052 GLenum TexWrapGLMapping (TexWrap tex_wrap_mode) 00053 { 00054 int i = 0; 00055 00056 while (TexWrapMappingArray[i].tex_wrap_mode != TEXWRAP_UNKNOWN) 00057 { 00058 if (TexWrapMappingArray[i].tex_wrap_mode == tex_wrap_mode) 00059 { 00060 return TexWrapMappingArray[i].opengl_wrap_mode; 00061 } 00062 00063 ++i; 00064 } 00065 00066 nuxAssertMsg (0, TEXT ("[TexWrapGLMapping] Invalid texture wrap mode.") ); 00067 return GL_CLAMP; 00068 } 00069 00070 struct TexFilterMapping 00071 { 00072 TexFilter tex_filter_mode; 00073 t_u32 opengl_filter_mode; 00074 }; 00075 00076 struct TexFilterMapping TexFilterMappingArray [] = 00077 { 00078 {TEXFILTER_LINEAR, GL_LINEAR}, 00079 {TEXFILTER_NEAREST, GL_NEAREST}, 00080 {TEXFILTER_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST}, 00081 {TEXFILTER_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST}, 00082 {TEXFILTER_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR}, 00083 {TEXFILTER_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR}, 00084 {TEXFILTER_UNKNOWN, 0}, 00085 }; 00086 00087 GLenum TexFilterGLMapping (TexFilter tex_filter_mode) 00088 { 00089 int i = 0; 00090 00091 while (TexFilterMappingArray[i].tex_filter_mode != TEXFILTER_UNKNOWN) 00092 { 00093 if (TexFilterMappingArray[i].tex_filter_mode == tex_filter_mode) 00094 { 00095 return TexFilterMappingArray[i].opengl_filter_mode; 00096 } 00097 00098 ++i; 00099 } 00100 00101 nuxAssertMsg (0, TEXT ("[TexFilterGLMapping] Invalid texture filter mode.") ); 00102 return GL_REPEAT; 00103 } 00104 00105 struct RopBlendMapping 00106 { 00107 RopBlend rop_blend_mode; 00108 t_u32 opengl_blend_op; 00109 }; 00110 00111 struct RopBlendMapping RopBlendMappingArray [] = 00112 { 00113 {ROPBLEND_ZERO, GL_ZERO}, 00114 {ROPBLEND_ONE, GL_ONE}, 00115 {ROPBLEND_SRC_COLOR, GL_SRC_COLOR}, 00116 {ROPBLEND_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR}, 00117 {ROPBLEND_DST_COLOR, GL_DST_COLOR}, 00118 {ROPBLEND_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_DST_COLOR}, 00119 {ROPBLEND_SRC_ALPHA, GL_SRC_ALPHA}, 00120 {ROPBLEND_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}, 00121 {ROPBLEND_DST_ALPHA, GL_DST_ALPHA}, 00122 {ROPBLEND_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA}, 00123 {ROPBLEND_CONSTANT_COLOR, GL_CONSTANT_COLOR}, 00124 {ROPBLEND_ONE_MINUS_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR}, 00125 {ROPBLEND_CONSTANT_ALPHA, GL_CONSTANT_ALPHA}, 00126 {ROPBLEND_ONE_MINUS_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA}, 00127 {ROPBLEND_SRC_ALPHA_SATURATE, GL_SRC_ALPHA_SATURATE}, 00128 {ROPBLEND_UNKNOWN, 0}, 00129 }; 00130 00131 GLenum RopBlendGLMapping (RopBlend rop_blend_mode) 00132 { 00133 int i = 0; 00134 00135 while (RopBlendMappingArray[i].rop_blend_mode != ROPBLEND_UNKNOWN) 00136 { 00137 if (RopBlendMappingArray[i].rop_blend_mode == rop_blend_mode) 00138 { 00139 return RopBlendMappingArray[i].opengl_blend_op; 00140 } 00141 00142 ++i; 00143 } 00144 00145 nuxAssertMsg (0, TEXT ("[RopBlendGLMapping] Invalid texture ROP operation.") ); 00146 return ROPBLEND_ONE; 00147 } 00148 00149 TexCoordXForm::TexCoordXForm() 00150 { 00151 u0 = v0 = u1 = v1 = 0.0f; 00152 uscale = 1.0f; 00153 vscale = 1.0f; 00154 uoffset = 0.0f; 00155 voffset = 0.0f; 00156 flip_u_coord = false; 00157 flip_v_coord = false; 00158 uwrap = TEXWRAP_CLAMP; 00159 vwrap = TEXWRAP_CLAMP; 00160 min_filter = TEXFILTER_NEAREST; 00161 mag_filter = TEXFILTER_NEAREST; 00162 m_tex_coord_type = TexCoordXForm::OFFSET_SCALE_COORD; 00163 } 00164 00165 void TexCoordXForm::FlipUCoord (bool b) 00166 { 00167 flip_u_coord = b; 00168 } 00169 00170 void TexCoordXForm::FlipVCoord (bool b) 00171 { 00172 flip_v_coord = b; 00173 } 00174 00175 void TexCoordXForm::FlipUVCoord (bool flip_u, bool flip_v) 00176 { 00177 flip_u_coord = flip_u; 00178 flip_v_coord = flip_v; 00179 } 00180 00181 void TexCoordXForm::SetFilter (TexFilter minfitter, TexFilter magfilter) 00182 { 00183 min_filter = minfitter; 00184 mag_filter = magfilter; 00185 } 00186 00187 void TexCoordXForm::SetWrap (TexWrap u_wrap, TexWrap v_wrap) 00188 { 00189 uwrap = u_wrap; 00190 vwrap = v_wrap; 00191 } 00192 00193 void TexCoordXForm::SetTexCoordType (TexCoordType tex_coord_type) 00194 { 00195 m_tex_coord_type = tex_coord_type; 00196 } 00197 00198 void QRP_Compute_Texture_Coord (t_int32 quad_width, t_int32 quad_height, ObjectPtr<IOpenGLBaseTexture> tex, TexCoordXForm &texxform) 00199 { 00200 float tex_width = tex->GetWidth(); 00201 float tex_height = tex->GetHeight(); 00202 00203 if (tex->Type().IsDerivedFromType (IOpenGLTexture2D::StaticObjectType) ) 00204 { 00205 if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_SCALE_COORD) 00206 { 00207 texxform.u0 = texxform.uoffset; 00208 texxform.v0 = texxform.voffset; 00209 texxform.u1 = texxform.u0 + texxform.uscale; 00210 texxform.v1 = texxform.v0 + texxform.vscale; 00211 } 00212 else if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_COORD) 00213 { 00214 texxform.u0 = texxform.uoffset; 00215 texxform.v0 = texxform.voffset; 00216 texxform.u1 = texxform.u0 + (float) quad_width / tex_width; 00217 texxform.v1 = texxform.v0 + (float) quad_height / tex_height; 00218 } 00219 else if (texxform.m_tex_coord_type == TexCoordXForm::UNNORMALIZED_COORD) 00220 { 00221 texxform.u0 /= (float) tex_width; 00222 texxform.v0 /= (float) tex_height; 00223 texxform.u1 /= (float) tex_width; 00224 texxform.v1 /= (float) tex_height; 00225 } 00226 else if (texxform.m_tex_coord_type == TexCoordXForm::NORMALIZED_COORD || texxform.m_tex_coord_type == TexCoordXForm::FIXED_COORD) 00227 { 00228 // Use provided texture coordinates as is. 00229 } 00230 } 00231 else if (tex->Type().IsDerivedFromType (IOpenGLRectangleTexture::StaticObjectType) ) 00232 { 00233 if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_SCALE_COORD) 00234 { 00235 texxform.u0 = t_int32 (texxform.uoffset * tex_width); 00236 texxform.v0 = t_int32 (texxform.voffset * tex_height); 00237 texxform.u1 = texxform.u0 + tex_width * texxform.uscale; 00238 texxform.v1 = texxform.v0 + tex_height * texxform.vscale; 00239 } 00240 else if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_COORD) 00241 { 00242 texxform.u0 = texxform.uoffset; 00243 texxform.v0 = texxform.voffset; 00244 texxform.u1 = texxform.u0 + quad_width; 00245 texxform.v1 = texxform.v0 + quad_height; 00246 } 00247 else if (texxform.m_tex_coord_type == TexCoordXForm::NORMALIZED_COORD) 00248 { 00249 texxform.u0 *= (float) tex_width; 00250 texxform.v0 *= (float) tex_height; 00251 texxform.u1 *= (float) tex_width; 00252 texxform.v1 *= (float) tex_height; 00253 } 00254 else if (texxform.m_tex_coord_type == TexCoordXForm::UNNORMALIZED_COORD || texxform.m_tex_coord_type == TexCoordXForm::FIXED_COORD) 00255 { 00256 // Use provided texture coordinates as is. 00257 } 00258 } 00259 00260 if (texxform.flip_u_coord) 00261 { 00262 float temp = texxform.u0; 00263 texxform.u0 = texxform.u1; 00264 texxform.u1 = temp; 00265 } 00266 00267 if (texxform.flip_v_coord) 00268 { 00269 float temp = texxform.v0; 00270 texxform.v0 = texxform.v1; 00271 texxform.v1 = temp; 00272 } 00273 00274 if (tex->Type().IsDerivedFromType (IOpenGLRectangleTexture::StaticObjectType) ) 00275 { 00276 // A chance to avoid some potential errors! Rectangle textures support only GL_CLAMP, GL_CLAMP_TO_EDGE, and GL_CLAMP_TO_BORDER. 00277 // See http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt 00278 if(texxform.uwrap != TEXWRAP_CLAMP || 00279 texxform.uwrap != TEXWRAP_CLAMP_TO_EDGE || 00280 texxform.uwrap != TEXWRAP_CLAMP_TO_BORDER || 00281 texxform.vwrap != TEXWRAP_CLAMP || 00282 texxform.vwrap != TEXWRAP_CLAMP_TO_EDGE || 00283 texxform.vwrap != TEXWRAP_CLAMP_TO_BORDER) 00284 { 00285 texxform.uwrap = TEXWRAP_CLAMP; 00286 texxform.vwrap = TEXWRAP_CLAMP; 00287 } 00288 } 00289 tex->SetWrap (TexWrapGLMapping (texxform.uwrap), TexWrapGLMapping (texxform.vwrap), GL_CLAMP); 00290 tex->SetFiltering (TexFilterGLMapping (texxform.min_filter), TexFilterGLMapping (texxform.mag_filter) ); 00291 } 00292 00293 00294 void GraphicsEngine::QRP_Color (int x, int y, int width, int height, const Color &color) 00295 { 00296 #ifndef NUX_OPENGLES_20 00297 if (UsingGLSLCodePath ()) 00298 QRP_GLSL_Color (x, y, width, height, color, color, color, color); 00299 else 00300 QRP_ASM_Color (x, y, width, height, color, color, color, color); 00301 #else 00302 QRP_GLSL_Color (x, y, width, height, color, color, color, color); 00303 #endif 00304 } 00305 00306 void GraphicsEngine::QRP_Color (int x, int y, int width, int height, const Color &c0, const Color &c1, const Color &c2, const Color &c3) 00307 { 00308 #ifndef NUX_OPENGLES_20 00309 if (UsingGLSLCodePath ()) 00310 QRP_GLSL_Color (x, y, width, height, c0, c1, c2, c3); 00311 else 00312 QRP_ASM_Color (x, y, width, height, c0, c1, c2, c3); 00313 #else 00314 QRP_GLSL_Color (x, y, width, height, c0, c1, c2, c3); 00315 #endif 00316 } 00317 00318 void GraphicsEngine::QRP_1Tex (int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0) 00319 { 00320 #ifndef NUX_OPENGLES_20 00321 if (UsingGLSLCodePath ()) 00322 QRP_GLSL_1Tex (x, y, width, height, DeviceTexture, texxform0, color0); 00323 else 00324 QRP_ASM_1Tex (x, y, width, height, DeviceTexture, texxform0, color0); 00325 #else 00326 QRP_GLSL_1Tex (x, y, width, height, DeviceTexture, texxform0, color0); 00327 #endif 00328 } 00329 00330 void GraphicsEngine::QRP_Pixelate (int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &c0, int pixel_size) 00331 { 00332 #ifndef NUX_OPENGLES_20 00333 if (UsingGLSLCodePath ()) 00334 QRP_GLSL_Pixelate (x, y, width, height, DeviceTexture, texxform, c0, pixel_size); 00335 else 00336 QRP_ASM_Pixelate (x, y, width, height, DeviceTexture, texxform, c0, pixel_size); 00337 #else 00338 QRP_GLSL_Pixelate (x, y, width, height, DeviceTexture, texxform, c0, pixel_size); 00339 #endif 00340 } 00341 00342 // Render the texture alpha into RGB and modulated by a color. 00343 void GraphicsEngine::QRP_ColorModTexAlpha (int x, int y, int width, int height, 00344 ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color) 00345 { 00346 #ifndef NUX_OPENGLES_20 00347 if (UsingGLSLCodePath ()) 00348 QRP_GLSL_ColorModTexAlpha (x, y, width, height, DeviceTexture, texxform, color); 00349 else 00350 QRP_ASM_ColorModTexAlpha (x, y, width, height, DeviceTexture, texxform, color); 00351 #else 00352 QRP_GLSL_ColorModTexAlpha (x, y, width, height, DeviceTexture, texxform, color); 00353 #endif 00354 } 00355 00356 // Blend 2 textures together 00357 void GraphicsEngine::QRP_2Tex (int x, int y, int width, int height, 00358 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0, 00359 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1) 00360 { 00361 #ifndef NUX_OPENGLES_20 00362 if (UsingGLSLCodePath ()) 00363 QRP_GLSL_2Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00364 else 00365 QRP_ASM_2Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00366 #else 00367 QRP_GLSL_2Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00368 #endif 00369 } 00370 00371 00372 void GraphicsEngine::QRP_2TexMod (int x, int y, int width, int height, 00373 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0, 00374 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1) 00375 { 00376 #ifndef NUX_OPENGLES_20 00377 if (UsingGLSLCodePath ()) 00378 QRP_GLSL_2TexMod (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00379 else 00380 QRP_ASM_2TexMod (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00381 #else 00382 QRP_GLSL_2TexMod (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1); 00383 #endif 00384 } 00385 00386 void GraphicsEngine::QRP_4Tex (int x, int y, int width, int height, 00387 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0, 00388 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1, 00389 ObjectPtr<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm &texxform2, const Color &color2, 00390 ObjectPtr<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm &texxform3, const Color &color3) 00391 { 00392 #ifndef NUX_OPENGLES_20 00393 if (UsingGLSLCodePath ()) 00394 QRP_GLSL_4Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1, 00395 DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3); 00396 else 00397 QRP_ASM_4Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1, 00398 DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3); 00399 #else 00400 QRP_GLSL_4Tex (x, y, width, height, DeviceTexture0, texxform0, color0, DeviceTexture1, texxform1, color1, 00401 DeviceTexture2, texxform2, color2, DeviceTexture3, texxform3, color3); 00402 #endif 00403 } 00404 00405 void GraphicsEngine::QRP_Triangle (int x0, int y0, 00406 int x1, int y1, 00407 int x2, int y2, 00408 Color c0) 00409 { 00410 #ifndef NUX_OPENGLES_20 00411 if (UsingGLSLCodePath ()) 00412 QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0, c0, c0); 00413 else 00414 QRP_ASM_Triangle (x0, y0, x1, y1, x2, y2, c0, c0, c0); 00415 #else 00416 QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0, c0, c0); 00417 #endif 00418 } 00419 00420 void GraphicsEngine::QRP_Triangle (int x0, int y0, 00421 int x1, int y1, 00422 int x2, int y2, 00423 Color c0, Color c1, Color c2) 00424 { 00425 #ifndef NUX_OPENGLES_20 00426 if (UsingGLSLCodePath ()) 00427 QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0, c1, c2); 00428 else 00429 QRP_ASM_Triangle (x0, y0, x1, y1, x2, y2, c0, c1, c2); 00430 #else 00431 QRP_GLSL_Triangle (x0, y0, x1, y1, x2, y2, c0, c1, c2); 00432 #endif 00433 } 00434 00435 void GraphicsEngine::QRP_Line (int x0, int y0, 00436 int x1, int y1, Color c0) 00437 { 00438 #ifndef NUX_OPENGLES_20 00439 if (UsingGLSLCodePath ()) 00440 QRP_GLSL_Line (x0, y0, x1, y1, c0, c0); 00441 else 00442 QRP_ASM_Line (x0, y0, x1, y1, c0, c0); 00443 #else 00444 QRP_GLSL_Line (x0, y0, x1, y1, c0, c0); 00445 #endif 00446 } 00447 00448 void GraphicsEngine::QRP_Line (int x0, int y0, 00449 int x1, int y1, Color c0, Color c1) 00450 { 00451 #ifndef NUX_OPENGLES_20 00452 if (UsingGLSLCodePath ()) 00453 QRP_GLSL_Line (x0, y0, x1, y1, c0, c1); 00454 else 00455 QRP_ASM_Line (x0, y0, x1, y1, c0, c1); 00456 #else 00457 QRP_GLSL_Line (x0, y0, x1, y1, c0, c1); 00458 #endif 00459 } 00460 00461 void GraphicsEngine::QRP_QuadWireframe (int x0, int y0, int width, int height, 00462 Color c0, 00463 Color c1, 00464 Color c2, 00465 Color c3) 00466 { 00467 #ifndef NUX_OPENGLES_20 00468 if (UsingGLSLCodePath ()) 00469 QRP_GLSL_QuadWireframe (x0, y0, width, height, c0, c1, c2, c3); 00470 else 00471 QRP_ASM_QuadWireframe (x0, y0, width, height, c0, c1, c2, c3); 00472 #else 00473 QRP_GLSL_QuadWireframe (x0, y0, width, height, c0, c1, c2, c3); 00474 #endif 00475 } 00476 00477 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetBlurTexture ( 00478 int x, int y, 00479 int buffer_width, int buffer_height, 00480 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, 00481 const Color& c0, 00482 float sigma, int num_pass) 00483 { 00484 #ifndef NUX_OPENGLES_20 00485 if (UsingGLSLCodePath ()) 00486 return QRP_GLSL_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00487 else 00488 return QRP_ASM_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00489 #else 00490 return QRP_GLSL_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00491 #endif 00492 } 00493 00494 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetAlphaTexture ( 00495 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& c0) 00496 { 00497 #ifndef NUX_OPENGLES_20 00498 if (UsingGLSLCodePath ()) 00499 return QRP_GLSL_GetAlphaTexture (device_texture, texxform, c0); 00500 else 00501 return QRP_ASM_GetAlphaTexture (device_texture, texxform, c0); 00502 #else 00503 return QRP_GLSL_GetAlphaTexture (device_texture, texxform, c0); 00504 #endif 00505 } 00506 00507 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetColorMatrixTexture ( 00508 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, 00509 const Color& c0, Matrix4 color_matrix, Vector4 offset) 00510 { 00511 #ifndef NUX_OPENGLES_20 00512 if (UsingGLSLCodePath ()) 00513 return QRP_GLSL_GetColorMatrixTexture (device_texture, texxform, c0, color_matrix, offset); 00514 else 00515 return QRP_ASM_GetColorMatrixTexture (device_texture, texxform, c0, color_matrix, offset); 00516 #else 00517 return QRP_GLSL_GetColorMatrixTexture (device_texture, texxform, c0, color_matrix, offset); 00518 #endif 00519 } 00520 00521 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetPower ( 00522 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& c0, const Vector4 &exponent) 00523 { 00524 #ifndef NUX_OPENGLES_20 00525 if (UsingGLSLCodePath ()) 00526 return QRP_GLSL_GetPower (device_texture, texxform, c0, exponent); 00527 else 00528 return QRP_ASM_GetPower (device_texture, texxform, c0, exponent); 00529 #else 00530 return QRP_GLSL_GetPower (device_texture, texxform, c0, exponent); 00531 #endif 00532 } 00533 00534 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetLQBlur ( 00535 int x, int y, 00536 int buffer_width, int buffer_height, 00537 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, 00538 const Color& c0) 00539 { 00540 #ifndef NUX_OPENGLES_20 00541 if (UsingGLSLCodePath ()) 00542 return QRP_GLSL_GetLQBlur (x, y, buffer_width, buffer_height, device_texture, texxform, c0); 00543 else 00544 return QRP_ASM_GetLQBlur (x, y, buffer_width, buffer_height, device_texture, texxform, c0); 00545 #else 00546 return QRP_GLSL_GetLQBlur (x, y, buffer_width, buffer_height, device_texture, texxform, c0); 00547 #endif 00548 } 00549 00550 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetHQBlur ( 00551 int x, int y, int buffer_width, int buffer_height, 00552 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, 00553 const Color& c0, 00554 float sigma, int num_pass) 00555 { 00556 #ifndef NUX_OPENGLES_20 00557 if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion () >= 2)) 00558 return QRP_GLSL_GetHQBlur (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00559 else 00560 return QRP_ASM_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00561 #else 00562 return QRP_ASM_GetBlurTexture (x, y, buffer_width, buffer_height, device_texture, texxform, c0, sigma, num_pass); 00563 #endif 00564 } 00565 00566 void GraphicsEngine::QRP_DisturbedTexture ( 00567 int x, int y, int width, int height, 00568 ObjectPtr<IOpenGLBaseTexture> distorsion_texture, TexCoordXForm &texxform0, const Color& c0, 00569 ObjectPtr<IOpenGLBaseTexture> src_device_texture, TexCoordXForm &texxform1, const Color& c1) 00570 { 00571 #ifndef NUX_OPENGLES_20 00572 if (UsingGLSLCodePath ()) 00573 QRP_GLSL_DisturbedTexture (x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1); 00574 else 00575 { 00576 // NUXTODO 00577 //QRP_ASM_DisturbedTexture (x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1); 00578 } 00579 #else 00580 QRP_GLSL_DisturbedTexture (x, y, width, height, distorsion_texture, texxform0, c0, src_device_texture, texxform1, c1); 00581 #endif 00582 } 00583 00584 ObjectPtr<IOpenGLBaseTexture> GraphicsEngine::QRP_GetPixelBlocks ( 00585 ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform, const Color& color, int pixel_size) 00586 { 00587 #ifndef NUX_OPENGLES_20 00588 if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion () >= 2)) 00589 return QRP_GLSL_GetPixelBlocks (device_texture, texxform, color, pixel_size); 00590 else 00591 return QRP_ASM_GetPixelBlocks (device_texture, texxform, color, pixel_size); 00592 #else 00593 return QRP_GLSL_GetPixelBlocks (device_texture, texxform, color, pixel_size); 00594 #endif 00595 } 00596 00597 void GraphicsEngine::QRP_GetCopyTexture ( 00598 int width, int height, 00599 ObjectPtr<IOpenGLBaseTexture>& dst_device_texture, 00600 ObjectPtr<IOpenGLBaseTexture>& src_device_texture, 00601 TexCoordXForm &texxform0, const Color& c0) 00602 { 00603 #ifndef NUX_OPENGLES_20 00604 if (UsingGLSLCodePath() && (_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion () >= 2)) 00605 return QRP_GLSL_GetCopyTexture (width, height, dst_device_texture, src_device_texture, texxform0, c0); 00606 else 00607 return QRP_ASM_GetCopyTexture (width, height, dst_device_texture, src_device_texture, texxform0, c0); 00608 #else 00609 return QRP_GLSL_GetCopyTexture (width, height, dst_device_texture, src_device_texture, texxform0, c0); 00610 #endif 00611 } 00612 } 00613