ofImage.loadImage problem
I have 2 Ati Radeon HD 7770 cards. Each card is diving one monitor. I have an image loading problem. If I change the image on the second screen, the image updates fine. However, if I change the image on the first screen, I get a generic grey box instead of my image. What am I doing wrong? Here's my code:
testApp.h:
pragma once
include "ofMain.h"
include "ofxFensterManager.h"
class mySecondWindow : public ofxFensterListener { public:
mySecondWindow()
{
}
~mySecondWindow()
{
}
void setup() {
myImg.loadImage("background.jpg");
}
void updateImg() {
myImg.loadImage("background2.jpg");
}
void draw() {
myImg.draw(0,0);
}
private: ofImage myImg; };
class testApp : public ofBaseApp {
public: void setup(); void draw();
void mousePressed(int x, int y, int button);
void mousePressedEvent(ofMouseEventArgs &args);
ofxDisplayList displays;
ofxDisplay* disp;
//my second screen
mySecondWindow window2;
ofImage myImg;
};
testApp.cpp:
include "testApp.h"
//--------------------------------------------------------------
void testApp::setup()
{
//initialized variables and make first screen full
displays = ofxDisplayManager::get()->getDisplays();
disp = displays[0];
ofxFensterManager::get()->setActiveDisplay(disp);
ofxFensterManager::get()->getActiveWindow()->toggleFullscreen();
//initialize first screen
myImg.loadImage("background.jpg");
//create second screen and make full
ofxFenster* win=ofxFensterManager::get()->createFenster(1920, 0, 1920, 1080, OF_WINDOW);
disp = displays[1];
ofxFensterManager::get()->setActiveDisplay(disp);
ofxFensterManager::get()->getActiveWindow()->toggleFullscreen();
ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent);
window2.setup();
win->addListener(&window2);
}
//-------------------------------------------------------------- void testApp::draw() { myImg.draw(0,0); }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button) { printf("monitor 1 mouse pressed x:%d y:%d\n",x,y); //--------------------------------------------------------------------------------------------------- //image doesn't get updated properly. Displays a generic grey box instead //--------------------------------------------------------------------------------------------------- myImg.loadImage("background2.jpg"); }
void testApp::mousePressedEvent(ofMouseEventArgs &args) { printf("monitor 2 mouse pressed x:%d y:%d\n",args.x, args.y); window2.updateImg(); }
Hmm, I feel like the code should work as it is. It might be a bug. That said it is a little tricky to get two graphic cards working with resources like images and movies. Because they don't share their opengl context. Sometimes explicitly setting the context can do the trick. Does the code help?
ofxFensterManager::get()->getPrimaryWindow->setActive()
before loading the image in the main window? ( so before myImg.loadImage("background2.jpg"); )
perfect. ofxFensterManager::get()->getPrimaryWindow()->setActive(); made it work.
Ok, cool. I'll keep this open though. Still feels like a bug.
Ok no problem. Currently using Windows 7,Visual Studio Professional 2010, of_v0073_vs2010_release, and on the bottom of ofxFenster-master docs/html/index.html it says Generated on Fri Sep 30 2011 01:33:37 for ofxFenster by doxygen 1.7.4. Hope this helps in your debugging.