#include <SDL/SDL.h>
#include "SDL/video.h"
#include "SDL/events.h"
#include "filesrc.h"
#include "log.h"
void MainGameLoop();
Log outLog("OutLog.txt");
Log errLog("ErrLog.txt");
Screen screen("Icon.bmp","",640,480,0,SDL_RESIZABLE,0xffffff00,"Klingis","");
Event event(screen,KEY_OPTION_DOWN);
Image *test;
int SDL_main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
InitFileDirs();
InitKeys();
SetFileDir(FILE_DIR_DATA);
test = new Image("test.bmp");
test->setColor(0,0,0,0);
test->setMask(0,0,0,255);
test->drawHorzLine(15,0,100);
// screen.setMask(0xff,0xff,0);
screen.setColor(0xff,0x00,0x00);
MainGameLoop();
SetFileDir(FILE_DIR_APP);
screen.saveBMP("ScreenShot.bmp");
test->saveBMP("test.bmp");
delete test;
return 0;
}
void MainGameLoop()
{
bool running = true;
while (running)
{
screen.fillBG();
// screen.drawRect(10,10,100,100);
test->centerBlit();
if (event.update())
{
switch (event.type())
{
case SDL_QUIT:
running = false;
break;
default:
break;
}
}
screen.update();
}
}
void Screen::setIcon(const std::string &iconFile, const std::string &maskFile)
{
SDL_Surface *icon;
std::ifstream maskIfs;
Uint8 *mask;
SetFileDir(GetDataDir());
if (iconFile.empty())
icon = NULL;
else
icon = SDL_LoadBMP(FilePath(iconFile).c_str());
if (maskFile.empty())
mask = NULL;
else
{
maskIfs.open(FilePath(maskFile).c_str());
if (maskIfs.good())
{
int size = 32 * 32;
mask = new Uint8[size];
maskIfs.read((char *)mask,size);
maskIfs.close();
}
else
mask = NULL;
}
if (icon || mask)
setIcon(icon,mask);
}
Screen::Screen(const std::string &iconFile, const std::string &iconMaskFile, int width, int height, int bitpp, Uint32 flags, Uint32 bgColor, const std::string &title, const std::string &iconName)
{
// setIcon(iconFile,iconMaskFile);
SetFileDir(GetDataDir());
SDL_WM_SetIcon(SDL_LoadBMP(FilePath(iconFile).c_str()),0);
this->width = width;
this->height = height;
this->bitpp = bitpp;
this->flags = flags;
this->bgColor = bgColor;
success = create();
setCaption(title,iconName);
}
[Solved] SDL_WM_SetIcon crashes
I can't set the window icon, not even with SDL_LoadBMP:
Do you know why?
[Edited by - programering on May 30, 2009 12:24:13 PM]
Quote:Original post by programeringNope.
I can't set the window icon, not even with SDL_LoadBMP:
*** Source Snippet Removed ***
Do you know why?
But if you give us some sort of information we might. For a start, where does the crash occur, and what's the message? Have you used your Debugger to see that everything is as it should be (E.g. that the pointers are valid, and you managed to load the BMP and so on)?
Yes the SDL_Surface loads, and I know it's SDL_WM_SetIcon(SDL_LoadBMP(FilePath(iconFile).c_str()),0); causing the crash.
Call Stack
SDL! 0039c2ac() - Code Segment:
$E36() line 15 + 223 bytes
$E39() + 29 bytes
MSVCRT! 77c29d7a()
Output
Call Stack
SDL! 0039c2ac()$E36() line 15 + 223 bytes$E39() + 29 bytesMSVCRT! 77c29d7a()KLINGIS! WinMainCRTStartup + 202 bytesKERNEL32! 7c816fe7()
SDL! 0039c2ac() - Code Segment:
0039C290 push ecx0039C291 mov edx,dword ptr ds:[3B19DCh]0039C297 push ebx0039C298 mov ebx,dword ptr [esp+0Ch]0039C29C mov eax,edx0039C29E push ebp0039C29F push esi0039C2A0 test ebx,ebx0039C2A2 mov dword ptr [esp+0Ch],eax0039C2A6 je 0039C3530039C2AC mov eax,dword ptr [eax+104h] // <-- Here.0039C2B2 test eax,eax0039C2B4 je 0039C3530039C2BA mov ecx,dword ptr [esp+18h]0039C2BE test ecx,ecx0039C2C0 jne 0039C34B0039C2C6 mov eax,dword ptr [ebx+8]0039C2C9 mov dword ptr [esp+14h],ecx0039C2CD add eax,70039C2D0 imul eax,dword ptr [ebx+0Ch]0039C2D4 cdq0039C2D5 and edx,70039C2D8 add eax,edx0039C2DA mov esi,eax0039C2DC sar esi,30039C2DF push esi0039C2E0 call dword ptr ds:[3A110Ch]0039C2E6 mov ebp,eax0039C2E8 add esp,40039C2EB test ebp,ebp0039C2ED je 0039C3530039C2EF mov ecx,esi0039C2F1 push edi0039C2F2 mov edx,ecx0039C2F4 or eax,0FFh0039C2F7 mov edi,ebp0039C2F9 shr ecx,20039C2FC rep stos dword ptr [edi]0039C2FE mov ecx,edx0039C300 and ecx,30039C303 rep stos byte ptr [edi]0039C305 mov eax,dword ptr [ebx]0039C307 pop edi0039C308 test ah,10h0039C30B mov ecx,10039C310 jne 0039C3160039C312 mov ecx,dword ptr [esp+14h]0039C316 test eax,10000h0039C31B je 0039C3200039C31D or ecx,20039C320 test ecx,ecx0039C322 je 0039C32F0039C324 push ecx0039C325 push ebp0039C326 push ebx0039C327 call 0039C3600039C32C add esp,0Ch0039C32F mov eax,dword ptr [esp+0Ch]0039C333 push ebp0039C334 push ebx0039C335 push eax0039C336 call dword ptr [eax+104h]0039C33C push ebp0039C33D call dword ptr ds:[3A1104h]0039C343 add esp,10h0039C346 pop esi0039C347 pop ebp0039C348 pop ebx0039C349 pop ecx0039C34A ret0039C34B push ecx0039C34C push ebx0039C34D push edx0039C34E call eax0039C350 add esp,0Ch0039C353 pop esi0039C354 pop ebp0039C355 pop ebx0039C356 pop ecx0039C357 ret
$E36() line 15 + 223 bytes
#include <SDL/SDL.h>#include "SDL/video.h"#include "SDL/events.h"#include "filesrc.h"#include "log.h"void MainGameLoop();Log outLog("OutLog.txt");Log errLog("ErrLog.txt");/* The green arrow --> */ Screen screen("Icon.bmp","",640,480,0,SDL_RESIZABLE,0xffffff00,"Klingis","");Event event(screen,KEY_OPTION_DOWN);Image *test;int SDL_main(int argc, char *argv[]){ SDL_Init(SDL_INIT_VIDEO); InitFileDirs(); InitKeys(); SetFileDir(FILE_DIR_DATA); test = new Image("test.bmp"); test->setColor(0,0,0,0); test->setMask(0,0,0,255); test->drawHorzLine(15,0,100);// screen.setMask(0xff,0xff,0); screen.setColor(0xff,0x00,0x00); MainGameLoop(); SetFileDir(FILE_DIR_APP); screen.saveBMP("ScreenShot.bmp"); test->saveBMP("test.bmp"); delete test; return 0;}void MainGameLoop(){ bool running = true; while (running) { screen.fillBG(); // screen.drawRect(10,10,100,100); test->centerBlit(); if (event.update()) { switch (event.type()) { case SDL_QUIT: running = false; break; default: break; } } screen.update(); }}
$E39() + 29 bytes
$E39:00404890 push ebp00404891 mov ebp,esp00404893 sub esp,40h00404896 push ebx00404897 push esi00404898 push edi00404899 lea edi,[ebp-40h]0040489C mov ecx,10h004048A1 mov eax,0CCCCCCCCh004048A6 rep stos dword ptr [edi]004048A8 call $E36 (004048d0)004048AD call $E38 (00404a80)004048B2 pop edi004048B3 pop esi004048B4 pop ebx004048B5 add esp,40h004048B8 cmp ebp,esp004048BA call _chkesp (0040869c)004048BF mov esp,ebp004048C1 pop ebp004048C2 ret
MSVCRT! 77c29d7a()
77C29D0E int 377C29D0F int 377C29D10 int 377C29D11 int 377C29D12 int 377C29D13 mov edi,edi77C29D15 push ebp77C29D16 mov ebp,esp77C29D18 push 77C040A4h77C29D1D call dword ptr ds:[77C010E8h]77C29D23 test eax,eax77C29D25 je 77C29D3C77C29D27 push 77C04094h77C29D2C push eax77C29D2D call dword ptr ds:[77C010D0h]77C29D33 test eax,eax77C29D35 je 77C29D3C77C29D37 push dword ptr [ebp+8]77C29D3A call eax77C29D3C push dword ptr [ebp+8]77C29D3F call dword ptr ds:[77C0121Ch]77C29D45 int 377C29D46 int 377C29D47 int 377C29D48 int 377C29D49 int 377C29D4A int 377C29D4B push 877C29D4D call 77C2A5BB77C29D52 pop ecx77C29D53 ret77C29D54 int 377C29D55 int 377C29D56 int 377C29D57 int 377C29D58 int 377C29D59 push 877C29D5B call 77C2A51977C29D60 pop ecx77C29D61 ret77C29D62 int 377C29D63 int 377C29D64 int 377C29D65 int 377C29D66 int 377C29D67 mov edi,edi77C29D69 push ebp77C29D6A mov ebp,esp77C29D6C push esi77C29D6D mov esi,dword ptr [ebp+8]77C29D70 jmp 77C29D7D77C29D72 mov eax,dword ptr [esi]77C29D74 test eax,eax77C29D76 je 77C29D7A77C29D78 call eax77C29D7A add esi,4 // <-- Green arrow here.77C29D7D cmp esi,dword ptr [ebp+0Ch]77C29D80 jb 77C29D7277C29D82 pop esi77C29D83 pop ebp77C29D84 ret77C29D85 int 377C29D86 int 377C29D87 int 377C29D88 int 377C29D89 int 377C29D8A mov eax,[77C500F8]77C29D8F test eax,eax77C29D91 je 77C29D9577C29D93 call eax77C29D95 push esi77C29D96 mov ecx,77C01284h77C29D9B mov esi,77C0129Ch77C29DA0 xor eax,eax77C29DA2 cmp ecx,esi77C29DA4 push edi77C29DA5 mov edi,ecx77C29DA7 jae 77C29DC077C29DA9 test eax,eax77C29DAB jne 77C29DD377C29DAD mov ecx,dword ptr [edi]77C29DAF test ecx,ecx77C29DB1 je 77C29DB577C29DB3 call ecx77C29DB5 add edi,477C29DB8 cmp edi,esi77C29DBA jb 77C29DA977C29DBC test eax,eax77C29DBE jne 77C29DD377C29DC0 push 77C01280h77C29DC5 push 77C01278h77C29DCA call 77C29D6777C29DCF pop ecx77C29DD0 pop ecx77C29DD1 xor eax,eax77C29DD3 pop edi77C29DD4 pop esi77C29DD5 ret
Output
Loaded 'ntdll.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system\SDL_image.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system\SDL.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.Loaded symbols for 'C:\WINDOWS\system32\MSVCP60D.DLL'Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.First-chance exception in Klingis.exe (SDL.DLL): 0xC0000005: Access Violation.The program 'C:\Save\Projects\Programming\Klingis Entertainment\Klingis\Cpp\Debug\Klingis.exe' has exited with code 0 (0x0).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement