GoaLitiuM / bindbc-bgfx

Dynamic and static D bindings for bgfx
Boost Software License 1.0
21 stars 1 forks source link

Simple app not working. Need help. #2

Closed SuperDIMMaX closed 4 years ago

SuperDIMMaX commented 4 years ago

I compile bgfx to dll and copy-paste example and get:

Program exited with code -1073741819
The terminal process terminated with exit code: 2

on bgfx_init_ctor(&init); -

Exception has occurred: W32/0xc0000005
Unhandled exception at 0x0000000000000000 in project_d6.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

and how compile with static lib? I try, but get errors: LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library and bgfx.lib(renderer_d3d9.obj) : error LNK2019: unresolved external symbol __imp_SetWindowPos referenced in function "public: virtual void __cdecl bgfx::d3d9::RendererContextD3D9::requestScreenShot(struct bgfx::FrameBufferHandle,char const *)" (?requestScreenShot@RendererContextD3D9@d3d9@bgfx@@UEAAXUFrameBufferHandle@3@PEBD@Z) and LINK : warning LNK4217, LINK : warning LNK4286

loadBgfx - not load... loadSDL working

GoaLitiuM commented 4 years ago

What's the filename of your compiled bgfx dynamic library? loadBgfx tries to load the DLL with these following names:

const(char)[][4] libNames =
[
    "bgfx.dll",
    "bgfx-shared-libRelease.dll",
    "bgfx_debug.dll",
    "bgfx-shared-libDebug.dll"
];

... or alternatively you can give it a custom name as a parameter loadBgfx("my_bgfx.dll").

For static library, you probably need to link against user32.lib to fix the linker error.

SuperDIMMaX commented 4 years ago

Static linked with SDL and bgfx need (not shure, but working)

        "user32",
        "kernel32",
        "opengl32",
        "secur32",
        "winmm",
        "msdmo",
        "gdi32",
        "winspool",
        "shell32",
        "comdlg32",
        "OLE32",
        "imm32",
        "oleaut32",
        "version",
        "uuid",
        "advapi32",
        "setupapi",
        "psapi",

and

        "./libs/SDL2-static",
        "./libs/astc-codec",
        "./libs/astc",
        "./libs/bgfx",
        "./libs/bimg",
        "./libs/bx",
        "./libs/edtaa3",
        "./libs/etc1",
        "./libs/etc2",
        "./libs/iqa",
        "./libs/nvtt",
        "./libs/pvrtc",
        "./libs/squish"

and no linker errors, and no errors with Program exited with code -1073741819 ... but not working...

bgfx_init_t init;
bgfx_init_ctor(&init);

auto i = bgfx_init(&init);
writeln(i);
bgfx_reset(1280, 720, BGFX_RESET_NONE, init.resolution.format);

bgfx_shutdown();

print "true" ... and what is bgfx_init_ctor?

SuperDIMMaX commented 4 years ago

bgfx and sdl - working... examples not working

if need somebody working example -

import bindbc.bgfx;
import bindbc.sdl;

int main(string[] args)
{
    ushort WIDTH = 800;
    ushort HEIGHT= 600;

    SDL_Window* window = SDL_CreateWindow("df", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH,HEIGHT, SDL_WindowFlags.SDL_WINDOW_SHOWN);
    SDL_SysWMinfo windowWMInfo;
    SDL_VERSION(&windowWMInfo.version_);
    SDL_GetWindowWMInfo(window, &windowWMInfo);

    bgfx_platform_data_t pd;
    pd.ndt = null;
    pd.nwh = windowWMInfo.info.win.window;

    bgfx_set_platform_data(&pd);
    bgfx_render_frame(10);
    bgfx_init_t init;
    init.type = bgfx_renderer_type_t.BGFX_RENDERER_TYPE_OPENGL;
    init.debug_ = true;

    bgfx_init_ctor(&init);
    bgfx_init(&init);
    bgfx_reset(WIDTH, HEIGHT, BGFX_RESET_VSYNC, init.resolution.format);
    bgfx_set_debug(BGFX_DEBUG_TEXT | BGFX_DEBUG_STATS);
    bgfx_set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF, 1.0, 0);
    bgfx_set_view_rect(0, 0, 0, WIDTH, HEIGHT);
    bgfx_touch(0);
    bgfx_dbg_text_printf(0, 0, 0x0f, "TEST");
    bool quit = false;
    SDL_Event currentEvent;
    while(!quit) {
        while(SDL_PollEvent(&currentEvent) != 0) {
        if(currentEvent.type == SDL_QUIT) {
            quit = true;
        }
        }

        bgfx_frame(true);
    }
    bgfx_shutdown();
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

and

"lflags":["/NODEFAULTLIB:libcmt"], -- need add or many errors.

{
    "name": "project_d6",
    "dependencies": {
        "bindbc-bgfx": "0.3.1+106",
        "bindbc-loader": "~>0.3.1",
        "bindbc-sdl": "~>0.19.0"
    },
    "lflags":["/NODEFAULTLIB:libcmt"],

    "subConfigurations": {
        "bindbc-bgfx": "static",
        "bindbc-sdl": "static"
    },

    "libs":[
        "user32",
        "./libs/SDL2-static",
        "./libs/astc-codec",
        "./libs/astc",
        "./libs/bgfx",
        "./libs/bimg",
        "./libs/bx",
        "./libs/edtaa3",
        "./libs/etc1",
        "./libs/etc2",
        "./libs/iqa",
        "./libs/nvtt",
        "./libs/pvrtc",
        "./libs/squish"
    ]
}
GoaLitiuM commented 4 years ago

The example in this package does not do anything other than provide a very minimal example of how to use the bindings, it does not display any graphics or output. For other resources on how to use bgfx, you should follow the examples in bgfx repository.