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"
8
#if defined(NUX_OS_WINDOWS)
9
#define PKGDATADIR "../../data/"
12
void TextureCopyBlurTest()
14
nux::GraphicsDisplay* graphics_display = gGLWindowManager.CreateGLWindow("Window", 600, 300, nux::WINDOWSTYLE_NORMAL, 0, false);
15
nux::GraphicsEngine* graphics_engine = graphics_display->GetGraphicsEngine();
17
graphics_display->ShowWindow();
19
nux::ObjectPtr<nux::IOpenGLFrameBufferObject> fbo;
20
nux::ObjectPtr<nux::IOpenGLBaseTexture> texture_rt;
21
nux::ObjectPtr<nux::IOpenGLBaseTexture> depth_rt;
23
fbo = graphics_display->GetGpuDevice ()->CreateFrameBufferObject ();
24
texture_rt = graphics_display->GetGpuDevice ()->CreateSystemCapableDeviceTexture (graphics_display->GetWindowWidth(), graphics_display->GetWindowHeight(), 1, nux::BITFMT_R8G8B8A8);
25
depth_rt = graphics_display->GetGpuDevice ()->CreateSystemCapableDeviceTexture (graphics_display->GetWindowWidth(), graphics_display->GetWindowHeight(), 1, nux::BITFMT_D24S8);
29
graphics_engine->GetWindowSize(w, h);
30
graphics_engine->SetViewport(0, 0, w, h);
31
graphics_engine->SetOrthographicProjectionMatrix(w, h);
34
memset(&event, 0, sizeof(nux::Event));
37
int frame_counter = 0;
38
int frame_periode = 0;
40
float periode_time = 0;
41
bool first_time = true;
44
CHECKGL( glClearColor(0, 0, 0, 1) );
45
CHECKGL( glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) );
47
graphics_display->GetSystemEvent(&event);
48
if(first_time || (event.type == nux::NUX_SIZE_CONFIGURATION))
51
graphics_engine->DisableAllTextureMode(0);
52
graphics_engine->DisableAllTextureMode(1);
53
graphics_engine->DisableAllTextureMode(2);
54
graphics_engine->DisableAllTextureMode(3);
55
//graphics_engine->SetEnvModeSelectTexture(GL_TEXTURE0);
56
graphics_engine->GetWindowSize(w, h);
57
graphics_engine->SetViewport(0, 0, w, h);
58
graphics_engine->SetScissor(0, 0, w, h);
59
graphics_engine->SetOrthographicProjectionMatrix(w, h);
61
fbo = graphics_display->GetGpuDevice ()->CreateFrameBufferObject ();
62
texture_rt = graphics_display->GetGpuDevice ()->CreateSystemCapableDeviceTexture (graphics_display->GetWindowWidth(), graphics_display->GetWindowHeight(), 1, nux::BITFMT_R8G8B8A8);
63
depth_rt = graphics_display->GetGpuDevice ()->CreateSystemCapableDeviceTexture (graphics_display->GetWindowWidth(), graphics_display->GetWindowHeight(), 1, nux::BITFMT_D24S8);
64
fbo->FormatFrameBufferObject (graphics_display->GetWindowWidth(), graphics_display->GetWindowHeight(), nux::BITFMT_R8G8B8A8);
67
fbo->SetRenderTarget (0, texture_rt->GetSurfaceLevel (0));
68
fbo->SetDepthSurface (depth_rt->GetSurfaceLevel (0));
72
// graphics_engine->GetWindowSize(w, h);
73
// graphics_engine->SetViewport(0, 0, w, h);
74
// graphics_engine->SetOrthographicProjectionMatrix(w, h);
76
for (int i = 0; i < 1; i++)
78
nux::Rect geo (nux::RandomUInt(graphics_display->GetWindowWidth()),
79
nux::RandomUInt(graphics_display->GetWindowHeight()),
81
nux::RandomUInt(200));
83
graphics_engine->QRP_Color(geo.x, geo.y, geo.width, geo.height, nux::color::RandomColor());
86
nux::TexCoordXForm texxform;
87
// Make a copy of the render target
88
nux::ObjectPtr <nux::IOpenGLBaseTexture> tex_copy = graphics_engine->CreateTextureFromBackBuffer (0, 0, graphics_display->GetWindowWidth (), graphics_display->GetWindowHeight ());
90
// Restore the back buffer
91
graphics_display->GetGpuDevice ()->DeactivateFrameBuffer ();
93
// Make a blurred version of the back buffer
94
nux::ObjectPtr <nux::IOpenGLBaseTexture> tex_blur = graphics_engine->QRP_GLSL_GetBlurTexture (
95
0, 0, texture_rt->GetWidth (), texture_rt->GetHeight (),
96
texture_rt, texxform, nux::color::White);
98
// Render the blurred texture
99
graphics_engine->QRP_1Tex(0, 0, tex_blur->GetWidth(), tex_blur->GetHeight(), tex_blur, texxform, nux::color::White);
101
sprintf(fps, "FPS: %3.2f", frame_rate);
109
graphics_engine->RenderColorTextLineStatic(graphics_engine->GetBoldFont (), page, fps, nux::color::White, false, nux::eAlignTextLeft);
111
graphics_display->SwapBuffer();
113
float frame_time = graphics_display->GetFrameTime();
114
graphics_display->ResetFrameTime();
115
periode_time += frame_time;
120
if (frame_periode >= 100)
122
frame_rate = frame_periode * 1000.0f / periode_time;
127
} while((event.type != nux::NUX_TERMINATE_APP) && (event.GetVirtualKeyState(NUX_VK_ESCAPE) == 0));
130
texture_rt.Release ();
133
delete graphics_display;
137
int main(int argc, char **argv)
139
nux::NuxCoreInitialize(0);
140
nux::NuxGraphicsInitialize();
142
TextureCopyBlurTest ();
b'\\ No newline at end of file'