Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: See-Through Window Problem  (Read 3369 times)

0 Members and 1 Guest are viewing this topic.

SinisterRainbow

  • Newbie
  • *
  • Posts: 5
    • View Profile
See-Through Window Problem
« 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:



Code: [Select]
#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!

SinisterRainbow

  • Newbie
  • *
  • Posts: 5
    • View Profile
Temp Solution - but only temp
« Reply #1 on: August 26, 2011, 04:54:47 pm »
Could this be a bug with sfml? I can get it to work when I change my code FROM:
Code: [Select]
 sf::VideoMode VMode(800,600,32);
    sf::RenderWindow Window(VMode,"Pong!");


TO:
Code: [Select]
sf::RenderWindow Window(sf::VideoMode::GetDesktopMode(),"Pong!",sf::Style::Fullscreen);

I've tried varations of Style to no avail, and infact, ONLY "sf::Style::Fullscreen" works. (I can get 800x600 to work (tested) and likely others as well), but only "Fullscreen"..

I also found one person with the same problem, but he also didn't seem to have a solution other than rebooting his computer (which doesn't work for me) -- see: http://www.sfml-dev.org/forum/viewtopic.php?t=1242&sid=0640b1a157b92b4388c95caa3f524932

Thanks.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
See-Through Window Problem
« Reply #2 on: August 26, 2011, 06:28:58 pm »
What you are seeing is left-over data or something like that. It's not a bug. Just call the clear function on the window and you are done.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
See-Through Window Problem
« Reply #3 on: August 28, 2011, 07:57:46 pm »
Window.Clear() should come before Window.Display(), not sure if that's the problem...

Also why are you calling Window.Draw(Rect) after the window loop?
Need a place to upload your code, files or screenshots? Use SFML Uploads!

SinisterRainbow

  • Newbie
  • *
  • Posts: 5
    • View Profile
Hrm.. Still not working
« Reply #4 on: August 29, 2011, 08:21:04 am »
I appreciate the feedback - still seems to have problems, no matter where I Window.Clear();..

So I simply created a very very simple program - taken (and modified to work) from the sfml documentation . This again works in full screen, but when windowed, it fails on me, it creates the window, blank, then hangs.

The code is:

Code: [Select]
#include <SFML/Graphics.hpp>
using namespace std;

int main(void)
{

 // Create a new render-window
 sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window",sf::Style::Default);//Fullscreen);

 // Create a new render-texture
 sf::RenderTexture texture;

texture.Create(500, 500);

 // The main loop
 while (window.IsOpened())
 {
    // Event processing
    // ...

    // Clear the whole texture with red color
    texture.Clear(sf::Color::Red);


    // We're done drawing to the texture
    texture.Display();

    // Now we start rendering to the window, clear it first
    window.Clear();

    // Draw the texture
    sf::Sprite sprite(texture.GetTexture());
    window.Draw(sprite);

    // End the current frame and display its contents on screen
    window.Display();
 }
}


I've tried with and without the sf::Default tag..

I'm thinking it's something to do with my OS version or hardware related in some way.

Running Nvidia GeForce 9600GT (with the latest drivers)
Windows Vista Version 6.0 (Build 6000).


I just don't see how it doesn't work in windowed mode, but works fine fullscreen, it's beyond my scope of understanding, just picking up sfml 3 days ago.

BTW - I should note, I downloaded a program made with C++/SFML called CosmoScroll - it also runs in windowed mode, but is blank on me (I can hear the music fine).

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
See-Through Window Problem
« Reply #5 on: August 29, 2011, 08:24:57 am »
are you running in debug and linking against debug libraries?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

SinisterRainbow

  • Newbie
  • *
  • Posts: 5
    • View Profile
SOLVED.. sort of.
« Reply #6 on: August 29, 2011, 08:40:03 am »
Hi Groogy - Yah, running in debug -

WELL - I got it to work! -- Sort of.

This seems to be an issue with vista and the DWM. - The CosmoScroll game I got to run by going to properties and disabling the "Desktop Composition"..

Soooo, I disabled aero and vuala, the program runs, at least for a few seconds until it terminates with an apphang.. but i'm not so concerned about this at the moment, seems the major problem has been solved.

Appreciate all the feedback, hope this helps someone in the future.