Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
Set a valid value for deferred for all stimuli, by default. Also remo…
Browse files Browse the repository at this point in the history
…ved an instance of ExpandableList in the ImageStimulus class, in favor of a vector
  • Loading branch information
davidcox committed Jan 14, 2010
1 parent 2c6ce73 commit 96b669e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
39 changes: 17 additions & 22 deletions Core/Stimuli/StandardStimuli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,25 +885,18 @@ ImageStimulus::ImageStimulus(std::string _tag, std::string _filename,
shared_ptr<Variable> _alpha)
: BasicTransformStimulus(_tag, _xoffset, _yoffset,
_xscale ,_yscale, _rot, _alpha) {
// fprintf(stderr,"Creating image stimulus (filename = %s)\n",_filename.c_str());
// fflush(stderr);


filename = _filename;

texture_maps = new ExpandableList<GLuint>();
//image_loaded = false;
//il_image_name = 0;
width = 0;
height = 0;

// filename = _filename;
//image_loader = new OpenGLImageLoader();
}

// for cloning
ImageStimulus::ImageStimulus( std::string _tag,
std::string _filename,
ExpandableList<GLuint> *_texture_maps,
const vector<GLuint>& _texture_maps,
int _width, int _height,
shared_ptr<Variable> _xoffset,
shared_ptr<Variable> _yoffset, shared_ptr<Variable> _xscale,
Expand All @@ -917,8 +910,12 @@ ImageStimulus::ImageStimulus( std::string _tag,
// actually copy the string...
filename = _filename;

texture_maps = _texture_maps;
//image_loaded = false;
vector<GLuint>::const_iterator i;
for(i = _texture_maps.begin(); i != _texture_maps.end(); ++i){
texture_maps.push_back(*i);
}

//image_loaded = false;
//il_image_name = 0;
width = _width;
height = _height;
Expand Down Expand Up @@ -947,7 +944,6 @@ ImageStimulus::~ImageStimulus() {

}

delete texture_maps;
}


Expand All @@ -963,15 +959,15 @@ Stimulus * ImageStimulus::frozenClone(){
ImageStimulus *clone =
new ImageStimulus(tag,
filename,
new ExpandableList<GLuint>(*texture_maps),
texture_maps,
width,
height,
x_clone,
y_clone,
xs_clone,
ys_clone,
r_clone,
a_clone);
r_clone,
a_clone);


clone->setIsFrozen(true);
Expand All @@ -994,10 +990,13 @@ void ImageStimulus::load(StimulusDisplay *display) {
// TODO: this needs clean up. We are counting on all of the contexts
// in the stimulus display to have the exact same history. Ideally, this
// should be true, but we should eventually be robust in case it isn't
for(int i = 0; i < display->getNContexts(); i++){
texture_maps.clear();

for(int i = 0; i < display->getNContexts(); i++){
display->setCurrent(i);
GLuint texture_map = OpenGLImageLoader::load(filename, display, &width, &height);
texture_maps->addElement(i, texture_map);

texture_maps.push_back(texture_map);
// fprintf(stderr, "Loaded texture map %u into context %d\n", (unsigned int)texture_map, i);fflush(stderr);
if(texture_map){
mprintf("Image loaded into texture_map %d", texture_map);
Expand Down Expand Up @@ -1026,11 +1025,7 @@ void ImageStimulus::drawInUnitSquare(StimulusDisplay *display) {

//glActiveTexture(GL_TEXTURE0);

// fprintf(stderr, "Binding texture %lu on context index %u (context %u)",
// *(texture_maps->getElement(display->getCurrentContextIndex())),
// display->getCurrentContextIndex(),
// (unsigned int)display->getCurrentContext());fflush(stderr);
glBindTexture(GL_TEXTURE_2D, *(texture_maps->getElement(display->getCurrentContextIndex())));
glBindTexture(GL_TEXTURE_2D, texture_maps[display->getCurrentContextIndex()]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glEnable (GL_BLEND);
Expand Down
6 changes: 3 additions & 3 deletions Core/Stimuli/StandardStimuli.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class OpenGLImageLoader {
class ImageStimulus : public BasicTransformStimulus {
protected:
std::string filename;
ExpandableList<GLuint> *texture_maps;
vector<GLuint> texture_maps;
int width, height;

// for debugging
Expand All @@ -134,14 +134,14 @@ class ImageStimulus : public BasicTransformStimulus {
shared_ptr<Variable> _alpha);
// constructor for cloning an existing image stimulus
ImageStimulus(std::string _tag, std::string _filename,
ExpandableList<GLuint> *_texture_maps,
const vector<GLuint>& _texture_maps,
int _width,
int _height,
shared_ptr<Variable> _xoffset,
shared_ptr<Variable> _yoffset,
shared_ptr<Variable> _xscale,
shared_ptr<Variable> _yscale,
shared_ptr<Variable> _rot,
shared_ptr<Variable> _rot,
shared_ptr<Variable> _alpha);

ImageStimulus(ImageStimulus& copy);
Expand Down
2 changes: 2 additions & 0 deletions Core/Stimuli/Stimulus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Stimulus::Stimulus(std::string _tag):Announcable(ANNOUNCE_STIMULUS_TAGNAME),
has_thumbnail = false;
thumbnail = NULL;

deferred = Stimulus::nondeferred_load;
frozen = false;
}

Expand All @@ -187,6 +188,7 @@ Stimulus::Stimulus(const Stimulus& copy):
visible = copy.visible;
cached = copy.cached;
has_thumbnail = copy.has_thumbnail;
deferred = copy.deferred;
if(has_thumbnail) {
// this should prevent a loop if someone set the thumbnail to
// be itself
Expand Down
4 changes: 2 additions & 2 deletions Core/Stimuli/Stimulus.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ class Stimulus : public Announcable, public mw::Component {
bool hasThumbnail();
Stimulus * getThumbnail();
std::string gettag();
int getDeferred(){ return deferred; }
void setDeferred(load_style _deferred){ deferred = _deferred; }
int getDeferred(){ return deferred; }
void setDeferred(load_style _deferred){ deferred = _deferred; }

/**
* announcement methods // JJD
Expand Down

0 comments on commit 96b669e

Please sign in to comment.