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

« back to all changes in this revision

Viewing changes to NuxGraphics/IOpenGLFrameBufferObject.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:
21
21
 
22
22
 
23
23
#include "GLResource.h"
 
24
#include "GraphicsDisplay.h"
24
25
#include "GpuDevice.h"
25
26
#include "GLDeviceObjects.h"
26
27
#include "IOpenGLFrameBufferObject.h"
39
40
    _PixelFormat = BITFMT_R8G8B8A8;
40
41
    _IsActive = false;
41
42
 
42
 
    for (int i = 0; i < GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment(); i++)
 
43
    for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
43
44
    {
44
45
      _Color_AttachmentArray.push_back (ObjectPtr<IOpenGLSurface> (0) );
45
46
    }
60
61
  {
61
62
    Deactivate();
62
63
 
63
 
    for (int i = 0; i < GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment(); i++)
 
64
    for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
64
65
    {
65
66
      _Color_AttachmentArray[i] = ObjectPtr<IOpenGLSurface> (0);
66
67
    }
86
87
 
87
88
  int IOpenGLFrameBufferObject::SetRenderTarget (int ColorAttachmentIndex, ObjectPtr<IOpenGLSurface> pRenderTargetSurface)
88
89
  {
89
 
    nuxAssert (ColorAttachmentIndex < GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment());
 
90
    nuxAssert (ColorAttachmentIndex < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/);
90
91
 
91
92
    if (pRenderTargetSurface.IsNull() )
92
93
    {
151
152
 
152
153
  ObjectPtr<IOpenGLSurface> IOpenGLFrameBufferObject::GetRenderTarget (int ColorAttachmentIndex)
153
154
  {
154
 
    nuxAssert (ColorAttachmentIndex < GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment());
 
155
    nuxAssert (ColorAttachmentIndex < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/);
155
156
    return _Color_AttachmentArray[ColorAttachmentIndex];
156
157
  }
157
158
 
165
166
    GLuint NumBuffers = 0;
166
167
    _Fbo.Bind();
167
168
 
168
 
    if (GetGpuDevice() )
169
 
      GetGpuDevice()->SetCurrentFrameBufferObject (ObjectPtr<IOpenGLFrameBufferObject> (this));
 
169
    if (GetGraphicsDisplay()->GetGpuDevice() )
 
170
      GetGraphicsDisplay()->GetGpuDevice()->SetCurrentFrameBufferObject (ObjectPtr<IOpenGLFrameBufferObject> (this));
170
171
 
171
 
    for (int i = 0; i < GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment(); i++)
 
172
    for (int i = 0; i < 1 /*GetGraphicsDisplay()->GetGpuDevice()->GetGpuInfo().GetMaxFboAttachment()*/; i++)
172
173
    {
173
174
      if (_Color_AttachmentArray[i].IsValid() )
174
175
      {
211
212
 
212
213
    nuxAssert ( _Fbo.IsValid() == true );
213
214
 
214
 
    if (GetThreadGraphicsContext() )
215
 
      GetThreadGraphicsContext()->SetViewport (0, 0, _Width, _Height);
 
215
    if (GetGraphicsDisplay()->GetGraphicsEngine())
 
216
      GetGraphicsDisplay()->GetGraphicsEngine()->SetViewport (0, 0, _Width, _Height);
216
217
 
217
218
    if (WithClippingStack)
218
219
      ApplyClippingRegion();
230
231
    CHECKGL ( glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, 0) );
231
232
#endif
232
233
 
233
 
    if (GetGpuDevice() )
234
 
      GetGpuDevice()->SetCurrentFrameBufferObject (ObjectPtr<IOpenGLFrameBufferObject> (0));
 
234
    if(GetGraphicsDisplay()->GetGpuDevice())
 
235
      GetGraphicsDisplay()->GetGpuDevice()->SetCurrentFrameBufferObject (ObjectPtr<IOpenGLFrameBufferObject> (0));
235
236
 
236
 
    if (GetThreadGraphicsContext() )
237
 
      GetThreadGraphicsContext()->SetScissor (0, 0, _Width, _Height);
 
237
    if(GetGraphicsDisplay()->GetGraphicsEngine())
 
238
      GetGraphicsDisplay()->GetGraphicsEngine()->SetScissor (0, 0, _Width, _Height);
238
239
 
239
240
    _IsActive = false;
240
241
    return 1;
241
242
  }
242
243
 
243
 
  void IOpenGLFrameBufferObject::PushClippingRegion (Rect rect)
 
244
  void IOpenGLFrameBufferObject::PushClippingRegion(Rect rect)
244
245
  {
245
246
    Rect r0;
246
 
    if (GetThreadGraphicsContext ())
 
247
    if(GetGraphicsDisplay()->GetGraphicsEngine())
247
248
    {
248
 
      r0 = GetThreadGraphicsContext ()->ModelViewXFormRect (rect);
 
249
      r0 = GetGraphicsDisplay()->GetGraphicsEngine()->ModelViewXFormRect(rect);
249
250
    }
250
251
 
251
252
    Rect current_clip_rect;
262
263
 
263
264
    Rect r1;
264
265
 
265
 
    if (GetThreadGraphicsContext ())
266
 
      r1 = GetThreadGraphicsContext ()->GetViewportRect ();
 
266
    if (GetGraphicsDisplay()->GetGraphicsEngine())
 
267
      r1 = GetGraphicsDisplay()->GetGraphicsEngine()->GetViewportRect ();
267
268
 
268
269
    r0.OffsetPosition (r1.x, _Height - (r1.y + r1.GetHeight ()));
269
270
 
270
 
    Rect Intersection = current_clip_rect.Intersect (r0);
 
271
    Rect Intersection = current_clip_rect.Intersect(r0);
271
272
 
272
273
    if (!Intersection.IsNull ())
273
274
    {
274
275
      _clipping_rect = Intersection;
275
276
      _ClippingRegionStack.push_back (Intersection);
276
277
 
277
 
      SetOpenGLClippingRectangle (Intersection.x + GetThreadGraphicsContext ()->GetViewportX (),
278
 
                         _Height - Intersection.y - Intersection.GetHeight () - GetThreadGraphicsContext()->GetViewportY (),
 
278
      SetOpenGLClippingRectangle (Intersection.x + GetGraphicsDisplay()->GetGraphicsEngine()->GetViewportX (),
 
279
                         _Height - Intersection.y - Intersection.GetHeight () - GetGraphicsDisplay()->GetGraphicsEngine()->GetViewportY (),
279
280
                         Intersection.GetWidth (), Intersection.GetHeight ());
280
281
    }
281
282
    else
332
333
 
333
334
  void IOpenGLFrameBufferObject::SetClippingRectangle (const Rect &rect)
334
335
  {
335
 
    if (GetThreadGraphicsContext ())
 
336
    if (GetGraphicsDisplay()->GetGraphicsEngine())
336
337
    {
337
338
      _clipping_rect = rect;
338
 
      GetThreadGraphicsContext ()->SetScissor (rect.x, _Height - rect.y - rect.height, rect.width, rect.height);
 
339
      GetGraphicsDisplay()->GetGraphicsEngine()->SetScissor (rect.x, _Height - rect.y - rect.height, rect.width, rect.height);
339
340
    }
340
341
  }
341
342
 
342
343
  void IOpenGLFrameBufferObject::SetOpenGLClippingRectangle (int x, int y, int width, int height)
343
344
  {
344
 
    if (GetThreadGraphicsContext ())
 
345
    if (GetGraphicsDisplay()->GetGraphicsEngine())
345
346
    {
346
347
      _clipping_rect = Rect (x, y, width, height);
347
 
      GetThreadGraphicsContext ()->SetScissor (x, y, width, height);
 
348
      GetGraphicsDisplay()->GetGraphicsEngine()->SetScissor (x, y, width, height);
348
349
    }
349
350
  }
350
351