digitalmars.D.learn - Glad and WGL
- Josh Phillips (16/16) Jan 13 2016 So I started using Glad but I can't get WGL to work with it,
- Dav1d (3/19) Jan 13 2016 Your function isnt marked nothrow.
- Adam D. Ruppe (8/11) Jan 13 2016 You just need to explicitly mark it nothrow in the signature. Add
- Josh Phillips (20/26) Jan 13 2016 Oh wow that's easy. They should really make that more clear in
- Dav1d (3/11) Jan 13 2016 Link with opengl32.lib
- Josh Phillips (3/4) Jan 13 2016 How? Everywhere I looked it says this cannot be done due to
- Dav1d (8/13) Jan 14 2016 Welcome to D and Windows. You can use GDC or LDC or try
- Dav1d (7/22) Jan 14 2016 There is also objconv: http://www.agner.org/optimize/
- Josh Phillips (7/24) Jan 14 2016 I actually got it to work by enforcing 64bit. DMD uses the VC
- Josh Phillips (4/8) Jan 15 2016 For anyone else with this issue I finally figured it out. You
- userABCabc123 (17/21) Jan 13 2016 No, because actually you can have a function that uses
- Josh Phillips (13/34) Jan 13 2016 Ok? I'm not sure what you are saying no to and I understand this.
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?
Jan 13 2016
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.
Jan 13 2016
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
Jan 13 2016
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 coolOh 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.
Jan 13 2016
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:Link with opengl32.lib[...]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' [...]
Jan 13 2016
On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote:Link with opengl32.libHow? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one.
Jan 13 2016
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: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.Link with opengl32.libHow? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one.
Jan 14 2016
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: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.On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote: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.Link with opengl32.libHow? Everywhere I looked it says this cannot be done due to conflicting formats between the dmd compiler and the windows one.
Jan 14 2016
On Thursday, 14 January 2016 at 09:42:50 UTC, Dav1d wrote:On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote:I actually got it to work by enforcing 64bit. DMD uses the VC Linker in 64bit mode I guess. However I (of course) ran into new errors. Gl functions like glGetString and glGetIntegerv cause the program to crash. It appears that an opengl context is being created so I'm not sure whats causing the problemOn Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips wrote: 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.
Jan 14 2016
On Friday, 15 January 2016 at 07:37:27 UTC, Josh Phillips wrote:However I (of course) ran into new errors. Gl functions like glGetString and glGetIntegerv cause the program to crash. It appears that an opengl context is being created so I'm not sure whats causing the problemFor anyone else with this issue I finally figured it out. You have to call gladLoadGL AFTER you set the glContext and before you call any gl code.
Jan 15 2016
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.
Jan 13 2016
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: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.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.
Jan 13 2016