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

Author Topic: Draw Missing!?  (Read 35122 times)

0 Members and 2 Guests are viewing this topic.

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« on: August 04, 2008, 05:46:10 am »
i just updated to the latest SVN and for some reason my [window name].Draw function is missing!? what should i do?

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #1 on: August 04, 2008, 05:57:48 am »
nvmd, i needed a renderwindow instead of a window to draw images...when did that change?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #2 on: August 04, 2008, 06:03:34 am »
That never changed, there's nothing related to 2D graphics in sfml-window.
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #3 on: August 04, 2008, 06:57:38 am »
using VS 2008 + SVN version...its been awhile since ive used SFML

im getting a debug assertation, but im pretty sure im using the code right

i load the image here in the header file

Code: [Select]
int LoadImages()
{
if (!Opening.LoadFromFile("C:/Jeopardy/Other/Opening.jpg"))
return EXIT_FAILURE;


wrap up the function in the same file
Code: [Select]

int Load()
{
LoadImages();


then assign the image to a sprite in the main .cpp file
Code: [Select]
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Jeopardy!", sf::Style::Fullscreen);
Load();
OpeningImage.SetImage(Opening);


and display it after the event loop
Code: [Select]

App.Clear();
App.Draw(OpeningImage);
App.Display();


what am i doing wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #4 on: August 04, 2008, 06:59:54 am »
What is the assertion message ? On which line is it happening ?
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #5 on: August 05, 2008, 11:17:07 pm »
it happens when i get to the
Code: [Select]
App.Draw(OpeningImage);

breaking out of the program leads me to this section of code but points specifically to the line with _DEBUG_ERROR...

Code: [Select]
#if _HAS_ITERATOR_DEBUGGING
if (size() <= _Pos)
{
_DEBUG_ERROR("vector subscript out of range");
_SCL_SECURE_OUT_OF_RANGE;
}


error-debug assertation failed, line 779, vector subscript out of range

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #6 on: August 06, 2008, 02:44:19 am »
Line 779 of which file ? Can you run it in debug mode and get the callstack ?

Basically, I'm almost sure there isn't any "out of range" error with vectors in SFML, so the problem might come from your code.
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #7 on: August 06, 2008, 03:29:38 am »
my code just in case

Code: [Select]
#include "SFML/Quickstart.h"
#include "SFML/String Conversion.h"

std::string base = "../Jeopardy/Questions/Question";
std::string end = ".png";
std::string final;

sf::Sprite Categories[6];
sf::Sprite OpeningImage;

sf::Image n100;
sf::Image n200;
sf::Image n300;
sf::Image n400;
sf::Image n500;

sf::Image Category1;
sf::Image Category2;
sf::Image Category3;
sf::Image Category4;
sf::Image Category5;
sf::Image Category6;

sf::Image Question;
sf::Image Answer;
sf::Image Opening;
sf::Image FinalJeopardy;
sf::Image DailyDouble;

sf::Music OpeningMusic;
sf::Music FinalJeopardyMusic;

/*/int LoadQuestion(int QuesNumber)
{
std::string middle = Convert(QuesNumber);
std::string Q = base + middle + end;
if (!Ques.LoadFromFile(Q))
return EXIT_FAILURE;
}/*/

int LoadImages()
{
if (!Opening.LoadFromFile("C:/Jeopardy/Other/Opening.jpg"))
return EXIT_FAILURE;

if (!Category1.LoadFromFile("C:/Jeopardy/Categories/Slide1.gif"))
return EXIT_FAILURE;

if (!Category2.LoadFromFile("../Jeopardy/Categories/Slide2.gif"))
return EXIT_FAILURE;

if (!Category3.LoadFromFile("../Jeopardy/Categories/Slide3.gif"))
return EXIT_FAILURE;

if (!Category4.LoadFromFile("../Jeopardy/Categories/Slide4.gif"))
return EXIT_FAILURE;

if (!Category5.LoadFromFile("../Jeopardy/Categories/Slide5.gif"))
return EXIT_FAILURE;

if (!Category6.LoadFromFile("../Jeopardy/Categories/Slide6.gif"))
return EXIT_FAILURE;

if (!n100.LoadFromFile("../Jeopardy/Money/Slide1.bmp"))
return EXIT_FAILURE;

if (!n200.LoadFromFile("../Jeopardy/Money/Slide2.bmp"))
return EXIT_FAILURE;

if (!n300.LoadFromFile("../Jeopardy/Money/Slide3.bmp"))
return EXIT_FAILURE;

if (!n400.LoadFromFile("../Jeopardy/Money/Slide4.bmp"))
return EXIT_FAILURE;

if (!n500.LoadFromFile("../Jeopardy/Money/Slide5.bmp"))
return EXIT_FAILURE;

return EXIT_SUCCESS;
}

int LoadOpeningMusic()
{
if (!OpeningMusic.OpenFromFile("../Jeopardy/Music/Opening.wav"))
{
return EXIT_FAILURE;
};

return EXIT_SUCCESS;
}



int LoadFinalJeopardyMusic()
{
if (!FinalJeopardyMusic.OpenFromFile("../Jeopardy/Music/Final Jeopardy.wav"))
{
return EXIT_FAILURE;
};

return EXIT_SUCCESS;
}

void CategoryArray()
{
Categories[0] = sf::Sprite(Category1);
Categories[1] = sf::Sprite(Category2);
Categories[2] = sf::Sprite(Category3);
Categories[3] = sf::Sprite(Category4);
Categories[4] = sf::Sprite(Category5);
Categories[5] = sf::Sprite(Category6);
}

int Load()
{
LoadImages();
LoadOpeningMusic();
LoadFinalJeopardyMusic();
OpeningMusic.Play();
CategoryArray();

return EXIT_SUCCESS;
}



Code: [Select]
#include "Jeopardy.h"

int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Jeopardy!", sf::Style::Fullscreen);
Load();
OpeningImage.SetImage(Opening);

while(App.IsOpened())
    {
sf::Event Event;
while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
if ((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left))
App.Close();
};

App.Clear();
App.Draw(OpeningImage);
App.Display();
    };

return 1;
}


