10
« on: January 24, 2011, 05:57:14 pm »
Hello so, I downloaded the SFML SDK and got it set up etc. Linked the correct libraries to the configuration (release to release,debug to debug etc) and tried to compile the source code from the "Integrating with Win32" example.
This gives me an access violation during runtime and it points me at
sf::RenderWindow SFMLView2;
So, i decide to remove that certain line and run it, now it gives me another error during runtime:
"A buffer overrun has occurred in sfmltesting.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.
For more details please see Help topic 'How to debug Buffer Overrun Issues'."
The whole source code:
#include "global.h"
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lp,int nCmdShow)
{
WNDCLASS WindowClass;
WindowClass.style = 0;
WindowClass.lpfnWndProc = &WndProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = NULL;
WindowClass.hCursor = 0;
WindowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BACKGROUND);
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = L"testclass";
RegisterClass(&WindowClass);
// Let's create the main window
HWND Window = CreateWindow(L"testclass", L"Orly", WS_SYSMENU | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, hInstance, NULL);
DWORD Style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
HWND View1 = CreateWindow(L"STATIC", NULL, Style, 50, 100, 300, 400, Window, NULL, hInstance, NULL);
sf::RenderWindow SFMLView1;
SFMLView1.Create(View1);
MSG Message;
Message.message = ~WM_QUIT;
while (Message.message != WM_QUIT)
{
if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
else
{
// SFML rendering code goes here
}
}
DestroyWindow(Window);
UnregisterClass(L"testclass", hInstance);
return EXIT_SUCCESS;
}
As you can see I am merely trying to create those so-called "sfmlviews". It works fine if I remove the
sf::RenderWindow SFMLView1;
SFMLView1.Create(View1);
It shows me one box to the left.
I am using VC++ Express 2010 and i have recompiled the library without errors and i have told the linker where to find the lib's. Anyone wants to shed some more light on this?
P.S. global.h only contains the declaration for WndProc and #include <SFML\Graphics.hpp> + the definition for WndProc is inside another .cpp file.
I am running Windows 7 atm.