PDA

View Full Version : nehe troubles



04-14-2004, 04:12 PM
145 main.cpp
`CDS_FULLSCREEN' undeclared (first use this function)
145 main.cpp
(Each undeclared identifier is reported only once
145 main.cpp
for each function it appears in.)

is what i get when i try to compile it, any help?

Green_Dragon
04-14-2004, 04:26 PM
What compiler do you use? When i had Dev c++ 4.0 i encountered the same problem. Then I downloaded DevC++ 4.9.8.0 (for free) and it works fine now. My "includes are"
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

If you have DevC++ 4.9.8.0 try going to project>project options>parameters and see if you have
-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
in the linker window. :p

chowe6685
04-14-2004, 04:32 PM
#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 4
#endif

04-14-2004, 06:06 PM
i updated my dev c++ and then i did everything else u said(exept for u greendragon, no clue where to put that code) and it now gives me the message2
C:\My Documents\Test\2
unable to run program file.

04-15-2004, 05:03 AM
any help?

04-15-2004, 08:10 AM
First of all, the file should be a project, not just a source file. You can create an empty project in devc++ and then add the source to it.
U put these as includes in your project:
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

On the top bar in DevC++ where "File" and other stuff is you have to click "Project" then "project options" click "parameters" tab and see if you have this line in "compiler":

-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32

04-15-2004, 05:45 PM
my gosh dev c++ hates me, i tried waht u said green dragon and it still gives me the same message
C:\My Documents\test\2
unable to run program file.
heres the thing thats got me bafeled though, test is the file that all my programing stuff is in, but i do not know what the 2 is, my project name is untitled 1(im just trying to get something running) and the cpp file is untitled 1, so i go to line 2 and it says that
#include <gl\gl.h>
has a probleme with it, :confused:
if u guys could help, i would appreciate ur help

04-16-2004, 05:54 AM
any help?

BeginOpenGL
04-16-2004, 11:13 AM
Spartan086

I just downloaded the Dev C++ 4.9.8.0 distribution myself a few days ago and Iīm new to C++ as well as OpenGL. But, I got the compiler working just fine. I worked out the example OpenGl included in the download and build my first 3d Engine. Okay, itīs a very simple one but, it shows an entire pyramid spinning in 3d Space which was built from vertices which are themselves 3 points in 3d space. The procedure to compile, as well as the code itself are included below. the procedure might help you compile any of your files as well.

Here are the possible steps to compile the DevC++ 4.9.8.0 3D Engine in DEV C++ 4.9.8.0:

1. Created a new folder inside the main DevC++ folder and called it DEVOpenGL.

2. Opened a new project in the above folder(when the dialog box pops up asking where to put new project, give it the new folderīs path), and gave it a name. Deleted the automatically generated main.cpp code and copied the below code in itīs place.

3. Saved everything. Save the project as well as main.cpp(with the engines code) into the newly created DEVOpenGL folder by "saving as" and giving the path to this projectīs folder in the "save as" dialog box. "Maybe you can exit Dev C++ IDE then, to cal the project again, double click on your projectīs icon so that DevC++ loads the project as well as the new main.cpp with the DevC++ engineīs code you pasted in the above step instead of the originally generated main.cpp code." The projects source files will now be inside this new folder. You can bring up Dev C++ IDE by just double clicking on your projects icon.

4. Created a new Icon for the executable inside the Project Menu dialog box and dumped it in the DevOpenGL folder along with two Private files that areīnt supposed to be edited and another file related to the icon. These three files are added automatically to the rest of the source files.

5. Create another new folder inside the above folder and called it DevOpenGL01EXE. This folderīs path can be given in Project/Project Options/Build Options as the path to dump the final object file as well as the compiled OpenGL01.EXE standalone executable. Thereby separating it from all the source files.

6. Dumped the following library names in:
Projects/ProjectOptions/Parameters, and they are:
(Iīm not too sure if I need all of them, but it compiles)
-lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32

7.Also gave the following command line option to the compiler:
(Not too sure what this does, but, it works too.)
-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS
Itīs done in the same place in the Project dialog box as step 6. But, in the compiler whitespace instead of the linker whitespace.

8. Get rid of the console by specifying in the Project/Project Options/General dialog box WIN32GUI instead of Console.

9. Going with the regular default compiler as compared to specifying a C++ compiler in Project/Project Options/Compiler didīnt seem to make any difference.

10. Went up to the menu again and clicked Execute/compile. The resulting object file and OpenGl01.EXE were output to the second folder I had created(DevOpenGLEXE folder), as specified.

11. Double clicked on the DevOpenGL01.EXE icon and executed the app.

If itīs not too much of a bother, can someone with Dev C++ please tell me if they could follow the above procedure and compile that code without any errors or warnings. I compiled it without a single error or warning.


/***************************************
* DevC++ 4.9.8.0 3D Engine Ver 0.000002
*
***************************************/
/*These includes seem to be automatically used by the Dev C compiler,*/
/*without having to type in their path in the Project/Project Options/Directories/Include Directories*/
/*dialog box*/
#include <windows.h>
#include <gl/gl.h>

/**************************
* Function Declarations
*
**************************/

LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);

/**************************
* WinMain
*
**************************/

int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int iCmdShow)
{
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit = FALSE;
/*īdeclare the var theta, to be used as an angle in rotations*/
float theta = 0.0;

/* register window class */
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "GLSample";
RegisterClass (&wc);

/* create main window */
hWnd = CreateWindow (
"GLSample", "DEV C++ 4.9.8.0 3D Engine",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
0, 0, 1024, 768,
NULL, NULL, hInstance, NULL);

/* enable OpenGL for the window */
EnableOpenGL (hWnd, &hDC, &hRC);

/* program main loop */
while (!bQuit)
{
/* check for messages */
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
/* handle or dispatch messages */
if (msg.message == WM_QUIT)
{
bQuit = TRUE;
}
else
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
else
{
/* OPEN GL ANIMATION CODE FOR PRIMITIVES GOES BELOW */

/*Set the Background color to black*/
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
/*Clear previous frame color buffer to enable drawing of next frame*/
/*Clear previous frame depth buffer to enable drawing of next frame*/
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*Clear existing internal tansformations by loading identity matrix*/
glLoadIdentity ();
/*move all vertices(the pyramid) 1 unit forward on z axis*/
glTranslatef (0, 0, -1);
/*rotate(spin) pyramid around itīs vertical Y axis*/
glRotatef (theta, 0, 1, 0);
/*access OpenGlīs matrix stack to save transformations*/
glPushMatrix ();
/*Join vertex 1,2,3..1,3,4 and 1,4,5(vertice 1 is common to the rest)*/
glBegin (GL_TRIANGLE_FAN);
/*assign color and position in 3d space to each vertex thru its 3 coords*/
glColor3f (0,.5, 1); glVertex3f ( 0, 1, 0);
glColor3f (1, .5, 0); glVertex3f (-1,-1, 1);
glColor3f (1, .3, 1); glVertex3f ( 1,-1, 1);
glColor3f (.2, 0, 1); glVertex3f ( 1,-1,-1);
glColor3f (0, 1, 0); glVertex3f (-1,-1,-1);
glColor3f (1, .7, 0); glVertex3f (-1,-1, 1);
glEnd ();
/*restore OpenGlīs matrix stack transformations to continue to translatef*/
glPopMatrix ();
/*Make the pyramid visible*/
SwapBuffers (hDC);

theta += .5;
Sleep (1);
}
}

/* shutdown OpenGL */
DisableOpenGL (hWnd, hDC, hRC);

/* destroy the window explicitly */
DestroyWindow (hWnd);

return msg.wParam;
}

/********************
* Window Procedure
*
********************/

LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{

switch (message)
{
case WM_CREATE:
return 0;
case WM_CLOSE:
PostQuitMessage (0);
return 0;

case WM_DESTROY:
return 0;

case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
}
return 0;

default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
}

/*******************
* Enable OpenGL
*
*******************/

void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;

/* get the device context (DC) */
*hDC = GetDC (hWnd);

/* set the pixel format for the DC */
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat (*hDC, &pfd);
SetPixelFormat (*hDC, iFormat, &pfd);

/* create and enable the render context (RC) */
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );

}

/******************
* Disable OpenGL
*
******************/

void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC)
{
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hRC);
ReleaseDC (hWnd, hDC);
}



Hope that helps

BeginOpenGL

04-16-2004, 01:40 PM
wow thxs alot, the code worked, but i had to down grade dev c++ :rolleyes: figures, but thxs for helping me

BeginOpenGL
04-16-2004, 02:57 PM
Spartan 086

Youīre welcome. Glad it helped. But, Iīm not too sure what you mean by "downgrading" Dev C++.

The new DevC++ 4.9.8.0 IDE seems to have worked just fine. At least for the few days I have been using it. Iīts got a nice IDE. Also, this new version is supposed to be compatible with Win2000 as well as Win XP. I doīnt think thereīs too many free c++ compilers that can do that.

I was also able to compile some of NeHeīs lessons. But, you need to put a new glaux.h file in the Include/GL folder to be able to do so. This is because the download doesīnt include it.

If you get stuck compiling NeHeīs lessons with Dev C++ or just canīt find that glaux.h include file, let me know.

BeginOpenGL

04-17-2004, 10:31 AM
I hav the same problem, im not sure how to fix it. Ive ha problwms with Dev-C++ from the start but its startingto annoy me. I was also using NeHe's tutorial on loading textures. I get these errors:

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Kris2456\My Documents\Programming\plank\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Kris2456\My Documents\Programming\plank\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include"

main.cpp:13:69: gl\glaux.h: No such file or directory
main.cpp:32: syntax error before `*' token
main.cpp:41: ISO C++ forbids declaration of `File' with no type
main.cpp:41: `Filename' was not declared in this scope
main.cpp:43: parse error before `if'
main.cpp: In function `int LoadGLTextures()':
main.cpp:56: `AUX_RGBImageRec' undeclared (first use this function)
main.cpp:56: (Each undeclared identifier is reported only once for each

function it appears in.)
main.cpp:56: `TextureImage' undeclared (first use this function)
main.cpp:61: `LoadBMP' undeclared (first use this function)

make.exe: *** [main.o] Error 1

Execution terminated

***********************************************

also if i try and use the: #include <gl\glaux.h> line, it never works, ive only had this problem while trying to load textures

BeginOpenGL
04-17-2004, 02:33 PM
Do you have the glaux.h file in the DevC++/Include/Gl folder? If not, get it from here: web page (: http://molhanec.net/devpaks.php ) and unpack it into the above Gl folder.

Also, make sure the paramater in the Projectīs dialog box is set to WIN32GUI and not console.

Hope that helps.

BeginOpenGL