Problem with hge and window 7
  • FraserFraser October 2009
    hello,

    I'm not sure if the problem I'm having is because I'm using windows 7 or not. Recently started to continue work on one of my projects with hge and when I load any textures I get the message "can't create texture" in the log.

    Has anyone experience this before or know what my problem is?


    Here's some code I wrote to test the problem, when I start the program I just get a white screen and the can't create texture message in the log.
    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
    #include "hge.h"
    #include "hgesprite.h"
     
    HGE* hge = 0;
    hgeSprite* spr = 0;
     
    bool RenderFunc() {
    hge->Gfx_BeginScene();
    hge->Gfx_Clear(0);
    spr->Render(0, 0);
    hge->Gfx_EndScene();
    return false;
    }
     
    bool FrameFunc() {
    if(hge->Input_GetKeyState(HGEK_ESCAPE)) {
    return true;
    }
    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_WINDOWED, true);
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 600);
    hge->System_SetState(HGE_LOGFILE, "log.log");
     
    HTEXTURE tex = hge->Texture_Load("image.png");
    spr = new hgeSprite(tex, 0, 0, 800, 600);
     
    if(hge->System_Initiate()) {
    hge->System_Start();
    } else {
    MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    }
    delete spr;
    hge->Texture_Free(tex);
    hge->System_Shutdown();
    hge->Release();
     
    return 0;
    }
  • ProfEclipseProfEclipse October 2009
    You can't call any graphics loading functions until after you call System_Initiate. The directx graphics device isn't created until that has been called.
  • AkkernightAkkernight October 2009

    You can't call any graphics loading functions until after you call System_Initiate. The directx graphics device isn't created until that has been called.



    hmm... Just wondering, does HGE describe that anywhere? Like in the documentary? I can't remember reading it...
  • ProfEclipseProfEclipse October 2009

    You can't call any graphics loading functions until after you call System_Initiate. The directx graphics device isn't created until that has been called.



    hmm... Just wondering, does HGE describe that anywhere? Like in the documentary? I can't remember reading it...

    Yes. Second paragraph in the Remarks section for HGE::System_Initiate.
  • FraserFraser October 2009
    Crap I can't believe I over looked somthing so simple, I feel like a complete idiot lol

    thanks ProfEclipse.
  • ProfEclipseProfEclipse October 2009
    No worries. Sometimes it just takes an extra pair of eyes. :-)
  • jayaxidjayaxid July 2011
    Hi prof eclipse just need a little your pair of eyes :)

    I also do the same just like fraser did,

    below I attach my code
    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
    #include <windows>
    #include <iostream>
    #include <hge>
     
    HGE *hge = 0;
    hgeQuad quad;
     
    HEFFECT snd;
     
    float x = 100.0f, y = 100.0f;
    float dx = 0.0f, dy = 0.0f;
     
    const float speed = 90;
    const float friction = 0.98f;
     
    // boom is to play the sound of collision
    void boom()
    {
    int pan = (int) ((x - 400) / 4);
    float pitch = (dx * dx + dy * dy) * 0.0005f + 0.2f;
    hge->Effect_PlayEx(snd, 100, pan, pitch);
    }
     
    bool FrameFunc()
    {
    float dt = hge->Timer_GetDelta();
     
    // if user press escape key then it stop the scene and will close the app
    if (hge->Input_GetKeyState(HGEK_ESCAPE))
    return true;
     
    // get key pressed from user
    // key pressed is left arrow
    if (hge->Input_GetKeyState(HGEK_LEFT))
    dx -= speed * dt;
     
    // key pressed is right arrow
    if (hge->Input_GetKeyState(HGEK_RIGHT))
    dx += speed * dt;
     
    // key pressed is up arrow
    if (hge->Input_GetKeyState(HGEK_UP))
    dy -= speed * dt;
     
    // key pressed is down arrow
    if (hge->Input_GetKeyState(HGEK_DOWN))
    dy += speed * dt;
     
    // do the calculation with friction (gesekan)
    dx *= friction;
    dy *= friction;
    x += dx;
    y += dy;
     
    // if position X is over then 784 (boundaries on the right side) then boom!!! sound is activate
    if(x > 784)
    {
    x = 784 - (x - 784);
    dx =- dx;
    boom();
    }
     
    // if position X is less then 16 (boundaries on the left side) then boom!!! sound is activate
    if(x <16> 584)
    {
    y = 584 - (y - 584);
    dy =- dy;
    boom();
    }
     
    // if position Y is less then 16 (boundaries on the top side) then boom!!! sound is activate
    if(y <16>Gfx_BeginScene();
    hge->Gfx_Clear(0);
    hge->Gfx_RenderQuad(&quad);
    hge->Gfx_EndScene();
     
    return false;
    }
     
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    hge = hgeCreate(HGE_VERSION);
     
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    hge->System_SetState(HGE_WINDOWED, true);
    hge->System_SetState(HGE_USESOUND, false);
    //hge->System_SetState(HGE_TITLE, "HGE Tutorial 01 - Minimal HGE application");
    hge->System_SetState(HGE_TITLE, "HGE Tutorial 02 - Using input, sound and rendering");
    hge->System_SetState(HGE_HIDEMOUSE, false);
    hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
    hge->System_SetState(HGE_FPS, 100);
    hge->System_SetState(HGE_SCREENWIDTH, 800);
    hge->System_SetState(HGE_SCREENHEIGHT, 800);
    hge->System_SetState(HGE_SHOWSPLASH, false);
     
    // to blend the picture
    quad.blend = BLEND_ALPHAADD | BLEND_COLORMUL | BLEND_ZWRITE;
     
    for (int i = 0; i <4>System_Initiate())
    {
    snd = hge->Effect_Load("D:\menu.wav");
    quad.tex = hge->Texture_Load("D:\button.png");
     
    hge->System_Start();
    }
    else
    {
    MessageBoxA(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
    }
    hge->Texture_Free(quad.tex);
    hge->Effect_Free(snd);
     
    hge->System_Shutdown();
    hge->Release();
     
    return 0;
    }


    I'm using Visual C++ .NET2005 in developing this project, but the result is not like what i'm expect it just show a black screen with an orange box located in 100, 100 (probably), I also using Windows 7.

    i'm very confuse where did i do the wrong code, can you help me? htx in advanced :)
  • Please edit your post and make sure to click the "Disable HTML in this post" checkbox. Otherwise, the forum tends to eat parts of your code. Right now, I can't tell what your code actually looks like.
  • jayaxidjayaxid July 2011
    hi prof,

    already clear after one night checking the whole code... just to add "\" in the filename...

    thx again prof...
  • Glad you got it sorted out.

    As a tip for the future, you can use forward slashes instead of backslashes in file paths. That way you don't have to worry about double slashes. e.g.:

    "D:/menu.wav"

    instead of:

    "D:\\menu.wav"

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)