ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

isaac_compositors.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #pragma once
17 
18 namespace isaac
19 {
20 
22 {
23  DefaultCompositor( isaac_size2 framebuffer_size ) {}
25  static inline isaac_size2 getCompositedbufferSize( isaac_size2 framebuffer_size )
26  {
27  return framebuffer_size;
28  }
29  inline uint32_t* doCompositing(IceTImage* image)
30  {
31  return icetImageGetColorui(image[0]);
32  }
33 };
34 
35 template <typename TController>
37 {
38  public:
39  static inline isaac_size2 getCompositedbufferSize( isaac_size2 framebuffer_size )
40  {
41  isaac_size2 compbuffer_size =
42  {
43  framebuffer_size.x * 2,
44  framebuffer_size.y
45  };
46  return compbuffer_size;
47  }
48  StereoCompositorSideBySide( isaac_size2 framebuffer_size ) :
49  framebuffer_size( framebuffer_size ),
50  compbuffer_size( getCompositedbufferSize( framebuffer_size ) )
51  {
52  compbuffer = (uint32_t*)malloc(sizeof(uint32_t) * compbuffer_size.x * compbuffer_size.y);
53  }
55  {
56  free(compbuffer);
57  }
58  inline uint32_t* doCompositing(IceTImage* image)
59  {
60  static_assert(TController::pass_count >= 2, "Not enough passes defined in Controller for StereoCompositor!");
61  uint32_t* left = icetImageGetColorui(image[0]);
62  uint32_t* right = icetImageGetColorui(image[1]);
63  for (unsigned int y = 0; y < compbuffer_size.y; y++)
64  {
65  memcpy( &(compbuffer[y*compbuffer_size.x ]), &( left[y*framebuffer_size.x]), sizeof(uint32_t) * framebuffer_size.x);
66  memcpy( &(compbuffer[y*compbuffer_size.x + framebuffer_size.x]), &(right[y*framebuffer_size.x]), sizeof(uint32_t) * framebuffer_size.x);
67  }
68  return compbuffer;
69  }
70  private:
71  isaac_size2 compbuffer_size;
72  isaac_size2 framebuffer_size;
73  uint32_t* compbuffer;
74 };
75 
76 template <
77  typename TController,
78  uint32_t LeftFilter,
79  uint32_t RightFilter
80 >
82 {
83  public:
84  static inline isaac_size2 getCompositedbufferSize( isaac_size2 framebuffer_size )
85  {
86  return framebuffer_size;
87  }
88  StereoCompositorAnaglyph( isaac_size2 framebuffer_size ) :
89  framebuffer_size( framebuffer_size )
90  {
91  compbuffer = (uint32_t*)malloc(sizeof(uint32_t) * framebuffer_size.x * framebuffer_size.y);
92  }
94  {
95  free(compbuffer);
96  }
97  inline uint32_t* doCompositing(IceTImage* image)
98  {
99  static_assert(TController::pass_count >= 2, "Not enough passes defined in Controller for StereoCompositor!");
100  uint32_t* left = icetImageGetColorui(image[0]);
101  uint32_t* right = icetImageGetColorui(image[1]);
102  for (unsigned int x = 0; x < framebuffer_size.x; x++)
103  for (unsigned int y = 0; y < framebuffer_size.y; y++)
104  compbuffer[x+y*framebuffer_size.x] =
105  ( left[x+y*framebuffer_size.x] & LeftFilter) |
106  (right[x+y*framebuffer_size.x] & RightFilter);
107  return compbuffer;
108  }
109  private:
110  isaac_size2 framebuffer_size;
111  uint32_t* compbuffer;
112 };
113 
114 } //namespace isaac;
StereoCompositorSideBySide(isaac_size2 framebuffer_size)
static isaac_size2 getCompositedbufferSize(isaac_size2 framebuffer_size)
Definition: isaac.hpp:60
DefaultCompositor(isaac_size2 framebuffer_size)
uint32_t * doCompositing(IceTImage *image)
static isaac_size2 getCompositedbufferSize(isaac_size2 framebuffer_size)
StereoCompositorAnaglyph(isaac_size2 framebuffer_size)
uint32_t * doCompositing(IceTImage *image)
uint32_t * doCompositing(IceTImage *image)
static isaac_size2 getCompositedbufferSize(isaac_size2 framebuffer_size)