Проблемы с GUI
  • IgoIgo June 2010
    У меня проблема с запуском чуть чуть измененного 6го туториала.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    #include<hge>
    #include<menuitem>
    #pragma comment (lib, "hge.lib")
    #pragma comment (lib, "hgehelp.lib")
     
    HGE *hge=0;
     
    HEFFECT snd;
    HTEXTURE tex;
     
    hgeGUI *gui;
    hgeFont *fnt;
    hgeSprite *spr;
    float tx;
    float ty;
     
    bool FrameFunc()
    {
     
    int id;
    static int lastid=0;
    float dt=hge->Timer_GetDelta();
     
     
    if(hge->Input_GetKeyState(HGEK_ESCAPE)) { lastid=3; gui->Leave(); };
     
    id=gui->Update(dt);
    if(id == -1)
    {
    switch(lastid)
    {
    case 1:
    {
    hge->System_Launch("hge.exe");
    return true;
    }
    case 2:
    gui->SetFocus(1);
    gui->Enter();
    break;
    case 3:
    {
    return true;
    }
    }
    }
    else if(id) { lastid=id; gui->Leave(); }
    return false;
    }
    bool RenderFunc()
    {
    hge->Gfx_BeginScene();
    gui->Render();
    fnt->SetColor(0xFFFFFFFF);
    hge->Gfx_EndScene();
     
    return false;
     
    }
     
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
    {
    hge = hgeCreate(HGE_VERSION);
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
    hge->System_SetState(HGE_USESOUND, true);
    hge->System_SetState(HGE_TITLE, "HGE");
    hge->System_SetState(HGE_LOGFILE, "data/launcher.log");
    hge->System_SetState(HGE_INIFILE, "data/launcher.ini");
    hge->System_SetState(HGE_FPS, 100);
    hge->System_SetState(HGE_WINDOWED, true);
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 400);
    hge->System_SetState(HGE_SCREENBPP, 32);
    if(hge->System_Initiate())
    {
    snd=hge->Effect_Load("data/sounds/frog.wav");
    tex=hge->Texture_Load("data/textures/cursor.png");
    fnt=new hgeFont("data/fonts/font1.fnt");
    spr=new hgeSprite(tex,0,0,32,32);
     
    if(!snd)
    {
    MessageBoxA(NULL, hge->System_GetErrorMessage(), "Cant load FROG.WAV Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    hge->System_Shutdown();
    hge->Release();
    return 0;
    }
    if(!tex)
    {
    MessageBoxA(NULL, hge->System_GetErrorMessage(), "Can't load CURSOR.PNG Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    hge->System_Shutdown();
    hge->Release();
    return 0;
    }
    if(!fnt)
    {
    MessageBoxA(NULL, hge->System_GetErrorMessage(), "Can't load font1.fnt Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    hge->System_Shutdown();
    hge->Release();
    return 0;
    }
     
    gui=new hgeGUI();
    gui->AddCtrl(new hgeGUIMenuItem(1,fnt, snd, 600, 100, 0.0f, "Играть"));
    gui->AddCtrl(new hgeGUIMenuItem(2,fnt, snd, 600, 200, 0.1f, "Опции"));
    gui->AddCtrl(new hgeGUIMenuItem(3,fnt, snd, 600, 300, 0.2f, "Выход"));
     
    gui->SetNavMode(HGEGUI_UPDOWN | HGEGUI_CYCLED);
    gui->SetCursor(spr);
    gui->SetFocus(1);
    gui->Enter();
     
    delete fnt;
    delete gui;
    delete spr;
    hge->System_Start();
    hge->Texture_Free(tex);
    hge->Effect_Free(snd);
    }
    hge->System_Shutdown();
    hge->Release();
    return 0;
    }

    все комплируется без проблем, но вот когда начинаешь запускать его в дебаге то вываливается окошко "продолжить или остановиться", а в output логе пишет :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    First-chance exception at 0x00414852 in game launcher.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
    Unhandled exception at 0x00414852 in game launcher.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
     
    > game launcher.exe!hgeGUI::Update() + 0x82 bytes
    game launcher.exe!FrameFunc() Line 27 + 0x12 bytes C++
    hge.dll!10008f07()
    [Frames below may be incorrect and/or missing, no symbols loaded for hge.dll]
    game launcher.exe!WinMainCRTStartup() Line 399 C
    kernel32.dll!7c817067()


    а переменной id присваевается ваще странное значение:
    1
    id = -858993460


    в чем проблема не понимаю :shock: . "Please help!!!"

    P.S. Компилю я VC++ 2008 express edition, а версия HGE 1.81
  • SQRederSQReder September 2010
    Наверное я поднимаю мертвую тему, но суть в следующем:
    1
    2
    3
    4
                delete fnt; 
    delete gui;
    delete spr;
    hge->System_Start();

    Объекты уничтожаются до того, как будут использованы во framefunc - неудивительно, что не работает.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (0)