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 - diegonolan

Pages: [1]
1
Graphics / Access Violation in when creating sf::Window
« on: August 28, 2012, 08:51:57 pm »
I am using VS2010 with sfml 2.0 rc and I am getting an access violation when creating a window.  I was able to make other sfml programs work fine, but my project file seems to be messing this one up.  This is the line of code the program fails at in WindowImplWin32.cpp.

 int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle));
 

I thought it was a unicode problem so I changed Project->Properties->General->Character Set to Use Multi-Byte Character Set but that didn't work.

I don't want to make a project from stract because I am using IBM cplex and all the settings are working for it but seem to conflict with sfml settings.  I attached my project file.



[attachment deleted by admin]

2
General / Using sfml with IBM's cplex optimizer
« on: July 26, 2012, 11:07:25 pm »
I am using IBM's cplex optimizer alongside with sfml to do some visualization of the results.  I can get it compiling and running fine but for some reason the sfml header files are recognized so Visual Studio is always red-under-lining anything in the sf namespace.  I also don't get any of the auto-completion of sf functions or classes.  This makes it more much more difficult to program because I don't have the library memorized.  Here is my project file with the settings required to run cplex.

I am using cplex v12.4 and the sfml-2.0 release candidate.



[attachment deleted by admin]

3
General / Problem Running OpenGL example with VS2010 sfml2.0-rc
« on: May 20, 2012, 10:16:38 pm »
I am trying to run the opengl example on the github page.  I got it to compile but when I run it it crashes and makes a strange beeping noise.  When I run the debugger it says it crashes on this when loading the background.jpg.

Code: [Select]
if (!backgroundTexture.loadFromFile("resources/background.jpg"))

Am I missing the jpg library or something?  I can't figure out what is going wrong.

4
General / Problem Building the SFML 2.0 Release Candidate
« on: May 17, 2012, 05:25:58 am »
I had sfml 2.0 running from the compiled source. I noticed that the sfml 2.0 release candidate was posted so I thought I would update and I am having trouble compiling a simple example, which I assume is a problem linking.

This is the error I get
main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>C:\Users\Nolan\documents\visual studio 2010\Projects\mapmaker\Debug\mapmaker.exe : fatal error LNK1120: 1 unresolved externals

and this is all the code I am using

#include <iostream>
#include <SFML/Graphics.hpp>

using std::cout;
using std::endl;

int main()
{
        sf::RenderWindow window(sf::VideoMode(300, 200), "SFML works!");
        sf::Text text("Hello SFML");

        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                }
                window.clear();
                window.draw( text );
                window.display();
        }

        return 0;
}
 

Everything compiles except the ' window.draw( text ); ' line so there is something wrong there but I am unsure what it is.  The new release came with precompiled .dll's so I didn't compile anything with cmake or Nmake.  Also I deleted all old sfml related stuff so there shouldn't be a problem with that.  This is visual studio  2010.

5
Graphics / Questions About Textures in SFML
« on: February 20, 2012, 01:32:40 am »
I have some questions regarding texture size and performance.

    Should textures width and heights always be powers of 2?  ie 128, 256, 512 etc I know it is important in other libraries but does sfml account for it?

    How do large images (100kb) affect performance?

    Whet is the best file format to use for the images? png, jpg... etc


Thanks

6
Graphics / Scrolling Text Issue
« on: February 04, 2012, 03:36:50 am »
Hello, I want text to scroll onto the screen.  Ie. display more and more characters every time step of some given string.  I also have it divided up into lines.  I got the code working up the method I am using seems to be very inefficient because I am getting very low framerates. I bet it is because I am using sf::Text::SetString a lot but I am unable to think of a better solution.  This is in SFML 2.0.

Here is the snippet of code I am using:

Code: [Select]

Time += float(Window.GetFrameTime())/1000.f;
      int charstoshow = int(Time*CHARSPERSECOND);
      for(unsigned int i=0;i<TextLines.size();++i)
      {
         // More or equal to the amount of chars in this line
         if(charstoshow >= TextLines[i].size())
         {
            TextToDisplay[i].SetString(TextLines[i]);
            Window.Draw(TextToDisplay[i]);
            charstoshow -= TextLines[i].size();
         }
         // this line will run out of characters
         else
         {
            std::stringstream ss;
            for(unsigned int j=0;j<charstoshow;++j)
            {
               ss << TextLines[i][j];
            }
            string temp;
            ss >> temp;
            TextToDisplay[i].SetString(temp);
            Window.Draw(TextToDisplay[i]);
            break;
         }
      }



