PDA

View Full Version : I started reading OpenGL SuperBible (6th), have some issues and questions!



wdna98
01-20-2014, 03:40 AM
The book comes with this set of examples: https://github.com/openglsuperbible/sb6code

I currently using Windows 8.1 and Visual Studio 2013, I have hybrid Intel HD Graphics 4400 and NVIDIA 740M (supports OpenGL 4.4) on this laptop.
The examples contain an external dependency library glfw-2.7.6, all examples compiled fine, but when run the window open and closes, then exit with 0.

I tried debug glfw to find what the problem is, but it did not allow me to look inside the library (and the 2.6.7 project did not compile). so i found this legacy glfw-2.7.9 repo (https://github.com/glfw/glfw-legacy) with updated project files, that did compile, and allowed me to debug glfw, I saw that from some reason it fails to create the window, or some component of the window, I can paste some code if needed.

Luckily the examples also contained a project called win32raw, it does:


HWND hWnd = ::CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
TEXT("OPENGL"),
TEXT("OGL 001"),
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
800, 600,
NULL,
NULL,
hInstance,
NULL);


To create the window, and this one works. So I suspect this might be an issue with glfw lib and how it open windows in the current Windows API.
I thought i could use this project template to go on with the book, but the book shows this:


static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, red);


But I don't have glClearBufferfv() available, it seem it's part of header called gl3w.h it seems to wrap OpenGL functions. so I'm somewhat confused here, because I don't have glClearBuffer() neither. the win32 example use:


glClearColor(0.05f, 0.0f, 0.7f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);

To do the same operation, but glClearBufferfv() is used in the book... can someone clarify for me what I'm missing here? I'm very new to raw OpenGL, I have decent C++ experience (although it's not my main usage this days) and I coded couple of small apps using SDL2, just for you to know my general level. I have also spend 2 days googling, testing and debug this stuff before I came here =]

nenad*
01-21-2014, 06:29 AM
glClearBuffer() is OpenGL 3.0 function. You can use glew library to query the GL version your driver is running and to automatically expose pertaining function pointers. As for glfw, hard to tell without seeing the code.

Jesse
01-22-2014, 10:12 AM
The book comes with this set of examples: https://github.com/openglsuperbible/sb6code

Here's an interesting remark at the bottom of the page:



Please note carefully: EVEN IF YOU CAN BUILD THE SOURCES FOR YOUR FAVORITE
PLATFORM OF CHOICE, YOU NEED RECENT OpenGL 4.3 DRIVERS TO RUN THEM. PLEASE
DON'T PAN MY BOOK BECAUSE YOUR COMPUTER DOESN'T SUPPORT OpenGL 4.3. THANKS





But I don't have glClearBufferfv() available, it seem it's part of header called gl3w.h it seems to wrap OpenGL functions. so I'm somewhat confused here, because I don't have glClearBuffer() neither.


These functions are part of OpenGL 3.0+. Their prototypes are in glcorearb.h:



GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);
GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);
GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);
GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);


If you're on Windows, a library such as GLEW, Gl3w, or GL Load, can do the necessary grunt work to load these. If you prefer to do it yourself, then you can always use WGL.

Link to glcorearb.h: http://www.opengl.org/registry/api/GL/glcorearb.h

DaleGriff
03-15-2014, 07:39 AM
"all examples compiled fine, but when run the window open and closes, then exit with 0."

I am having the same problem. My NVidia GeForce GT can support up to opengl 4.4 and I have got the most recent drivers. I have tried running the code in VS2010 initially and then VS2012 to no avail.

It's very frustrating because I am really enjoying reading the book. There is another online tutorial, using glfw3 with opengl 3 code that works fine without any glitches and I've also been doing some freeglut and bullet physics from another book I have (but I want to get away from the gl.begin usage to more modern opengl), this particular book also does not teach shaders.

I'm really at my whits end with this. THere's nothing obvious to me in project properties because there wasn't really anything to set (unlike tinkering with the other tutorial I've mentioned above with additional dependencies and such like). I did unzip the code and then unzipped the media files into media/bin, then compiled all the code (without a hitch) but then when I set any project to starting project then try and run a white window with 'GLFW Window' in the title bar opens momentarily and then within a few seconds closes again.

The debug output gives me this?
'blendmatrix_dbg.exe': Loaded 'C:\opengl\SuperBibleCode\sb6code_2013_11_10\bin\b lendmatrix_dbg.exe', Symbols loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Exports loaded.
SHIMVIEW: ShimInfo(Complete)
'blendmatrix_dbg.exe': Loaded 'C:\ProgramData\Norton\{0C55C096-0F1D-4F28-AAA2-85EF591126E7}\NIS_20.3.1.22\Definitions\BASHDefs\2 0140214.001\UMEngx86.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\winmmbase.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\ProgramData\Internet Helper Anti-phishing\internetHelper_antiphishing.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\combase.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\nvoglshim32.dll', Exports loaded.
'blendmatrix_dbg.exe': Loaded 'C:\Windows\SysWOW64\ig7icd32.dll', Exports loaded.
'blendmatrix_dbg.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
'blendmatrix_dbg.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
'blendmatrix_dbg.exe': Unloaded 'C:\Windows\SysWOW64\winmm.dll'
'blendmatrix_dbg.exe': Unloaded 'C:\Windows\SysWOW64\winmmbase.dll'
The thread 'Win32 Thread' (0x3b8c) has exited with code 0 (0x0).
The program '[15096] blendmatrix_dbg.exe: Native' has exited with code 0 (0x0).

Not sure what all the unloaded .dlls are about at the end?? When I looked in SysWOW64 they are certainly in there (I thought it might be that they are missins). Although my laptop is windows 8 I run everything from the windows desktop as though I've got windows 7 pretty much. I've never seen the sysswow64 crop up before in any debug output before (isn't this windows 8 related) does this have any baring on my problem?

Would really appreciate any help/suggestions what so ever.
regards,
Dale.