Back to index

nux  3.0.0
Public Member Functions | Private Attributes
nux::GLSh_DrawFunction Class Reference

#include <GLSh_DrawFunction.h>

Collaboration diagram for nux::GLSh_DrawFunction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GLSh_DrawFunction ()
 ~GLSh_DrawFunction ()
void SetBackgroundColor (Color const &color)
void SetTextureFunction (ObjectPtr< IOpenGLBaseTexture > device_texture)
void Render (int x, int y, int z, int width, int height, int WindowWidth, int WindowHeight)
void SetScreenPositionOffset (float x, float y)

Private Attributes

Color background_color_
ObjectPtr< IOpenGLShaderProgramsprog
ObjectPtr
< IOpenGLAsmShaderProgram
m_AsmProg
float _ScreenOffsetX
float _ScreenOffsetY
UINT ViewPortX
UINT ViewPortY
UINT ViewPortWidth
UINT ViewPortHeight
ObjectPtr< IOpenGLBaseTexturem_device_texture
TemplateQuadBufferm_QuadBuffer

Detailed Description

Definition at line 37 of file GLSh_DrawFunction.h.


Constructor & Destructor Documentation

Definition at line 101 of file GLSh_DrawFunction.cpp.

Here is the call graph for this function:

Definition at line 121 of file GLSh_DrawFunction.cpp.

  {
    sprog = ObjectPtr<IOpenGLShaderProgram> (0);
  }

Member Function Documentation

void nux::GLSh_DrawFunction::Render ( int  x,
int  y,
int  z,
int  width,
int  height,
int  WindowWidth,
int  WindowHeight 
)

Definition at line 131 of file GLSh_DrawFunction.cpp.

  {
    float fx = x, fy = y;
    float VtxBuffer[] =
    {
      fx,          fy,          0.0f, 1.0f,
      fx,          fy + height, 0.0f, 1.0f,
      fx + width,  fy + height, 0.0f, 1.0f,
      fx + width,  fy,          0.0f, 1.0f,
    };

    if (GetGraphicsDisplay()->GetGraphicsEngine()->UsingGLSLCodePath() && (GetGraphicsDisplay()->GetGpuDevice()->GetGPUBrand() != GPU_BRAND_INTEL))
    {
      CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
      CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
      sprog->Begin();

      int VertexLocation = sprog->GetAttributeLocation("AVertex");

      int     VPMatrixLocation = sprog->GetUniformLocationARB("ViewProjectionMatrix");
      Matrix4 MVPMatrix = GetGraphicsDisplay()->GetGraphicsEngine()->GetOpenGLModelViewProjectionMatrix();
      sprog->SetUniformLocMatrix4fv((GLint) VPMatrixLocation, 1, false, (GLfloat *) & (MVPMatrix.m));

      GetGraphicsDisplay()->GetGraphicsEngine()->SetTexture(GL_TEXTURE0, m_device_texture);

      int ColorBase       = sprog->GetUniformLocationARB("Color");
      int RectPosition    = sprog->GetUniformLocationARB("RectPosition");
      int RectDimension   = sprog->GetUniformLocationARB("RectDimension");
      int TextureFunction = sprog->GetUniformLocationARB("TextureFunction");

      if (ColorBase != -1)
        CHECKGL(glUniform4fARB(ColorBase, background_color_.red, background_color_.green, background_color_.blue, background_color_.alpha));

      if (RectPosition != -1)
        CHECKGL(glUniform4fARB(RectPosition, x + _ScreenOffsetX, WindowHeight - y - height - _ScreenOffsetY, z, 0.0f));

      if (RectDimension != -1)
        CHECKGL(glUniform4fARB(RectDimension, width, height, 0.0f, 0.0f));

      if (TextureFunction != -1)
        CHECKGL(glUniform1iARB(TextureFunction, 0));

      CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
      CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 16, VtxBuffer));

      CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));

      CHECKGL(glDisableVertexAttribArrayARB(VertexLocation));

      sprog->End();
    }
#ifndef NUX_OPENGLES_20
    else
    {
      CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
      CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
      m_AsmProg->Begin();

      CHECKGL(glMatrixMode(GL_MODELVIEW));
      CHECKGL(glLoadIdentity());
      CHECKGL(glLoadMatrixf((FLOAT *) GetGraphicsDisplay()->GetGraphicsEngine()->GetOpenGLModelViewMatrix().m));
      CHECKGL(glMatrixMode(GL_PROJECTION));
      CHECKGL(glLoadIdentity());
      CHECKGL(glLoadMatrixf((FLOAT *) GetGraphicsDisplay()->GetGraphicsEngine()->GetOpenGLProjectionMatrix().m));

      int VertexLocation          = VTXATTRIB_POSITION;

      GetGraphicsDisplay()->GetGraphicsEngine()->SetTexture(GL_TEXTURE0, m_device_texture);

      CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, x + _ScreenOffsetX, WindowHeight - y - height - _ScreenOffsetY, z, 0.0f));
      CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, width, height, 0.0f, 0.0f));
      CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, background_color_.red, background_color_.green, background_color_.blue, background_color_.alpha));

      CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
      CHECKGL(glVertexAttribPointerARB((GLuint) VertexLocation, 4, GL_FLOAT, GL_FALSE, 16, VtxBuffer));

      CHECKGL(glDrawArrays(GL_TRIANGLE_FAN, 0, 4));

      CHECKGL(glDisableVertexAttribArrayARB(VertexLocation));

      m_AsmProg->End();
    }
#endif
  }

Here is the call graph for this function:

void nux::GLSh_DrawFunction::SetBackgroundColor ( Color const &  color)

Definition at line 126 of file GLSh_DrawFunction.cpp.

  {
    background_color_ = color;
  }
void nux::GLSh_DrawFunction::SetScreenPositionOffset ( float  x,
float  y 
)

Definition at line 221 of file GLSh_DrawFunction.cpp.

Definition at line 216 of file GLSh_DrawFunction.cpp.

  {
    m_device_texture = device_texture;
  }

Member Data Documentation

Definition at line 53 of file GLSh_DrawFunction.h.

Definition at line 53 of file GLSh_DrawFunction.h.

Definition at line 49 of file GLSh_DrawFunction.h.

Definition at line 51 of file GLSh_DrawFunction.h.

Definition at line 58 of file GLSh_DrawFunction.h.

Definition at line 61 of file GLSh_DrawFunction.h.

Definition at line 50 of file GLSh_DrawFunction.h.

Definition at line 57 of file GLSh_DrawFunction.h.

Definition at line 56 of file GLSh_DrawFunction.h.

Definition at line 54 of file GLSh_DrawFunction.h.

Definition at line 55 of file GLSh_DrawFunction.h.


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