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

Author Topic: Invalid ptr window title (resolved)  (Read 3328 times)

0 Members and 2 Guests are viewing this topic.

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« on: October 26, 2011, 01:30:29 pm »
Whenever I create a window with a call something like the following;

sf::Window window(sf::VideoMode(640, 480, 32),"window title", sf::Style::Default, sf::ContextSettings(32));

The program crashes and shows invalid ptr for the window title.

All of the examples Ive come across use methods similar to this and they have no issue (or Im assuming they wouldn't do it)

The only way I can get a program to run is by using a string variable

sf::String name = "My window Title";
then I pass that in to the window constructor

I initially started with 1.6 and realized that 2.0 was available so I updated.  Now under 1.6 I had a similar issue but the program would not crash it just displayed whatever leftovers happen to be in memory as my window title.
If I left 5 spaces at the beginning of the string "     start title"
then it would show the first part of the title properly and truncate
anything after aprox 10 chars.

I just found SFML yesterday , and have spent most of that time getting the libraries compiled and set up to work with vs2005 ,
I then moved to 2010 express to see if it was an issue with the IDE ,

I guess my main question is how do I know if Im using the correct version of the libraries for my compiler?

Ive gone through the CMake interface a few times. Ive actually compiled the project files and used the libraries it generated as well. (preferred the install option with CMake though , just tidier )

Its not a big deal that Im passing a string variable in , but Im just wondering if small inconsistencies like this are a result of not having proper libraries

I am using the -d libs and am running in debug configuration in vc.

Any info I could provide you guys with to help me figure this out?
I figure it has to be something to do with my libraries since a search on this problem only turned up a couple of results , none exactly like my situation .

Thanks for any input.
I just want to make sure Im set up properly before investing too much time finding work a rounds for things that Im just learning

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Invalid ptr window title (resolved)
« Reply #1 on: October 27, 2011, 02:58:12 pm »
What does this line do to your program?

sf::Window window(sf::VideoMode(800, 600), "SFML window");

PS. Welcome to SFML, you will like it :-)
SFML 2.1

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #2 on: October 27, 2011, 06:13:39 pm »
Thanks for the welcome,

If I can straighten this out , I think its going to be quite cool playing around with SFML, it looks like its put together in a really intuitive way. Thats what caught my eye when I was wondering around looking at different things.


when I try your suggestion above it causes the same crash,

This has to be something with my setup , but I just cant seem to figure out how.

It crashes and brings me to  the following section in the WindowImplWin32.cpp file

 if (HasUnicodeSupport())
    {
        wchar_t wTitle[256];
        int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle));
        wTitle[count] = L'\0';
        myHandle = CreateWindowW(ClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
    }

I get the same results when trying to create a Renderwindow as well
both work if I pass in a string var rather than a constant.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Invalid ptr window title (resolved)
« Reply #3 on: October 27, 2011, 06:16:38 pm »
Don't forget to link to debug libraries (-d suffix) in Debug mode.
Laurent Gomila - SFML developer

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #4 on: October 27, 2011, 06:19:13 pm »
One of the first things I did , didn't want to come here looking like a fool ,
until of course it turned out that I had to lol

*edit*

Just noticed the user name,
your the developer of this library?
If so , very cool to see you still/so active in the forums.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Invalid ptr window title (resolved)
« Reply #5 on: October 27, 2011, 06:25:48 pm »
In your project properties->General, what is Character Set currently set to?

Try Use Multi-Byte Character Set instead of Use Unicode Character Set..
SFML 2.1

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #6 on: October 27, 2011, 06:27:55 pm »
Use Multi-Byte Character Set
is currently set.

Figured it may be a unicode issue as well.

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #7 on: October 27, 2011, 06:32:33 pm »
int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle)

in this line ,
title.c_str()  shows as <bad Ptr>

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Invalid ptr window title (resolved)
« Reply #8 on: October 27, 2011, 06:41:39 pm »
Hold on - when you moved from VS2005 to VS2010, you recompiled the libraries with CMake, right?

What Microsoft SDKs have you got installed?
SFML 2.1

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #9 on: October 27, 2011, 06:54:45 pm »
Initially I hadn't recompiled no,
but eventually, I got rid of everything , all libraries and src, downloaded again started fresh with vc xpress.

Now I did run into some configuration errors with cmake,
Im not sure, if its relevant but, cmake was complaining about no backwards compatible number being set.

I set it to 1.6 , then cmake ran with out issue after that. Think it may be worth a shot , trying again?

Im not real experienced with make, always used an ide.

If you have a few minutes to respond to any config errors I get with cmake, so I could set things properly , Id be happy to try again, at least then I'd know I was working with a proper set of libs.

nothing installed but vc express.

by the way I apreciate the input so far.

Nemesis

  • Newbie
  • *
  • Posts: 7
    • View Profile
Invalid ptr window title (resolved)
« Reply #10 on: October 27, 2011, 07:20:57 pm »
Well thanks for the input guys,

I knew it had to be something to do with my setup. I must have mangled the dlls with make. I found a copy of 2.0 that was already precompiled for vc 2010 and replaced the files. I now can compile and run as expected.

Throughs an error on exit , but since its in the msvcr100d.dll. I'll look into that part after. Maybe just an incompatible version of that dll.

At least I can continue with the tutorials , and work on that issue when it becomes necessary.

Thanks again guys. Look forward to seeing ya's around the forums.