Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 13, 2016 Glad and WGL | ||||
---|---|---|---|---|
| ||||
So I started using Glad but I can't get WGL to work with it, though I think this is more of a Win32 issue than WGL. wndclass.lpfnWndProc = &WndProc; Gives me an error no matter what: Error: cannot implicitly convert expression (& WndProc) of type int function(void* hWnd, uint message, uint wParam, int lParam) to extern (Windows) int function(void*, uint, uint, int) nothrow I think the error has to do with the nothrow but I tried making the function empty extern(Windows) LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { return 0; } And still got the same exact error. Any ideas/help? |
January 13, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Josh Phillips | On Wednesday, 13 January 2016 at 18:34:14 UTC, Josh Phillips wrote:
> So I started using Glad but I can't get WGL to work with it, though I think this is more of a Win32 issue than WGL.
>
> wndclass.lpfnWndProc = &WndProc;
>
> Gives me an error no matter what:
> Error: cannot implicitly convert expression (& WndProc) of type int function(void* hWnd, uint message, uint wParam, int lParam) to extern (Windows) int function(void*, uint, uint, int) nothrow
>
> I think the error has to do with the nothrow but I tried making the function empty
>
> extern(Windows)
> LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
> return 0;
> }
>
> And still got the same exact error. Any ideas/help?
Your function isnt marked nothrow.
|
January 13, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Josh Phillips | On Wednesday, 13 January 2016 at 18:34:14 UTC, Josh Phillips wrote:
> extern(Windows)
> LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
You just need to explicitly mark it nothrow in the signature. Add `nothrow` to the end of the param list:
extern(Windows)
LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow
and then you'll be cool
|
January 13, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 13 January 2016 at 18:37:09 UTC, Adam D. Ruppe wrote: > You just need to explicitly mark it nothrow in the signature. Add `nothrow` to the end of the param list: > > extern(Windows) > LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow > > and then you'll be cool Oh wow that's easy. They should really make that more clear in the dlang reference. They way it sounds there made me think that if a function doesn't throw any errors it automatically is 'nothrow' @Dav1d do I need to implicitly link WGL to any dlls or anything? Now I'm getting linking errors ..\dlibgui\lib\dlibgui.lib(window) Error 42: Symbol Undefined _wglMakeCurrent@8 ..\dlibgui\lib\dlibgui.lib(window) Error 42: Symbol Undefined _wglCreateContext@4 ..\dlibgui\lib\dlibgui.lib(window) Error 42: Symbol Undefined _ChoosePixelFormat@8 ..\dlibgui\lib\dlibgui.lib(window) Error 42: Symbol Undefined _SetPixelFormat@12 ..\dlibgui\lib\dlibgui.lib(window) Error 42: Symbol Undefined _wglDeleteContext@4 --- errorlevel 5 dmd failed with exit code 5. |
January 13, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Josh Phillips | On Wednesday, 13 January 2016 at 19:05:30 UTC, Josh Phillips wrote:
> On Wednesday, 13 January 2016 at 18:37:09 UTC, Adam D. Ruppe wrote:
>> [...]
>
> Oh wow that's easy. They should really make that more clear in the dlang reference. They way it sounds there made me think that if a function doesn't throw any errors it automatically is 'nothrow'
>
> [...]
Link with opengl32.lib
|
January 14, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Josh Phillips | On Wednesday, 13 January 2016 at 19:05:30 UTC, Josh Phillips wrote:
> Oh wow that's easy. They should really make that more clear in the dlang reference. They way it sounds there made me think that if a function doesn't throw any errors it automatically is 'nothrow'
No, because actually you can have a function that uses sub-functions that throw, but marked explicitly nothrow, because it hides the stuff under the carpet.
---
void bar()
{
throw new Exception("kaboom");
}
void foo() nothrow
{
try {bar;}
catch {/*under the carpet*/}
}
---
and that will compile.
|
January 14, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dav1d | On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote:
> Link with opengl32.lib
How? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one.
|
January 14, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to userABCabc123 | On Thursday, 14 January 2016 at 02:16:40 UTC, userABCabc123 wrote: > On Wednesday, 13 January 2016 at 19:05:30 UTC, Josh Phillips wrote: >> Oh wow that's easy. They should really make that more clear in the dlang reference. They way it sounds there made me think that if a function doesn't throw any errors it automatically is 'nothrow' > > No, because actually you can have a function that uses sub-functions that throw, but marked explicitly nothrow, because it hides the stuff under the carpet. > > --- > void bar() > { > throw new Exception("kaboom"); > } > > void foo() nothrow > { > try {bar;} > catch {/*under the carpet*/} > } > --- > > and that will compile. Ok? I'm not sure what you are saying no to and I understand this. It makes sense because foo catches bar's error and doesn't throw it up and further. I was just saying that the reference here https://dlang.org/spec/function.html was not all that clear since the section entitled nothrow merely states: "Nothrow functions do not throw any exceptions derived from class Exception. Nothrow functions are covariant with throwing ones." A deeper search on the page made me realize that there are more examples later which clarify how to declare a "nothrow" function however I didn't bother looking deeper at the time since the main section for nothrows gave no indication that I should. |
January 14, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Josh Phillips | On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips wrote: > On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote: >> Link with opengl32.lib > > How? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one. Welcome to D and Windows. You can use GDC or LDC or try http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible) Or you find an OMF opengl32.lib OR you make your own with implib and coff2omf http://www.digitalmars.com/ctg/implib.html http://www.digitalmars.com/ctg/coff2omf.html I dont really remember how that worked. |
January 14, 2016 Re: Glad and WGL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dav1d | On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote: > On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips wrote: >> On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote: >>> Link with opengl32.lib >> >> How? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one. > > Welcome to D and Windows. You can use GDC or LDC or try http://wiki.dlang.org/Installing_DMD_on_64-bit_Windows_7_(COFF-compatible) > > Or you find an OMF opengl32.lib OR you make your own with implib and coff2omf > http://www.digitalmars.com/ctg/implib.html > http://www.digitalmars.com/ctg/coff2omf.html > I dont really remember how that worked. There is also objconv: http://www.agner.org/optimize/ I found in an older code: echo "implib /s opengl32.lib opengl32.dll && exit" | cmd So maybe `implib /s opengl32.lib opengl32.dll` is enough. Would like to help you more, but I didnt need to deal with this shit lately (luckily) and forgot most of this mess. |
Copyright © 1999-2021 by the D Language Foundation