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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - jerryd

Pages: [1] 2
1
Window / sf::RenderWindow returns NULL pointer
« on: October 04, 2020, 05:04:40 am »
SFML forum,
 Windows 7

 I'm using SFML-2.5.1 with Visual Studio 2017.
 My program builds without any errors but I get an exception thrown because
 sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
 returns a NULL pointer.  Here's the entire program:

#include <SFML\Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
   window.close();
   return 0;
}

 I must be missing something.

jerryd

2
Window / Passing sheetRect to a function
« on: August 10, 2020, 09:15:34 pm »
SFML forum,
 I think this would related to a window problem.

 I'm using the sheetRect command successfully in the main flow of my program
 but when I pass it to a function it is grayed out and doesn't work.  The
 compiler doesn't complain and everything runs Ok.

here's the function declaration:
void drawToWindow(sf::RenderWindow &window, sf::IntRect &sheetRect);

here's the function call:
  drawToWindow(window, sheetRect);

here's the function:
void drawToWindow(sf::RenderWindow &window, sf::IntRect &sheetRect)
{
   sheetRect.top = 0;
   sheetRect.left = 0;
   suits.setTextureRect(sheetRect);
   suits.setPosition(50,1);

   window.clear(sf::Color::Green);
   window.draw(suits);
   window.draw(text);
   window.display();
}

The window commands work but not the sheetRects are grayed out?
As I stated this all works outside of the function.

jerryd

3
Graphics / rectSourceSprite out of scope
« on: August 09, 2020, 01:26:09 am »
SFML forum,

 I'm doing some sprite displaying in a function.
 I can do:
 sprite.setPosition(x,y);
 window.draw(sprite);

 but the compiler doesn't like:
 rectSourceSprite.left = 213;

 I have used all this command successfully outside of the function
 but the error message seems to indicate it's out of scope.

 I tried:
 sf::rectSourceSprite.left = 213;
 sprite.rectSourceSprite.left = 213;
 but they don't satisfy the compiler.

Any suggestions?
Jerry D


4
Window / RenderWindow Screen
« on: August 07, 2020, 07:09:18 pm »
sfml forum,
 I know there is a RenderWindow Screen command but I can't find any
 documentation about it.

 Anyone know if it's still valid and where I can read about it.

Jerry D

5
Graphics / Pixel Color
« on: July 04, 2017, 04:01:45 am »
SFML forum,

 How can I read the color of a specific pixel on the screen?

jerryd

6
General / [SOLVED]can't open sfml-window-d-2.dll
« on: July 03, 2017, 04:51:37 am »
SFML forum,

 SFML 2.4.2   Visual Studio 2017

 I have one project working and have started new one.

 I can build the new project with no errors but when I try to
 run it I get the error message: "The program can't start because
 sfml-window-d-2-dll is missing".

 This dll exists in C:\SFML-2.4.0\bin and I have checked the
 properties and they are all identical to my working project.

 What am I missing?

jerryd

7
Graphics / [SOLVED]One sprite for all my objects
« on: June 24, 2017, 05:17:49 am »
SFML forum,
 
 I'm using SFML but this might be a C++ OOP question.

 I want to use a sprite from a class in all my objects:



class Sprite
{
public:
    Sprite() {};

    sf::Texture MySprite;
    sf::Sprite sprite;

    void Load_Sprite()
    {
        if(!MySprite.loadFromFile("C:/sprites/MySprite.png"))
        { cout << " Texture Loading Error" << endl; system("pause"); }
        sprite.setTexture(MySprite);
    }
};
 

 But I have go use one of the objects to load the sprite so now it
 belongs to that object.  I would like to make the sprite static so
 I only need one and use it in every object.

 Any suggestions on how to do that?
Jerryd

8
General / How to load a png file for View
« on: June 15, 2017, 03:59:19 am »
SFML forum,
 I'm trying to figure out how to use View.

 I have read most of the documentation but I don't see
 how to load a png file that will be the View.  I tried to load
 it as I would a Texture but just got a compile error.

 sf::View view;
 if (!view.loadFromFile("C:/sprites/buildings.png"))
 { cout << " view Loading Error" << endl; system("pause"); }

 How do I do this?

jerryd

9
Graphics / [SOLVED] texture with VertexArray
« on: June 04, 2017, 06:59:52 am »
SFML forum,
 
 window.draw(edges, &texture);
 Program compiles and runs but the texture is never applied to the VertexArray "edges".

 I have successfully used this texture before on a quad.  The only difference is this quad is made with Points.

 I didn't know how to attach the program.

Any suggestions?
jerryd

