Jump to content
• Advertisement

Public Group

# Nehe - WNDCLASS

This topic is 3152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hi, i just wanted to get through the first lesson of NeHe's OpenGl Tutorials. I'm using DevCPP for that. http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01 i retyped the lesson to GLcreatWindow(...) and included the declaration of WndProc() where i was told to. now, when i'm trying to compile, i'm getting errors like "'struct WNDCLASS' has no member named 'obsClsExtra' ". Seems like it doesn't know where to find WNDCLASS, but i don't know either. Do i have to link a specific library? till now i've added "-lopengl32 -lglu32" to the linker.

#### Share this post

##### Share on other sites
Advertisement
A quick Google for WNDCLASS gives me this, which indicates to me that you misread or mistyped from the tutorial.

As a side note, you are getting a compile error. Compilation is a distinct stage from linking, so your library settings could not affect this. During linking, you get linker errors.

#### Share this post

##### Share on other sites
I've got that site too, and after having a break i've found the the typos :D

Anyway i'm getting a linker error ( [Linker error] undefined reference to _Z7WndProcP6HWND__jjl@16' ).

That's why i thought about a missing lib.

#### Share this post

##### Share on other sites
Quote:
 Original post by wski [...] included the declaration of WndProc() where i was told to.
Where did you put the definition of WndProc?

#### Share this post

##### Share on other sites
Quote:
 Original post by wskThat's why i thought about a missing lib.
Nope, not a library issue. WndProc is a user-defined function not a library-defined anything. You didn't define WndProc (or didn't define it correctly).

#### Share this post

##### Share on other sites
First, grab a recent decent compiler. I don't know why beginners always ends up with Dev-C++. As most people recommend, you should grab Visual Studio 2008 Express Edition. Why?
http://www.jasonbadams.net/20081218/why-you-shouldnt-use-dev-c/

Second, instead of typing manually NeHe code, why don't you just download the source file at the bottom of it's page? It won't contain typos like you had and will compile at first try.

Anyway, the only things you have to do usually to get this working is to include Windows.h, not any libs. The first error was with WNDCLASS, now it's with WndProc. It compile fine, so you have it's function prototype declared and referenced somewhere, but not it's function body since it have a problem in the linking stage.

#### Share this post

##### Share on other sites
Just the beginning of the code:

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

HGLRC hRC=NULL; // Permanent Rendering Context
HDC hDC=NULL; // Device Context->GDI (connects to Graphics Device Interface)
HWND hWnd=NULL; // Window Handler
HINSTANCE hInstance; // Program Instance

bool keys[256]; // monitoring keyboard
bool active=TRUE; // minimizing-> suspend program
bool fullscreen=TRUE; // Fullscreen-Mode?

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // CreateGLWindow() has reference to WndProc

...maybe i should get Visual Studio, to make sure it is my fault ;)
But i'm retyping the code from tutorial to remember it better. To copy code is quite inefficient for learning in my opinion.

thanks til now, i'll see if it runs properly in visual studio

#### Share this post

##### Share on other sites
Quote:
 But i'm retyping the code from tutorial to remember it better. To copy code is quite inefficient for learning in my opinion.

I think you have confused memory retention for knowledge. The Win32 boilerplate for creating an OpenGL application is irrelevant. You can get copies from many free sources.

What is infinitely more important is to understand how this code affects your game. The depth buffer, matrix modes, pixel formats, double buffering (to name a small few)? All are given minimal explanation in this tutorial. Yes, its a beginner tutorial and sometimes you have to just give the user a black box to play with before they can bootstrap the learning process, but these are the areas you should concentrate your learning on.

#### Share this post

##### Share on other sites
Just as I said, you have the line:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

This is a function prototype (declaration), telling the compiler that you can reference it because you know the function definition (code body) exist somewhere. Problem is, you don't have it. If I look at NeHe lesson 1, the definition of WndProc is further down, just before WinMain()

LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window							UINT	uMsg,			// Message For This Window							WPARAM	wParam,			// Additional Message Information							LPARAM	lParam)			// Additional Message Information{	switch (uMsg)									// Check For Windows Messages	{		case WM_ACTIVATE:							// Watch For Window Activate Message		{			if (!HIWORD(wParam))					// Check Minimization State			{				active=TRUE;						// Program Is Active			}			else			{				active=FALSE;						// Program Is No Longer Active			}			return 0;								// Return To The Message Loop		}		case WM_SYSCOMMAND:							// Intercept System Commands		{			switch (wParam)							// Check System Calls			{				case SC_SCREENSAVE:					// Screensaver Trying To Start?				case SC_MONITORPOWER:				// Monitor Trying To Enter Powersave?				return 0;							// Prevent From Happening			}			break;									// Exit		}		case WM_CLOSE:								// Did We Receive A Close Message?		{			PostQuitMessage(0);						// Send A Quit Message			return 0;								// Jump Back		}		case WM_KEYDOWN:							// Is A Key Being Held Down?		{			keys[wParam] = TRUE;					// If So, Mark It As TRUE			return 0;								// Jump Back		}		case WM_KEYUP:								// Has A Key Been Released?		{			keys[wParam] = FALSE;					// If So, Mark It As FALSE			return 0;								// Jump Back		}		case WM_SIZE:								// Resize The OpenGL Window		{			ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));  // LoWord=Width, HiWord=Height			return 0;								// Jump Back		}	}	// Pass All Unhandled Messages To DefWindowProc	return DefWindowProc(hWnd,uMsg,wParam,lParam);}`

This have nothing to do with OpenGL though, this is basic C. You should probably learn the language a bit more before digging into 3D libraries.

#### Share this post

##### Share on other sites
I'm just doing this for university, otherwise i wouldn't use c for beginning with opengl ;)

So there was my fault, i thought WndProc was something that was only linked to. I tried to set up a Visual Studio Project myself and it worked. So no Problem til now anymore ;)

thank you all

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 10
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632983
• Total Posts
3009707
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!