5
« on: August 26, 2011, 03:05:32 pm »
Having a bit of difficulty getting off the blocks here, and searched endlessly to try and solve this problem to no avail--
When I run my test code, it should simply open a window (and do a few simple things), however, the window that is opened is see-through (I can see whatever windows I have of other programs running beneath it, though it's screen shot of those programs (for example if it's a video, only the screen shot of the last frame appears in my 'sfml window')).
I've disabled windows opacity.
I tried Window.Clear() with various color schemes.
I've pulled out some of my hair.
Has anyone ever heard of this problem? I cannot find a way to solve it, just beginning here.
I'm running Windows Vista / Nvidia GeForce graphics card - my code is:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
int counter = 0;
sf::VideoMode VMode(800,600,32);
sf::RenderWindow Window(VMode, "View My Photo Hoe"); //,sf::Style::Fullscreen);
sf::Texture texture;
if (!texture.LoadFromFile("hoserBz2009.jpg"))
{
std::cout<<"Could not load file: hoserbz2009.jpg"<<std::endl;
return 1;
}
//sf::Sprite sprite(image);
int h = texture.GetHeight();
int w = texture.GetWidth();
sf::Sprite sprite;
sprite.SetTexture(texture);
string str1 = "I bet you do not see me.";
sf::Text txt1(str1);
//sprite.SetImage(image);
//sprite.SetPosition(100.0f,30.0f);
std::cout << h << " " << w<<std::endl;
sf::Shape Rect = sf::Shape::Rectangle (0,0,10,10, sf::Color::Red);
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}
//Window.SetBackgroundColor(sf::Color(200,0,0));
Window.Draw(sprite);
Window.Draw(txt1);
Window.Draw(Rect);
counter++;
std::cout<<"Displaying... "<<counter<<std::endl;
Window.Display();
Sleep(100);
Window.Clear();
} //end while loop
Window.Draw(Rect);
std::cout<<"Quit"<<std::endl;
return 0;
}
All help appreciated!