~nux-team/nuxplayground/nuxplayground.removed-deprecated

« back to all changes in this revision

Viewing changes to src/nux-gfx-color-layer-over-color/nux-gfx-color-layer-over-color.cpp

added Jay's new projects and nstring fixes to nuxplayground

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "NuxCore/NuxCore.h"
 
2
#include "NuxGraphics/BitmapFormats.h"
 
3
#include "NuxGraphics/GraphicsDisplay.h"
 
4
#include "NuxGraphics/GLWindowManager.h"
 
5
#include "NuxGraphics/GraphicsEngine.h"
 
6
#include "NuxCore/FilePath.h"
 
7
 
 
8
#if defined(NUX_OS_WINDOWS)
 
9
#define PKGDATADIR "../../data/"
 
10
#endif
 
11
 
 
12
 
 
13
void TextureLayerOverTexture()
 
14
{
 
15
  nux::GraphicsDisplay* graphics_display = gGLWindowManager.CreateGLWindow("Window", 600, 300, nux::WINDOWSTYLE_NORMAL, 0, false);
 
16
  nux::GraphicsEngine* graphics_engine = graphics_display->GetGraphicsEngine();
 
17
 
 
18
  graphics_display->ShowWindow();
 
19
 
 
20
  nux::BaseTexture* flowers = nux::CreateTextureFromFile(PKGDATADIR"/textures/flowers.png");
 
21
  nux::BaseTexture* wall = nux::CreateTextureFromFile(PKGDATADIR"/textures/wall.png");
 
22
 
 
23
 
 
24
  int w, h;
 
25
  int quad_size  = 128;
 
26
  int space = 10;
 
27
  nux::Event event;
 
28
  memset(&event, 0, sizeof(nux::Event));
 
29
  graphics_engine->GetWindowSize(w, h);
 
30
  graphics_engine->SetViewport(0, 0, w, h);
 
31
  graphics_engine->SetOrthographicProjectionMatrix(w, h);
 
32
  bool first_time = true;
 
33
 
 
34
  do
 
35
  {
 
36
    CHECKGL(glClearColor(0, 0, 0, 1));
 
37
    CHECKGL(glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT));
 
38
 
 
39
    graphics_display->GetSystemEvent(&event);
 
40
    if (first_time || (event.type == nux::NUX_SIZE_CONFIGURATION))
 
41
    {
 
42
      first_time = false;
 
43
      graphics_engine->GetWindowSize(w, h);
 
44
      graphics_engine->SetViewport(0, 0, w, h);
 
45
      graphics_engine->SetScissor(0, 0, w, h);
 
46
      graphics_engine->SetOrthographicProjectionMatrix(w, h);
 
47
    }
 
48
 
 
49
    int num_quad_per_row = graphics_display->GetWindowWidth() / (quad_size + space);
 
50
    int x = space;
 
51
    int y = space;
 
52
    int column = 0;
 
53
 
 
54
    for (int i = 0; i < nux::LAYER_BLEND_MODE_LAST; ++i)
 
55
    {
 
56
      graphics_engine->QRP_GLSL_ColorLayerOverColor(x, y, quad_size, quad_size,
 
57
        nux::color::Red,
 
58
        nux::color::Blue,
 
59
        (nux::LayerBlendMode)i);
 
60
 
 
61
      ++column;
 
62
      x += quad_size + space;
 
63
      if (column == num_quad_per_row)
 
64
      {
 
65
        x = space;
 
66
        y += quad_size + space;
 
67
        column = 0;
 
68
      }
 
69
    }
 
70
 
 
71
    graphics_display->SwapBuffer();
 
72
  } while(event.type != nux::NUX_TERMINATE_APP);
 
73
 
 
74
  flowers->UnReference();
 
75
  wall->UnReference();
 
76
 
 
77
  delete graphics_display;
 
78
}
 
79
 
 
80
int main(int argc, char **argv)
 
81
{
 
82
  nux::NuxCoreInitialize(0);
 
83
  nux::NuxGraphicsInitialize();
 
84
 
 
85
  TextureLayerOverTexture();
 
86
  return 0;
 
87
}