Time is a timer i use to keep track of when the text should start scrolling and how far i am along.  Then i cast it to an int to find how many characters i should show.  TextLines is a stl vector holding strings for each line of text. Then text to display is a stl vector holding sf::Text for each line.  I set the strings then display them, when I run out of characters I break.  This is done each time step.  Any help on a better implementation would be appreciated.  Thanks.

7
I am going through the tutorial and when I hit finish on the configure part for the cmake it tells me I am missing the libgmp-3.dll file.  I've looked in the MinGW folder at is there so I don't really know what is going. I've uninstalled and installed cmake and it doesn't seem to work.

8
Graphics / Problem with PostFx in 1.6
« on: January 06, 2012, 03:21:51 am »
I'm having a problem getting a post effect to work in 1.6.  I got the tutorial working and then i tried applying the same effect to a project i am working on.  The only difference is that I have a class that deals with all the graphics.  So I added the sf::PostFx as a private member and then loaded it in the constructor of the class.  Then drew it using a pointer to the sf::RenderWindow i also stored in the class i guess minimum code is the following:

Code: [Select]


class Graphics
{
   public:
      Graphics();
      ~Graphics();
      void Draw();
      void Load(sf::RenderWindow * Window, Hud * MyHud, QuadTree * MyQuadTree, Objects * everything);
   private:
      sf::View View;
      sf::Vector2f Center;
      sf::Vector2f HalfSize;
      void ChangeView();
      QuadTree * QuadTreePtr;
      Hud * HudPtr;
      sf::RenderWindow * WindowPtr;
      Objects * Everything;
      Shadow Shadows;
      void DrawMenu();

      sf::PostFX Effect;
};


and then the draw function that draws all the objects on the screen for me

Code: [Select]


void Graphics::Draw()
{
   // Update view based on gambino's position
   ChangeView();

   // Get the mouse position in the range [0, 1]
   float X = WindowPtr->GetInput().GetMouseX()/
         static_cast<float>(WindowPtr->GetWidth());
   float Y = WindowPtr->GetInput().GetMouseY()/
         static_cast<float>(WindowPtr->GetHeight());

   // Update the effect parameters
   Effect.SetParameter("color", 0.5f, X, Y);

   // Clear screen of previous renderings
   WindowPtr->Clear();


   // Calculate New Position of background
   Everything->BkGrndImg.SetPosition(WindowPtr->GetView().GetCenter().x*
                                   (1-BGTRANSSCALE),
                                    WindowPtr->GetView().GetCenter().y*
                                   (1-BGTRANSSCALE));

   // Draw Background
   WindowPtr->Draw(Everything->BkGrndImg);
   WindowPtr->Draw(Effect);

   // Get Vector of objects to draw from quadtree
   sf::Rect<float> viewrect = View.GetRect();
   vector<BaseObject*> ToDraw = QuadTreePtr->Query(viewrect);
   for(unsigned int i=0;i<ToDraw.size();++i)
   {
      ToDraw[i]->Draw(*WindowPtr);
   }

   // Display Heads Up Display
   HudPtr->DrawStatusBars(*WindowPtr,Everything->Gambino);
   HudPtr->DisplayFrameRate(*WindowPtr);

   // Draw menu if open
   if(state.GetMenu())
   {
      DrawMenu();
   }

   // Draw QuadTree for debugging purposes if TAB is being held down
   if(state.DrawQuadTree)
   {
      QuadTreePtr->Draw();
   }


   WindowPtr->Display();
}


I'm just wondering what I could be doing wrong or if there is something about post effects that doesn't allow me to do it this way.  Again, the tutorial does work and i am able to load the effect with this project it just doesn't seem to do anything.

9
Graphics / Sprite sizes stored in sprite class if image changed
« on: November 12, 2011, 04:36:26 am »
Hello, I am making a vector of sprites to hold all the sprites necessary for animation and I am running into trouble.  When I set the sprite to a new image it maintains the size of the previous sprite

Code: [Select]

Spr.SetImage(*Images.GetImgPtr("image_1"));
sf::Vector2<float> vect = Spr.GetSize();
cout << vect.x << " " << vect.y << endl;

Spr.SetImage(*Images.GetImgPtr("image_2"));
vect = Spr.GetSize();
cout << vect.x << " " << vect.y << endl;



This is putting out the same size even though the two images are not the same size.  Any one have any idea what is going on?

Pages: [1]