~unity-team/nux/nux-remove-glew-mx

« back to all changes in this revision

Viewing changes to NuxGraphics/GraphicsEngine.cpp

  • Committer: Jay Taoko
  • Date: 2011-05-30 02:54:31 UTC
  • mfrom: (353.1.1 nux)
  • Revision ID: jay.taoko@canonical.com-20110530025431-kpqcnbcq3apsfz92
* Object::Dispose() now does the same thing as Object::UnReference()
* Fixed memory leak in UXTheme::Load2DTextureFile
* Mesh Resource manager
    - Fixed mesh Resource manager pipeline
    - See example ProgObjMeshLoader

* Fixed GLSL Shaders in FontRendering.cpp
    - removed global variable USE_ARB_SHADERS and replaced with GraphicsEngine::UsingGLSLCodePath()

* Removing files IniFile.cpp/.h
* Removing files UIColorTheme.cpp/.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include "FontTexture.h"
35
35
#include "FontRenderer.h"
36
 
#include "UIColorTheme.h"
37
 
 
38
36
#include "GraphicsEngine.h"
39
37
 
40
38
namespace nux
177
175
 
178
176
    bool opengl_14_support = true;
179
177
 
180
 
    if ((_graphics_display.GetGpuDevice ()->GetOpenGLMajorVersion () == 1) &&
181
 
      (_graphics_display.GetGpuDevice ()->GetOpenGLMinorVersion () < 4))
 
178
    if ((_graphics_display.GetGpuDevice()->GetOpenGLMajorVersion () == 1) &&
 
179
      (_graphics_display.GetGpuDevice()->GetOpenGLMinorVersion () < 4))
