@edapx wrote:
Something weird is happening to me on Monday morning.
My problem is, I have a class called “ImageResource” containing a vector of ofImages, and I want to pass one of those images to a shader in my ofApp.This is the ImageResource class header.
#pragma once #include "ofMain.h" class ImageResources { public: ImageResources(); void update(); void setup(); // this is just for test ofImage getCurrentImageColor(); // Images vector<ofImage> imageColors; ofImage activeImg; int textureIndex; }
Implementation
#include "ImageResources.h" ImageResources::ImageResources(){} void ImageResources::setup(){ // ... // fill the imageColors vector // ... imgIndex = 0; activeImg = imageColors.at(imgIndex); } void ImageResources::update(){ // imgIndex may change. } ofImage ImageResources::getCurrentImageColor(){ return imageColors[textureIndex]; }
In my ofApp class I am simply going to use the ImageResources as follow:
damShader.begin(); ; damShader.setUniformTexture("damImage", imageResources.getCurrentImageColor().getTexture(), 0); plane.draw(); damShader.end();
With a wrong result, it looks like the texture got passed empty:
If I pass the texture as follows:
damShader.begin(); ; damShader.setUniformTexture("damImage", imageResources.activeimg.getTexture(), 0); plane.draw(); damShader.end();
It works.
I have already tried to see if
getCurrentImageColor()
was not returni any image, but if I draw it to the screen usinggetCurrentImageColor().getTexture(0,0)
it works.
Posts: 7
Participants: 2