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

Author Topic: Textures and RenderTextures broken  (Read 4638 times)

0 Members and 1 Guest are viewing this topic.

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« on: August 25, 2011, 07:23:49 pm »
I tried using a renderTexture earlier but the program would just close straight away.
I am also using a Texture like this:

Code: [Select]
#include "TitleScreen.hpp"

TitleScreen::TitleScreen()
{

}

TitleScreen::TitleScreen(sf::RenderWindow &App)
{
    app = &App;
    titleImage.LoadFromFile("./data/Title.png");
    titleImage.Bind();
}

TitleScreen::~TitleScreen(){}

void TitleScreen::Update()
{

}

void TitleScreen::Draw()
{
    app->Draw(sf::Sprite(titleImage ));
}


but I just et this image

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #1 on: August 25, 2011, 07:26:49 pm »
Where is the RenderTexture? Why do you Bind() the texture after loading it?

Can you show a complete and minimal example that reproduces your problem please?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #2 on: August 25, 2011, 07:45:59 pm »
This is my current code, I currently am not using a render Texture as I thought I coud get rid of it by just using different Views

http://pastebin.com/Mk3jjdiV

A simple example of how I use the texture would be:
Code: [Select]


int main( int argc, const char* argv[] )
{
   sf::RenderWindow App;
   sf::Texture titleImage;
titleImage.LoadFromFile("./data/Title.png");

sf::ContextSettings Settings;
Settings.DepthBits         = 24; // Request a 24 bits depth buffer
Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
Settings.AntialiasingLevel = GlobalSettings::globalSettings.AntiAliasing;  // Request 2 levels of antialiasing
Settings.MajorVersion = 2;
Settings.MinorVersion = 1;



if(GlobalSettings::globalSettings.FullScreen)
App.Create(sf::VideoMode(800, 600, sf::VideoMode::GetDesktopMode().BitsPerPixel), GlobalSettings::globalSettings.getWindowName(), sf::Style::Fullscreen ,Settings);
else
App.Create(sf::VideoMode(800, 600, sf::VideoMode::GetDesktopMode().BitsPerPixel), GlobalSettings::globalSettings.getWindowName(), sf::Style::Default ,Settings);


App.EnableVerticalSync(false);



try{
std::cout << "Using OpenGL " << App.GetSettings().MajorVersion << "." << App.GetSettings().MinorVersion << std::endl;

if ((App.GetSettings().MajorVersion < Settings.MajorVersion) || (App.GetSettings().MajorVersion == Settings.MajorVersion && App.GetSettings().MinorVersion < Settings.MinorVersion))
{
std::cout << "Sorry but a minimum of OpenGL "<< Settings.MajorVersion <<"."<< Settings.MinorVersion <<" is required"<<std::endl;
std::cout << "Try updating your drivers." << std::endl;
return false;
}

}
catch(int e){
std::cout << "Failed to get OpenGL version. " << e << std::endl;

return false;
}

GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
std::cout << "Error: " << glewGetErrorString(err) << std::endl;
return false;
}
else
{
std::cout << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
}



   App.SetFramerateLimit(60 );
App.ShowMouseCursor(false);


while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.PollEvent(Event))
{
   // Close window
                if (Event.Type == sf::Event::Closed)
                    App.Close();

                // Escape key pressed
                if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                    App.Close();

                if (Event.Type == sf::Event::Resized)
                    glViewport(0, 0, Event.Size.Width, Event.Size.Height);
            }



            App.SetActive();
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                    // Dark blue background
                    glClearColor(0.392156863f, 0.584313725f, 0.929411765f, 0.0f);


            switch(gameStage)
            {
                case intro:
                {
                    App.SaveGLStates();
                    App.RestoreGLStates();
                    break;
                }
                case menu:
                {
                    App.SaveGLStates();
                   App.Draw(sf::Sprite(titleImage ));
                    App.RestoreGLStates();
                    break;
                }
                case game:
                {


                    break;
                }
                case options:
                {
                    break;
                }
                case quit:
                {
                    break;
                }
            }




#ifdef  THIS_DEBUG
    App.SaveGLStates();
    std::stringstream ss;
ss << App.GetFrameTime();
sf::Text string(ss.str() + " ms",sf::Font::GetDefaultFont(), 14);
string.SetPosition(5,5);
App.Draw(string);
    App.RestoreGLStates();
#endif


            // Display window contents on screen
App.Display();
}
}



    return 0;
}


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #3 on: August 25, 2011, 09:27:31 pm »
Ok thanks. So this code displays the artifact shown in your first message?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #4 on: August 25, 2011, 09:58:23 pm »
Well I made that up as I went so might not be exactly it but more or less


Here is code I have tried out: http://pastebin.com/B81PJ4uG
And gives me the broken image, it also just blocks the window input so I cant close it and need to stop it via the IDE

It seems to not be happening all the time with that code, however when it doesnt happen the image still doesnt display

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #5 on: August 25, 2011, 10:20:28 pm »
Works for me (I just disabled GLEW).
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #6 on: August 25, 2011, 10:24:35 pm »
tried disabeling Glew but still did the same, guess it could be the drivers or something.
Do you know if there is anyway I can check?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #7 on: August 25, 2011, 10:50:52 pm »
The only way would be to run an OpenGL application that doesn't use SFML.

And also make sure that your graphics drivers are up-to-date. What's your graphics card and OS?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #8 on: August 25, 2011, 10:53:43 pm »
Im on fedora 15, and the graphics card is an intel GMA 4500
It works fine on windows which just makes me think its that linux is using outdated drivers

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Textures and RenderTextures broken
« Reply #9 on: August 25, 2011, 10:59:39 pm »
I've made it my holy cause to fight Intel integrated graphic cards whenever I find em...

Don't trust em', nugh' said! Their development tools(Vtune and like) is the best... but please Intel, STAY WITH CPU!
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #10 on: August 25, 2011, 11:48:42 pm »
Just tried the linux version of Osmos and it worked fine :/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #11 on: August 25, 2011, 11:52:12 pm »
Is it still wrong without OpenGL? In other words, can you try to make the above code as minimal as possible?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #12 on: August 26, 2011, 12:05:19 am »
Its till broken, however with out the openGL stuff I can now close the window.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Textures and RenderTextures broken
« Reply #13 on: August 26, 2011, 12:14:09 am »
So can you please show me the simplest code possible that still produces the problem...?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Textures and RenderTextures broken
« Reply #14 on: August 26, 2011, 12:26:47 am »
Code: [Select]

#include <SFML/Graphics.hpp>


int main( int argc, const char* argv[] )
 {
    sf::RenderWindow App;
    sf::Texture titleImage;
 titleImage.LoadFromFile("./data/Title.png");

    App.Create(sf::VideoMode(800, 600, 32), "Test");




 while (App.IsOpened())
       {
          // Process events
          sf::Event Event;
          while (App.PollEvent(Event))
          {
              // Close window
                 if (Event.Type == sf::Event::Closed)
                     App.Close();

                 // Escape key pressed
                 if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                     App.Close();

             }


             App.Clear();

                    App.Draw(sf::Sprite(titleImage ));




             // Display window contents on screen
          App.Display();
       }




     return 0;
 }


Linking with
Code: [Select]

-lsfml-graphics
-lsfml-window
-lsfml-system