182
180
    {
183
181
      // OpenGL version is less than OpenGL 1.4
184
182
      opengl_14_support = false;
188
186
    {
189
187
#ifndef NUX_OPENGLES_20
190
188
      if (UsingGLSLCodePath () &&
191
 
        GetGpuDevice ()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
192
 
        GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Shader () &&
 
189
        _graphics_display.GetGpuDevice()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
 
190
        _graphics_display.GetGpuDevice()->GetGpuInfo ().Support_ARB_Vertex_Shader () &&
193
191
        opengl_14_support)
194
192
      {
195
193
        InitSlColorShader ();
211
209
        InitSLHorizontalHQGaussFilter ();
212
210
        InitSLVerticalHQGaussFilter ();
213
211
      }
214
 
      else if (GetGpuDevice ()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
215
 
        GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Program () &&
 
212
      else if (_graphics_display.GetGpuDevice()->GetGpuInfo ().Support_ARB_Fragment_Shader () &&
 
213
        _graphics_display.GetGpuDevice()->GetGpuInfo ().Support_ARB_Vertex_Program () &&
216
214
        opengl_14_support)
217
215
      {
218
216
        InitAsmColorShader ();
286
284
      }
287
285
 
288
286
      if (gpu_info.Support_EXT_Framebuffer_Object ())
289
 
        _offscreen_fbo = GetGpuDevice()->CreateFrameBufferObject ();
 
287
        _offscreen_fbo = _graphics_display.GetGpuDevice()->CreateFrameBufferObject ();
290
288
 
291
 
      _offscreen_color_rt0  = GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
292
 
      _offscreen_color_rt1  = GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
293
 
      _offscreen_color_rt2  = GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
294
 
      _offscreen_color_rt3  = GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
 
289
      _offscreen_color_rt0  = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
 
290
      _offscreen_color_rt1  = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
 
291
      _offscreen_color_rt2  = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
 
292
      _offscreen_color_rt3  = _graphics_display.GetGpuDevice()->CreateTexture(2, 2, 1, BITFMT_R8G8B8A8);
295
293
    }
296
294
  }
297
295
 
309
307
 
310
308
  void GraphicsEngine::EvaluateGpuCaps ()
311
309
  {
312
 
    if (_graphics_display.GetGpuDevice ()->GetGpuInfo ().Support_ARB_Vertex_Shader() &&
313
 
      _graphics_display.GetGpuDevice ()->GetGpuInfo ().Support_ARB_Fragment_Shader() &&
314
 
      _graphics_display.GetGpuDevice ()->GetGPUBrand () ==  GPU_BRAND_NVIDIA)
 
310
    if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Shader() &&
 
311
      _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
 
312
      _graphics_display.GetGpuDevice()->GetGPUBrand() ==  GPU_BRAND_NVIDIA)
315
313
    {
316
314
      NString renderer_string = ANSI_TO_TCHAR (NUX_REINTERPRET_CAST (const char *, glGetString (GL_RENDERER)));
317
315
      CHECKGL_MSG (glGetString (GL_RENDERER));
509
507
 
510
508
  void GraphicsEngine::DisableAllTextureMode (int TextureUnit)
511
509
  {
512
 
    if ( (TextureUnit < GL_TEXTURE0) || (TextureUnit > GL_TEXTURE31) )
 
510
    if ((TextureUnit < GL_TEXTURE0) || (TextureUnit > GL_TEXTURE31))
513
511
      return;
514
512
 
515
 
    GetGpuDevice()->InvalidateTextureUnit (TextureUnit);
 
513
    _graphics_display.GetGpuDevice()->InvalidateTextureUnit(TextureUnit);
516
514
  }
517
515
 
518
516
//////////////////////
519
517
// DRAW CLIPPING    //
520
518
//////////////////////
521
 
  void GraphicsEngine::PushClippingRectangle (Rect rect)
 
519
  void GraphicsEngine::PushClippingRectangle(Rect rect)
522
520
  {
523
 
    if (_graphics_display.m_DeviceFactory->GetCurrentFrameBufferObject().IsValid() )
 
521
    if(_graphics_display.m_DeviceFactory->GetCurrentFrameBufferObject().IsValid())
524
522
    {
525
523
      // There is an active framebuffer set. Push the clipping rectangles to that fbo clipping stack.
526
524
      _graphics_display.m_DeviceFactory->GetCurrentFrameBufferObject()->PushClippingRegion (rect);
1289
1287
 
1290
1288
  bool GraphicsEngine::FlushCachedResourceData (ResourceData *Resource)
1291
1289
  {
1292
 
    bool cached = IsResourceCached (Resource);
1293
 
    if (cached == false)
 
1290
    if (!IsResourceCached(Resource))
1294
1291
      return false;
1295
1292
 
1296
 
    ResourceCache.FlushResourceId (Resource->GetResourceIndex ());
 
1293
    ResourceCache.FlushResourceId (Resource->GetResourceIndex());
1297
1294
    return true;
1298
1295
  }
1299
1296
 
1333
1330
  {
1334
1331
    //if ((colorbuffer->GetWidth() != width) || (depthbuffer->GetHeight() != height))
1335
1332
    {
1336
 
      colorbuffer = GetGpuDevice ()->CreateTexture (width, height, 1, BITFMT_R8G8B8A8);
1337
 
      depthbuffer = GetGpuDevice ()->CreateTexture (width, height, 1, BITFMT_D24S8);
 
1333
      colorbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_R8G8B8A8);
 
1334
      depthbuffer = _graphics_display.GetGpuDevice()->CreateTexture(width, height, 1, BITFMT_D24S8);
1338
1335
    }
1339
1336
 
1340
1337
    fbo->FormatFrameBufferObject(width, height, BITFMT_R8G8B8A8);
1341
 
    fbo->SetRenderTarget (0, colorbuffer->GetSurfaceLevel (0));
1342
 
    fbo->SetDepthSurface (depthbuffer->GetSurfaceLevel (0));
1343
 
    fbo->Activate ();
1344
 
    fbo->EmptyClippingRegion ();
1345
 
    SetContext (0, 0, width, height);
1346
 
    SetViewport (0, 0, width, height);
1347
 
    Push2DWindow (width, height);
 
1338
    fbo->SetRenderTarget(0, colorbuffer->GetSurfaceLevel(0));
 
1339
    fbo->SetDepthSurface(depthbuffer->GetSurfaceLevel(0));
 
1340
    fbo->Activate();
 
1341
    fbo->EmptyClippingRegion();
 
1342
    SetContext(0, 0, width, height);
 
1343
    SetViewport(0, 0, width, height);
 
1344
    Push2DWindow(width, height);
1348
1345
  }
1349
1346
 
1350
1347
  void GraphicsEngine::GaussianWeights(float **weights, float sigma, unsigned int num_tap)