10
General / Linking Problem with SFML/Visual Studio
« on: May 24, 2017, 04:47:10 am »
SFML forum,

 SFML 2.4.2   Visual Studio 2017

 I'm trying to link SFML to Visual Studio. I have followed all the
 steps in https://www.sfml-dev.org/tutorials/2.4/start-vc.php.
 Everything links and compiles until I put this line in my program:

 sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

 Then I get errors like:

 Error LNK2019 unresolved external symbol "public: __thiscall
 sf::String::String(char const *,class std::locale const &)"
 (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
 unresolved external symbol "public:_thiscall sf::VideoMode::VideoMode(
 unsigned int,unsigned)

 Note that the line #include <SFML/Graphics.hpp> causes no errors.

 Must be a linking error but I have double checked everything and
 SFML_STATIC is assigned.

Any suggestions?
jerryd



11
General / Missing libraries
« on: May 06, 2017, 11:32:28 pm »
SFML forum,
 I have been using SFML-2.4.0 with CodeLite and Code::Blocks for some
 time and am now trying to set up MS Visual C++ to use it.  The problem
 is MSVC wants me to include "sfml-graphics.lib" and other similar
 libraries but I don't have those.  Where or how do I get them?

Jerryd

12
Window / Window won't stay open
« on: October 27, 2016, 06:11:51 am »
SFML forum,
 Windows 7,  CodeLite 9.2.5, TDM-GCC-64,  SFML-2.3.1

 As soon as a window opens my program exits with the message:
 "SFML-Demo has stopped working"

 No error messages from the compiler.
 Here's the code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "My Window");
   
    while (window.isOpen())
    {
        sf::Event event;
       
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }
       
        window.display();
    }
}

 Any suggestions?

Jerry D.

13
General / pollEvent problem
« on: May 28, 2013, 04:25:06 am »
SFML forum,

 SFML 2.0  Visual c++ 2010

 I can take in keys pressed with a pollEvent in my main() successfully.

 But when I call a function that does another pollEvent to check keys pressed it always gets the last key typed from the pollEvent in the main().
  If I call the function without doing the pollEvent in main()  there is no key in the stdin buffer.

 I have read and tried all the methods for clearing the stdin buffer but none has worked.

 Any suggestions?

jerryd

14
Graphics / Double Buffering
« on: May 19, 2013, 05:55:32 am »
SFML forum,

 I have converted to 2.0,  not too bad.

 I have a question about the Screen.display() command, Screen being
 obtained by RenderWindow.

 With double buffering I call one buffer the off-screen buffer
 and the other one the on-screen buffer.

 It looks like when you do a Screen.display() these 2 buffers
 are flipped.  Is that correct?

 Other graphics libraries I have used just copy the off-screen
 buffer into the on-screen buffer and retain what was in the
 off-screen buffer.

 Is there a way to do this with SFML.

Jerryd

15
Graphics / Problem with setTextureRect SFML 2.0
« on: May 13, 2013, 03:04:20 am »
SFML forum,

 Switching over to SFML 2.0 from 1.6.

 The first project is a conversion of one that is working in 1.6.

 Not to bad so far but I'm have a problem with setTextureRect.

 In 1.6 I used:
   switch(num[index])
   {
      case 1:   Numbers.SetSubRect(sf::IntRect(0,0,63,63));   break;
      case 2:   Numbers.SetSubRect(sf::IntRect(64,0,127,63)); break;
      case 3:   Numbers.SetSubRect(sf::IntRect(128,0,191,63)); break;
      case 4: Numbers.SetSubRect(sf::IntRect(192,0,255,63)); break;
   }

 In 2.0 I use:
   switch(index)
   {
      case 1:   Numbers.setTextureRect(sf::IntRect(0,0,63,63));   break;
      case 2:   Numbers.setTextureRect(sf::IntRect(64,0,127,63)); break;
      case 3:   Numbers.setTextureRect(sf::IntRect(128,0,191,63)); break;
      case 4: Numbers.setTextureRect(sf::IntRect(192,0,255,63)); break;
   }

 Here's how I created the sprite in 2.0:
   sf::Texture MyNumbers;
   MyNumbers.loadFromFile("Numbers2.png");
   sf::Sprite Numbers;

 The problem is when index is 1 I get:
  1                          this is correct

 When it's 2 I get:
  2 3                       should be just  2

 When it's 3 I get:
  3 4                      should be just 3

 When it's 4 I get:
  4  ######          should be just 4

 The #s represent some garbage on the screen?
 
 The Numbers2.png file is attached.

Jerryd


[attachment deleted by admin]

Pages: [1] 2