call stack

Code: [Select]
> Jeopardy.exe!std::vector<sf::Color,std::allocator<sf::Color> >::operator[](unsigned int _Pos=0)  Line 780 + 0x2e bytes C++
  Jeopardy.exe!sf::Image::Update()  Line 549 + 0xd bytes C++
  Jeopardy.exe!sf::Image::Bind()  Line 360 C++
  Jeopardy.exe!sf::Sprite::Render(sf::RenderTarget & __formal={...})  Line 192 C++
  Jeopardy.exe!sf::Drawable::Draw(sf::RenderTarget & Target={...})  Line 396 + 0x13 bytes C++
  Jeopardy.exe!sf::RenderTarget::Draw(const sf::Drawable & Object={...})  Line 105 C++
  Jeopardy.exe!main()  Line 24 C++
  Jeopardy.exe!_WinMain@16()  + 0x19 bytes C++
  Jeopardy.exe!__tmainCRTStartup()  Line 574 + 0x35 bytes C
  Jeopardy.exe!WinMainCRTStartup()  Line 399 C


the file that breaking out of the program leads to is vector.h (the vc 2008 sdk file i think)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #8 on: August 06, 2008, 06:13:18 am »
Ok, I've found the bug. There's no protection when creating an OpenGL texture from an empty image, I'll fix this. By the way, this means one of your images failed to load.
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #9 on: August 06, 2008, 06:52:17 am »
failed to load due to a bug or due to my code?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #10 on: August 06, 2008, 07:06:54 am »
Should be due to your code, but apparently you properly handle loading errors. Unless you try to load a valid empty image ;)

By the way, GIF is not a supported format.
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #11 on: August 07, 2008, 12:33:02 am »
that would explain it, all my images are gifs...

changing them to pngs should work then thnx

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #12 on: August 07, 2008, 02:06:32 am »
i changed them all to pngs but they still dont work! i get the same error, oddly my images wont bind to the sf::Image variables for some odd reason

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw Missing!?
« Reply #13 on: August 07, 2008, 02:34:19 am »
You should check the standard error output for any SFML message.

You should also use the value returned by your loading functions to actually do something useful when they report an error ;)
Laurent Gomila - SFML developer

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Draw Missing!?
« Reply #14 on: August 07, 2008, 03:15:34 am »
my images are failing to load...is my code for loading images incorrect because i checked the path and it is correct

 

anything