18 #ifndef PIC_GL_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP 19 #define PIC_GL_POINT_SAMPLERS_SAMPLER_RANDOM_M_HPP 21 #include "../../base.hpp" 23 #include "../../gl/image.hpp" 25 #include "../../point_samplers/sampler_random_m.hpp" 34 GLenum err = glGetError();
36 if(err != GL_NO_ERROR) {
37 printf(
"----------- %d\n", err);
44 template <
unsigned int N>
137 printf(
"window: %d %d\n", window[0], window[1]);
140 if(!this->update(window, nSamples)) {
144 glDeleteTextures(1, &texture);
147 this->oldSamples = nSamples;
148 this->oldWindow = window;
153 if(this->nSamplers <= 0) {
157 printf(
"No samplers in MRSamplersGL.\n");
163 nSamples = int(this->samplers[0]->samplesR.size());
165 for(
int i = 1; i < this->nSamplers; i++) {
166 nSamples =
MIN(nSamples,
int(this->samplers[i]->samplesR.size()));
170 printf(
"Samples in samplers: %d %d\n", nSamples / N, N);
174 int *buffer =
new int [this->nSamplers * (nSamples / N) * 4];
178 for(
int i = 0; i < this->nSamplers; i++) {
179 for(
int j = 0; j < nSamples; j += N) {
182 for(
int k = 0; k < 4; k++) {
183 buffer[ind2 + k] = 0;
186 for(
int k = 0; k < N; k++) {
187 buffer[ind2 + k] = this->samplers[i]->samplesR[j + k];
190 buffer[ind2 + N] = this->samplers[i]->samplesR[j] *
191 this->samplers[i]->samplesR[j] +
192 this->samplers[i]->samplesR[j + 1] * this->samplers[i]->samplesR[j + 1];
198 glGenTextures(1, &texture);
199 glBindTexture(GL_TEXTURE_2D, texture);
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
201 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
202 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
203 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
204 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
206 width = nSamples / N;
207 height = this->nSamplers;
209 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0,
210 GL_RGBA_INTEGER, GL_INT, buffer);
215 glBindTexture(GL_TEXTURE_2D, 0);
225 int *buffer =
new int [this->nSamplers * this->nLevels];
228 for(
int i = 0; i < this->nSamplers; i++) {
229 for(
int j = 0; j < this->nLevels; j++) {
230 buffer[ind] = this->samplers[i]->levelsR[j];
231 printf(
"%d ", buffer[ind]);
239 glGenTextures(1, &levelsRtexture);
240 glBindTexture(GL_TEXTURE_2D, levelsRtexture);
241 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
242 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
243 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
244 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
245 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
247 glTexImage2D(GL_TEXTURE_2D, 0, GL_R32I, this->nLevels, this->nSamplers, 0,
248 GL_RED_INTEGER, GL_INT, buffer);
250 glBindTexture(GL_TEXTURE_2D, 0);
254 return levelsRtexture;
ImageGL * getImage()
getImage
Definition: sampler_random_m.hpp:89
SAMPLER_TYPE type
Definition: display.hpp:41
GLuint generateTexture()
generateTexture
The MRSamplers class.
Definition: sampler_random_m.hpp:34
PIC_INLINE void glGetPrintError()
glGetPrintError
Definition: sampler_random_m.hpp:32
The ImageGL class.
Definition: image.hpp:42
int height
Definition: sampler_random_m.hpp:50
int nLevels
Definition: display.hpp:44
int nSamplers
Definition: display.hpp:38
void updateGL(Vec< N, int > window, int nSamples)
updateGL
GLuint texture
Definition: sampler_random_m.hpp:48
The MRSamplersGL class.
Definition: sampler_random_m.hpp:45
SAMPLER_TYPE
Definition: point_samplers.hpp:51
#define PIC_INLINE
Definition: base.hpp:33
#define MIN(a, b)
Definition: math.hpp:69
Definition: bilateral_separation.hpp:25
MRSamplersGL(SAMPLER_TYPE type, Vec< N, int > window, int nSamples, int nLevels, int nSamplers)
MRSamplersGL.
Definition: sampler_random_m.hpp:63
GLuint getTexture()
getTexture
Definition: sampler_random_m.hpp:80
The Vec class.
Definition: vec.hpp:35
int nSamples
Definition: sampler_random_m.hpp:53
GLuint levelsRtexture
Definition: sampler_random_m.hpp:49
ImageGL * getImageLevelsR()
getImageLevelsR
Definition: sampler_random_m.hpp:100
GLuint getLevelsRTexture()
getLevelsRTexture
Definition: sampler_random_m.hpp:117
int width
Definition: sampler_random_m.hpp:50
GLuint generateLevelsRTexture()
generateLevelsRTexture