|
Basecode versus my code...
NeHe''s base code compiles and runs fun, my compiles, but it always fails when choosing a pixel format. I''ve searched the forums and this has been asked a lot, but no one seems to have an answer as to why it works for NeHe, but not for us. I''ve been sitting here, trying to figure this out, but I am lost. I decided to write my own base code to use so I would better understand the whole OpenGL initialization sequence. Everytime I get to ChoosePixelFormat, it returns zero and my program bails. I used the GetLastError function and it returns this, "The specified module could not be found." If I recall correctly, ChoosePixelFormat is a part of the GDI, which I find hard to believe could be missing. I followed NeHe''s code as a base, but nothing seems to work right for me. Could it be the fact that I am trying to wrap OpenGL up in a class? Anways, here is my init code up to where it fails.
Don''t worrry about all my other functions and defines, they are all their, because everything compiles fine, it just always fails when the program gets to ChoosePixelFormat. Does anyone have an idea as to what is going on? Thanks in advance.
"...."
Nothing looks wrong after a quick glance.
If you want to email me the source, I''ll be happy to check it out.
If you want to email me the source, I''ll be happy to check it out.
I also wanted to note, that ChoosePixelFormat fails if I have PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER commented out or not, I just have it commented out in there to see it was failing due to something not being supported.
"...."
Try setting the WS_CLIPCHILDREN|WS_CLIPSIBLINGS, and uncomment your PFD_* stuff.
Try moving the variable declarations (the pixeldescriptor and the uint PixelFormat) to the top of the function... if your compiler is compiling it as C and not C++ (MSVC will do this for files with a .c extension.. C++ == .cpp, you probably want to rename the file to .cpp if it''s a .c file... C is anal sometimes)
C says you need to declare all of your variables at the beginning of a subroutine and some compilers just dont give very good errors
hope that helps
noh
C says you need to declare all of your variables at the beginning of a subroutine and some compilers just dont give very good errors
hope that helps
noh
Thanks for the help, but I found out the answer to my problem, and here it is for anyone that has this same problem. ChoosePixelFormat is basically worthless unless you use wglCreateContext, I have no clue why, but as soon as I added that in, my code magically worked. Frankly, in my mind that makes no sense at all, but hey, my code works now, so why should I complain?
"...."
quote:
Original post by Lunatic Raven
Thanks for the help, but I found out the answer to my problem, and here it is for anyone that has this same problem. ChoosePixelFormat is basically worthless unless you use wglCreateContext, I have no clue why, but as soon as I added that in, my code magically worked. Frankly, in my mind that makes no sense at all, but hey, my code works now, so why should I complain?
This sounds like a problem I had some time ago. The solution I found is below but I can''t remember from where I got it (searching google I guess).
quote:
Internally, ChoosePixelFormat (and SetPixelFormat and all those functions) make calls to OPENGL32.DLL. If your program does not make any gl* calls, then your compiler''s smart-linker will probably not link opengl32.lib, so when you run your program then opengl32.dll will not be loaded, and so ChoosePixelFormat will fail.
---
"No game will ever rule more than CBT!" - stoof
Visit Da Shovvkejs.
---Mikael Lax
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement