473,561 Members | 3,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Working on a header file for OpenGL

23 New Member
It's meant to make making Windows for the API quiker and easier, but one of the problems is that in order to properly create a window with a create window function, needs to know about the Windows Procedure, but I don't know if you can properly pass a windows procedure wihtout parameters to a function in an include file. Lets say I create a Windows Procedure with typical parameters like this:

LRESULT CALLBACK(HWND, UINT, WPARAM, LPARAM);

Then how would I get the function in the include file to know about it? First part of function in include file is as follows (because it's massive, didn't want to overwhelm people). For the sake of concisity, I've only included the part I'm having trouble with, since I know the rest is error free.:

bool CreateGLWindow( char* title, char* Classname, int width, int height, int bits, bool fullscreenflag, HWND hWnd
, HINSTANCE hInstance, HGLRC hRC, HDC hDC)
{
WNDCLASS wc;
wc.lpfnWndProc = (WNDPROC)WndPro c;/*"WndProc undeclared! But I can't pass it as a parameter unless I use parameters for the function, but that causes errors. Should I make all parameters for WndProc optional so I don't have to pass anything? That wouldn't work...*/

I need a way to tell the function in the header file that WinProc is the function that I want to use, and a way to pass it as a parameter without passing parameters to it. Can someone help me with this?
Aug 11 '07 #1
1 1756
weaknessforcats
9,208 Recognized Expert Moderator Expert
I'm a little confused by phrases like:
I need a way to tell the function in the header file that ...
becuse there are no functions in a header file. And if there are, you have bigger problems than what you have posted.

First, a WNDPROC is a function pointer to a function like this:
Expand|Select|Wrap|Line Numbers
  1. LRESULT CALLBACK WindowProc(          HWND hwnd,
  2.     UINT uMsg,
  3.     WPARAM wParam,
  4.     LPARAM lParam
  5. );
  6.  
In winuser.h you see:
Expand|Select|Wrap|Line Numbers
  1. typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
  2.  
which says that a WNDPROC is a pointer to a function with specific arguments and return type.

For your WndProc function to be used as a WNDPROC is must have this prototype:
Expand|Select|Wrap|Line Numbers
  1. LRESULT CALLBACK WndProc(          HWND hwnd,
  2.     UINT uMsg,
  3.     WPARAM wParam,
  4.     LPARAM lParam
  5. );
  6.  
I assume that it does.

Now this error:
wc.lpfnWndProc = (WNDPROC)WndPro c;/*"WndProc undeclared!
tells me that the function prototype for WndProc is not available at the time this case is made. And, by the way, you don't need the cast if your WndProc has the correct prototype,. You should be able to:

Expand|Select|Wrap|Line Numbers
  1. wc.lpfnWndProc = WndProc;
  2.  
Lastly, I would not use the name WndProc for your function. Use something not likely to be confused witrh Windows code. Maybe:

Expand|Select|Wrap|Line Numbers
  1. LRESULT CALLBACK MyGLWindow(          HWND hwnd,
  2.     UINT uMsg,
  3.     WPARAM wParam,
  4.     LPARAM lParam
  5. );
  6.  
Aug 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3180
by: Rick Muller | last post by:
I have a problem that I would like to get some advice on from other Pythonistas. I currently manage a (soon to be) open source project for displaying molecular graphics for a variety of different programs. To do this I need to draw pictures of the molecules, typically using OpenGL, and do some basic control, using some widget set. The code...
15
4522
by: oracle411 | last post by:
Hi I'm new to OpenGL, but have an OpenGL application written in CPP that I would like to display on a web browser. Was wondering how this could be done? Thank you very much
2
1066
by: yanwan | last post by:
Hello Does anyone know where I can find the header file "ArisTracking.h"? I don't know which source this file relates. I have downloaded a file from internet (by google search), but it seems doesn't fit the program. For example, in this file 'nblines' is not a member of 'ArisTrackingStruct', but in linux os, which may have its own...
10
5204
by: Bad_Kid | last post by:
which is better for what?
9
1894
by: Daniel | last post by:
Hi, While I compile my old C++ source in VC.Net, rebulild whole project, there are always some header files are unvaliable like "fstream.h", "Dxguide.h".....etc. Did VC.Net remove the VC++'s headers? How can I get them back? Where sould I put them in?
4
4107
by: tobfon | last post by:
I'm creating a scientific visualization application with rather high demands on performance. I've created a nice rendering engine for it in C++/OpenGL and a python interface to the rendering engine. Now I'm looking to build a GUI in python with the rendering engine as an integrated window. I will most likely use wxPython for the GUI and I...
12
2082
by: Ben | last post by:
I'm kind of new to creating templates. I've made some small class and function templates in the past and I have used quite of bit of the STL, but I am having problems tyring to create templates. I'm trying to make class templates in seperate header files with pointers to each other, and I am getting strange errors. Is it possible to do?
9
7495
by: Achim Domma | last post by:
Hi, I'm developing a GUI app in Python/C++ to visualize numerical results. Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there are no windows binaries for Python 2.5 for quite some time now. I need a OpenGL context without restrictions and some settings dialogs. Is wx + PyOpenGL the way to go? Or could somebody recommend...
2
1838
by: urbanedge | last post by:
I've uploaded a site to a new server and now the headers in the mail function are not working to send the required email response. This is a newly acquired site and my php knowledge is at the beginner level. I've managed to list the headers that are being sent but I can't seem to find where or why the email won't work. I'd really appreciate...
0
7565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7855
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7611
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5182
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3613
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3595
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1174
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
888
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.