dev-cpp-users Mailing List for Dev-C++ (Page 684)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <Tre...@ao...> - 2001-07-20 17:46:17
|
Thank you for your help :) I am now trying to reverse the pattern and I am
getting an infinite loop.....can you see what is wrong.....it looks fine to
me.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int pattern = 0;
int lines = 0;
int stars;
cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
cin >> pattern;
if (pattern == 1)
{
lines = 9;
while (lines > 0)
{
stars = lines;
while (stars > 0)
{
putchar('*');
stars--;
}
putchar('\n');
lines--;
}
}
else if (pattern == 2)
{
lines = 9;
stars = 1;
while (lines > 0)
{
putchar('*');
stars++;
while (stars < 10)
{
putchar('\n');
lines--;
}
}
} //end if
return 0;
}
|
|
From: Ioannis V. <no...@ya...> - 2001-07-20 11:40:30
|
Compiler was released at 24 October 1999. Be patient to wait for the new gcc 3.0 port for windows... Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Jeethu Rao > Sent: Friday, July 20, 2001 10:57 AM > To: Dev CPP Mailing List > Subject: [Dev-C++] [Dev C++] istreambuf_iterator not present > in Dev-C++ ? > > > Hi, > I'm just learning STL. I tried running an example > from Bruce Eckel's book "Thinking in C++". > > This particular example uses istreambuf_iterator . > When I change all occurance of istreambuf_iterator to > istream_iterator, the code works. > > Is the version of STL which comes with Dev-C++ old ? > I'm using Dev-C++ 4.00 Do I need to upgrade ? > > Please Suggest > > Jeethu Rao > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Jeethu R. <je...@sa...> - 2001-07-20 08:54:46
|
Hi, I'm just learning STL. I tried running an example from Bruce Eckel's book "Thinking in C++". This particular example uses istreambuf_iterator . When I change all occurance of istreambuf_iterator to istream_iterator, the code works. Is the version of STL which comes with Dev-C++ old ? I'm using Dev-C++ 4.00 Do I need to upgrade ? Please Suggest Jeethu Rao |
|
From: Ioannis V. <no...@ya...> - 2001-07-19 19:50:55
|
#include <iostream>
int main()
{
using std::cout;
using std::endl;
for(int i=0; i<9; i++)
{
for(int j=9-i; j>0; j--)
cout<<'*';
cout<<endl;
}
}
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
<http://www.noicys.f2s.com/>
* Alternative URL: http://run.to/noicys
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of
Tre...@ao...
Sent: Thursday, July 19, 2001 7:35 PM
To: dev...@li...
Subject: [Dev-C++] nested loop
I have to write a program that uses a nested while loop in order to
display
lines of asterisks from 9 to 1. Here is the code.....can anyone help
me? I
don't understand how to make this work.
#include<iostream>
int main()
{
int asterisk = 9;
int counter = 9;
char ast = '*';
asterisk = (asterisk * ast);
while (counter > 0)
{
cout << asterisk << endl;
counter = counter - 1;
asterisk = asterisk - ast;
while (asterisk > 0)
{
cout << "*" << "" << endl;
}
}
return 0;
}
|
|
From: Schedler, K. <Kur...@hi...> - 2001-07-19 18:44:10
|
I have to wonder why you multiplied 9 times the asterisk character. I can
only presume you thought that would give you nine asterisks in a row. I
imagine that your code spit out a strange number and then hit an infinite
loop, continuously printing asterisks to the screen.
int main()
{
int lines = 9;
int stars;
while (lines > 0)
{
stars = lines;
while (stars > 0)
{
putchar('*');
stars--;
}
putchar('\n');
lines--;
}
return 0;
}
which gives this output:
*********
********
*******
******
*****
****
***
**
*
-----Original Message-----
From: Tre...@ao... [mailto:Tre...@ao...]
Sent: Thursday, July 19, 2001 10:35 AM
To: dev...@li...
Subject: [Dev-C++] nested loop
I have to write a program that uses a nested while loop in order to display
lines of asterisks from 9 to 1. Here is the code.....can anyone help me? I
don't understand how to make this work.
#include<iostream>
int main()
{
int asterisk = 9;
int counter = 9;
char ast = '*';
asterisk = (asterisk * ast);
while (counter > 0)
{
cout << asterisk << endl;
counter = counter - 1;
asterisk = asterisk - ast;
while (asterisk > 0)
{
cout << "*" << "" << endl;
}
}
return 0;
}
"The sender believes that this E-mail and any attachments were free of any
virus, worm, Trojan horse, and/or malicious code when sent. This message
and its attachments could have been infected during transmission. By
reading the message and opening any attachments, the recipient accepts full
responsibility for taking protective and remedial action about viruses and
other defects. The sender's employer is not liable for any loss or damage
arising in any way from this message or its attachments."
|
|
From: <Tre...@ao...> - 2001-07-19 17:35:24
|
I have to write a program that uses a nested while loop in order to display
lines of asterisks from 9 to 1. Here is the code.....can anyone help me? I
don't understand how to make this work.
#include<iostream>
int main()
{
int asterisk = 9;
int counter = 9;
char ast = '*';
asterisk = (asterisk * ast);
while (counter > 0)
{
cout << asterisk << endl;
counter = counter - 1;
asterisk = asterisk - ast;
while (asterisk > 0)
{
cout << "*" << "" << endl;
}
}
return 0;
}
|
|
From: Luigi S. <gi...@li...> - 2001-07-19 17:26:15
|
Iuri-
Suppose that your problem is the following: you have a text file (say it=20
"script") with lines of different lengths, you wish to load a line and=20
print it on the screen until all the lines have been processed.
script
------
aaaaaa
bbbbb
iuri
------
1- assume that you know that no line has more than 10 chars
Here is how I would solve it.
#include <stdio.h>
#include <assert.h>
#define MAX_LEN 11
#define FILE_NAME "script"
int main()
{
char buf[MAX_LEN];
FILE *inp =3D fopen(FILE_NAME, "r");
assert(inp !=3D 0); /* a quick way to report errors */
while (fgets(buf, MAX_LEN, inp))
printf("%s", buf);
fclose(inp);
return 0;
}
As you can see the second argument of fgets is the size of the array where=
=20
the line will be stored, not the size of the line that will be read. Also=20
keep in mind that fgets will read only MAX_LEN - 1 =3D 10 chars, the last=
one=20
will be used by fgets as the place for the '\0'.
So when you write:
fgets(linha1_ptr, sizeof(linha1_ptr), script);
It is "strange" (because usually you already know how big a string is), but=
=20
OK, if by "sizeof(linha1_ptr)" you mean the length of the string linha1_ptr=
=20
before the call to fgets, it is not correct if you mean: "read the line and=
=20
get its length, return this length as the value of sizeof(linha1_ptr)".
Suppose you say: (assume linha1_ptr is an array of 31 chars)
fgets(linha1_ptr, 31, script); /* and load the string "123\n" */
/* now sizeof(linha1_ptr) is 4 */
fgets(linha1_ptr, sizeof(linha1_ptr), script); /* trying to load "iuri\n" */
/* fgets will read 3 chars, "iur", the fourth will be '\0' */
Of course when you say:
fgets(linha1_ptr, 31, script); /* and load the string "123\n" */
fgets(linha1_ptr, 31, script); /* trying to load "iuri\n" */
/* now "iuri" will be loaded as expected */
Hope this clearly explains what should be used as the second argument of=
fgets.
2 - assume that you do not know the size of the biggest line
Here is how I would solve it.
#include <stdio.h>
#include <assert.h>
#include <string.h>
#define FILE_NAME "script"
char *getline(FILE *);
int main(int argc, char *argv[])
{
char *buf;
FILE *inp =3D fopen(FILE_NAME, "r");
assert(inp !=3D 0);
while (buf =3D getline(inp))
{
printf("%s", buf);
free(buf);
}
fclose(inp);
return 0;
}
/*
getline =3D read a line from the file, return the line read.
The string that is returned is always terminated by a '\n'
*/
#define SIZE 6
#define GET_MEM (char *)calloc(len + 1, sizeof(char))
char *getline(FILE *file)
{
char buf[SIZE];
char *line =3D 0;
int len =3D 0;
while (fgets(buf, SIZE, file))
{
char *tmp =3D line;
int n =3D strlen(buf);
len +=3D n;
line =3D GET_MEM;
assert(line !=3D 0);
if (tmp)
{
strcpy(line, tmp);
free(tmp);
}
strcat(line, buf);
if (buf[n - 1] =3D=3D '\n') /* finished reading line */
break;
}
return line;
}
Hope this is of some help
At 14.46 18/07/01 -0300, you wrote:
>Dear Luigi,
> Thank you for your help. I tried to use calloc because de string=
=20
> read from the
>file string has diferent sizes. I.e. the first line of the file script is=
=20
>"iuri", when I write:
>fgets (linha1_ptr ,sizeof(linha1_ptr), script);
> It returns: iur
>If I write:
>fgets (linha1_ptr , 30 , script);
> It returns: iuri
>
>With static memory the problem is that it reads the hole thing:
>So if my string is:
> aaaaaaaaaa
> bbbb
>With the fgets it will read:
> aaaaaaaaaa
> bbbb\0aaaa
>
>I think with sizeof it shouldn't happen, but it does. He reads the size of=
=20
>the 1=BA line and
>returns this same size for every line, even if it's bigger.
>
> Thanks,
> Iuri
---
gisan
|
|
From: <RPG...@ao...> - 2001-07-18 21:05:58
|
The only thing I needed to do was include the windows.h header. I don't know why that solved the problem... but it did. |
|
From: Iuri K. <IK...@am...> - 2001-07-18 17:46:06
|
Dear Luigi, Thank you for your help. I tried to use calloc because de string read from the file string has diferent sizes. I.e. the first line of the file script = is "iuri", when I write: fgets (linha1_ptr ,sizeof(linha1_ptr), script); It returns: iur If I write: fgets (linha1_ptr , 30 , script); It returns: iuri With static memory the problem is that it reads the hole thing: So if my string is: aaaaaaaaaa bbbb With the fgets it will read: aaaaaaaaaa bbbb\0aaaa I think with sizeof it shouldn't happen, but it does. He reads the size = of the 1=BA line and returns this same size for every line, even if it's bigger. Thanks, Iuri Date: Tue, 17 Jul 2001 19:46:44 +0200 To: dev...@li... From: Luigi Santillo <gi...@li...> Subject: Re: [Dev-C++] Malloc Problem Reply-To: dev...@li... In a C program you can ask for memory in a "static fashion" (i.e. at=20 compile time) and in a "dynamic fashion" (i.e. at execution time). When you define "linha1" by the line: char linha1[31]; /* 1 is for the terminating '\0' */ you are using static memory, this means that linha1 will be made of 30=20 chars during the whole execution, and its size is known at compile = time. If you wish to use dynamic memory, then I suggest you use calloc = instead of=20 malloc (calloc is for arrays) char *linha1; ... linha1 =3D (char *)calloc(31, sizeof(char)); /* 1 is for the = terminating '\0' */ When you no longer need the dynamically allocated variable linha1, you=20 should release the memory by the following: free(linha1); Dynamic memory is used when the size of the string is not known in = advance,=20 since in your code, you already know that no string has more than 30 = chars,=20 you should use static memory. In my opinion your code should be: --- #define MAX_SIZE 31 char linha1[MAX_SIZE]; ... fgets(linha1, MAX_SIZE, script); ... --- At 12.51 17/07/01 -0300, you wrote: >I can't find any tutorial about Malloc for strings. >I want to read a string (line) from a file named 'script'. Each line = has=20 >one string with diferent size. >The MAX string will have 30 chars. >I know it is very simple, but I can't find the solution. > Thanks, > Iuri >--------- > char linha1 [30]; > char *linha1_ptr =3D linha1; > linha1_ptr =3D malloc (30); >... > fgets (linha1_ptr , sizeof(linha1_ptr) , script); > printf(linha1_ptr,"\n"); > fputs(linha1_ptr, tudo); > write(sockfd, linha1_ptr, sizeof(linha1_ptr)); > write(sockfd, "\n\r",2); >------------ --- gisan --__--__-- |
|
From: Jarred <sto...@ya...> - 2001-07-18 16:58:56
|
Hellow I am new on this list and have a question about dev c++. I am trying to learn using this program to program in C. What is all the code if I chose windows project it throws in and what will give me a simple doss binary under the type of project? Thanks for any help. Also in that big mess of code that is automaticly put in for windows apps where do I put my own code. ----- Original Message ----- From: "Julio Lajara" <ju2...@ya...> To: <dev...@li...> Sent: Wednesday, July 18, 2001 11:47 AM Subject: [Dev-C++] RE: Trouble compiling OpenGL apss > If you downloaded the complete package of Dev-C++ it > should have already come with GLUT. I dont know if you > wrote the code you are having trouble with yourself or > if you edited the sample code from gamdev.net, but > here is one of my openGL apps that compiles fine with > "-lkernel32 -lopengl32 -lglu32 -lglaux" in the project > options, but I think it has to be a Win32 project > compiled in C++ with .cpp source code file to work: > > #include <windows.h> // Header File For Windows > #include <gl\gl.h> // Header File For The > OpenGL32 Library > #include <gl\glu.h> // Header File For The > GLu32 Library > #include <gl\glaux.h> // Header File For The > GLaux Library > > HGLRC hRC=NULL; // Permanent Rendering Context > HDC hDC=NULL; // Private GDI Device Context > HWND hWnd=NULL; // Holds Our Window Handle > HINSTANCE hInstance; // Holds The Instance Of > The Application > > bool keys[256]; // Array Used For The Keyboard > Routine > bool active=TRUE; // Window Active Flag Set To > TRUE By Default > bool fullscreen=TRUE; // Fullscreen Flag Set To > Fullscreen Mode By Default > > LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); > // Declaration For WndProc > > GLvoid ReSizeGLScene(GLsizei width, GLsizei height) > // Resize And Initialize The GL Window > { > if (height==0) // Prevent A Divide By Zero By > { > height=1; // Making Height Equal One > } > > glViewport(0, 0, width, height); // Reset The > Current Viewport > > glMatrixMode(GL_PROJECTION); // Select The > Projection Matrix > glLoadIdentity(); // Reset The Projection > Matrix > > // Calculate The Aspect Ratio Of The Window > > gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); > > glMatrixMode(GL_MODELVIEW); // Select > The Modelview Matrix > glLoadIdentity(); // Reset The > Modelview Matrix > } > > int InitGL(GLvoid) // All Setup For > OpenGL Goes Here > { > glShadeModel(GL_SMOOTH); // Enables > Smooth Shading > glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black > Background > glClearDepth(1.0f); // Depth Buffer Setup > glEnable(GL_DEPTH_TEST); // Enables Depth > Testing > glDepthFunc(GL_LEQUAL); // The Type Of Depth > Test To Do > glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); > // Really Nice Perspective Calculations > return TRUE; // Initialization Went OK > } > > int DrawGLScene(GLvoid) // Here's Where We Do > All The Drawing > { > glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > // Clear The Screen And The Depth Buffer > glLoadIdentity(); // Reset The Current > Modelview Matrix > glTranslatef(-1.5f,0.0f,-6.0f); // Move Left > 1.5 Units And Into The Screen 6.0 > glBegin(GL_TRIANGLES); // Drawing Using > Triangles > glVertex3f( 0.0f, 1.0f, 0.0f); // Top > glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left > glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right > glEnd(); // Finished Drawing The Triangle > glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 > Units > glBegin(GL_QUADS); // Draw A Quad > glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left > glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right > glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right > glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left > glEnd(); // Done Drawing The Quad > return TRUE; // Everything Went OK > } > > GLvoid KillGLWindow(GLvoid) // Properly Kill The > Window > { > > if (fullscreen) // Are We In Fullscreen Mode? > { > ChangeDisplaySettings(NULL,0); // If So Switch > Back To The Desktop > ShowCursor(TRUE); // Show Mouse Pointer > } > > if (hRC) // Do We Have A Rendering Context? > { > > if (!wglMakeCurrent(NULL,NULL)) // Are We Able > To Release The DC And RC Contexts? > { > MessageBox(NULL,"Release Of DC And RC > Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); > } > > if (!wglDeleteContext(hRC)) // Are We Able To > Delete The RC? > { > MessageBox(NULL,"Release Rendering Context > Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); > } > hRC=NULL; // Set RC To NULL > } > > if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able > To Release The DC > { > MessageBox(NULL,"Release Device Context > Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); > hDC=NULL; // Set DC To NULL > } > > if (hWnd && !DestroyWindow(hWnd)) // Are We Able > To Destroy The Window? > { > MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN > ERROR",MB_OK | MB_ICONINFORMATION); > hWnd=NULL; // Set hWnd To NULL > } > > if (!UnregisterClass("OpenGL",hInstance)) // Are We > Able To Unregister Class > { > MessageBox(NULL,"Could Not Unregister > Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); > hInstance=NULL; // Set hInstance To NULL > } > } > > BOOL CreateGLWindow(char* title, int width, int > height, int bits, bool fullscreenflag) > { > GLuint PixelFormat; // Holds The Results After > Searching For A Match > WNDCLASS wc; // Windows Class Structure > DWORD dwExStyle; // Window Extended Style > DWORD dwStyle; // Window Style > RECT WindowRect; // Grabs Rectangle Upper Left > / Lower Right Values > WindowRect.left=(long)0; // Set Left Value To 0 > WindowRect.right=(long)width; // Set Right Value > To Requested Width > WindowRect.top=(long)0; // Set Top Value To 0 > WindowRect.bottom=(long)height; // Set Bottom > Value To Requested Height > fullscreen=fullscreenflag; // Set The Global > Fullscreen Flag > hInstance = GetModuleHandle(NULL); // Grab An > Instance For Our Window > wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // > Redraw On Move, And Own DC For Window > wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc > Handles Messages > wc.cbClsExtra = 0; // No Extra Window Data > wc.cbWndExtra = 0; // No Extra Window Data > wc.hInstance = hInstance; // Set The Instance > wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load > The Default Icon > wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load > The Arrow Pointer > wc.hbrBackground = NULL; // No Background > Required For GL > wc.lpszMenuName = NULL; // We Don't Want A Menu > wc.lpszClassName = "OpenGL"; // Set The Class > Name > > if (!RegisterClass(&wc)) // Attempt To Register > The Window Class > { > MessageBox(NULL,"Failed To Register The Window > Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Exit And Return FALSE > } > > if (fullscreen) // Attempt Fullscreen Mode? > { > DEVMODE dmScreenSettings; // Device Mode > > memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); > // Makes Sure Memory's Cleared > dmScreenSettings.dmSize=sizeof(dmScreenSettings); > // Size Of The Devmode Structure > dmScreenSettings.dmPelsWidth = width; // Selected > Screen Width > dmScreenSettings.dmPelsHeight = height; // > Selected Screen Height > dmScreenSettings.dmBitsPerPel = bits; // Selected > Bits Per Pixel > > dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; > > // Try To Set Selected Mode And Get Results. NOTE: > CDS_FULLSCREEN Gets Rid Of Start Bar. > if > (ChangeDisplaySettings(&dmScreenSettings,SHOW_FULLSCREEN)!=DISP_CHANGE_SUCCE SSFUL) > { > // If The Mode Fails, Offer Two Options. Quit Or > Run In A Window. > if (MessageBox(NULL,"The Requested Fullscreen Mode > Is Not Supported By\nYour Video Card. Use Windowed > Mode Instead?","NeHe > GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) > { > fullscreen=FALSE; // Select Windowed Mode > (Fullscreen=FALSE) > } > else > { > // Pop Up A Message Box Letting User Know The > Program Is Closing. > MessageBox(NULL,"Program Will Now > Close.","ERROR",MB_OK|MB_ICONSTOP); > return FALSE; // Exit And Return FALSE > } > } > } > > if (fullscreen) // Are We Still In Fullscreen > Mode? > { > dwExStyle=WS_EX_APPWINDOW; // Window Extended > Style > dwStyle=WS_POPUP; // Windows Style > ShowCursor(FALSE); // Hide Mouse Pointer > } > else > { > dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // > Window Extended Style > dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style > } > > AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, > dwExStyle); // Adjust Window To True Requested Size > > if (!(hWnd=CreateWindowEx( dwExStyle, // Extended > Style For The Window > "OpenGL", // Class Name > title, // Window Title > WS_CLIPSIBLINGS | // Required Window Style > WS_CLIPCHILDREN | // Required Window Style > dwStyle, // Selected Window Style > 0, 0, // Window Position > WindowRect.right-WindowRect.left, // Calculate > Adjusted Window Width > WindowRect.bottom-WindowRect.top, // Calculate > Adjusted Window Height > NULL, // No Parent Window > NULL, // No Menu > hInstance, // Instance > NULL))) // Don't Pass Anything To WM_CREATE > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Window Creation > Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > static PIXELFORMATDESCRIPTOR pfd= // pfd Tells > Windows How We Want Things To Be > { > sizeof(PIXELFORMATDESCRIPTOR), // Size Of This > Pixel Format Descriptor > 1, // Version Number > PFD_DRAW_TO_WINDOW | // Format Must Support > Window > PFD_SUPPORT_OPENGL | // Format Must Support > OpenGL > PFD_DOUBLEBUFFER, // Must Support Double > Buffering > PFD_TYPE_RGBA, // Request An RGBA Format > bits, // Select Our Color Depth > 0, 0, 0, 0, 0, 0, // Color Bits Ignored > 0, // No Alpha Buffer > 0, // Shift Bit Ignored > 0, // No Accumulation Buffer > 0, 0, 0, 0, // Accumulation Bits Ignored > 16, // 16Bit Z-Buffer (Depth Buffer) > 0, // No Stencil Buffer > 0, // No Auxiliary Buffer > PFD_MAIN_PLANE, // Main Drawing Layer > 0, // Reserved > 0, 0, 0 // Layer Masks Ignored > }; > > if (!(hDC=GetDC(hWnd))) // Did We Get A Device > Context? > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Can't Create A GL Device > Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // > Did Windows Find A Matching Pixel Format? > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Can't Find A Suitable > PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are > We Able To Set The Pixel Format? > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Can't Set The > PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > if (!(hRC=wglCreateContext(hDC))) // Are We Able > To Get A Rendering Context? > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Can't Create A GL Rendering > Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > if(!wglMakeCurrent(hDC,hRC)) // Try To Activate > The Rendering Context > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Can't Activate The GL Rendering > Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > ShowWindow(hWnd,SW_SHOW); // Show The Window > SetForegroundWindow(hWnd); // Slightly Higher > Priority > SetFocus(hWnd); // Sets Keyboard Focus To The > Window > ReSizeGLScene(width, height); // Set Up Our > Perspective GL Screen > > if (!InitGL()) // Initialize Our Newly Created > GL Window > { > KillGLWindow(); // Reset The Display > MessageBox(NULL,"Initialization > Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); > return FALSE; // Return FALSE > } > > return TRUE; // Success > } > > 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); > } > > int WINAPI WinMain( HINSTANCE hInstance, // > Instance > HINSTANCE hPrevInstance, // Previous Instance > LPSTR lpCmdLine, // Command Line Parameters > int nCmdShow) // Window Show State > { > > MSG msg; // Windows Message Structure > BOOL done=FALSE; // Bool Variable To Exit Loop > > // Ask The User Which Screen Mode They Prefer > if (MessageBox(NULL,"Would You Like To Run In > Fullscreen Mode?", "Start > FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) > { > fullscreen=FALSE; // Windowed Mode > } > > // Create Our OpenGL Window > if (!CreateGLWindow("NeHe's OpenGL > Framework",640,480,16,fullscreen)) > { > return 0; // Quit If Window Was Not Created > } > > while(!done) // Loop That Runs Until done=TRUE > { > > if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is > There A Message Waiting? > { > > if (msg.message==WM_QUIT) // Have We Received A > Quit Message? > { > done=TRUE; // If So done=TRUE > } > else // If Not, Deal With Window Messages > { > TranslateMessage(&msg); // Translate The > Message > DispatchMessage(&msg); // Dispatch The Message > } > } > else // If There Are No Messages > { > > // Draw The Scene. Watch For ESC Key And Quit > Messages From DrawGLScene() > if (active) // Program Active? > { > if (keys[VK_ESCAPE]) // Was ESC Pressed? > { > done=TRUE; // ESC Signalled A Quit > } > else // Not Time To Quit, Update Screen > { > > DrawGLScene(); // Draw The Scene > SwapBuffers(hDC); // Swap Buffers (Double > Buffering) > } > } > > if (keys[VK_F1]) // Is F1 Being Pressed? > { > keys[VK_F1]=FALSE; // If So Make Key FALSE > KillGLWindow(); // Kill Our Current Window > fullscreen=!fullscreen; // Toggle Fullscreen / > Windowed Mode > // Recreate Our OpenGL Window > if (!CreateGLWindow("NeHe's OpenGL > Framework",640,480,16,fullscreen)) > { > return 0; // Quit If Window Was Not Created > } > } > } > } > > // Shutdown > KillGLWindow(); // Kill The Window > return (msg.wParam); // Exit The Program > } > > > ===== > Julio > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |
|
From: Julio L. <ju2...@ya...> - 2001-07-18 15:47:58
|
If you downloaded the complete package of Dev-C++ it should have already come with GLUT. I dont know if you wrote the code you are having trouble with yourself or if you edited the sample code from gamdev.net, but here is one of my openGL apps that compiles fine with "-lkernel32 -lopengl32 -lglu32 -lglaux" in the project options, but I think it has to be a Win32 project compiled in C++ with .cpp source code file to work: #include <windows.h> // Header File For Windows #include <gl\gl.h> // Header File For The OpenGL32 Library #include <gl\glu.h> // Header File For The GLu32 Library #include <gl\glaux.h> // Header File For The GLaux Library HGLRC hRC=NULL; // Permanent Rendering Context HDC hDC=NULL; // Private GDI Device Context HWND hWnd=NULL; // Holds Our Window Handle HINSTANCE hInstance; // Holds The Instance Of The Application bool keys[256]; // Array Used For The Keyboard Routine bool active=TRUE; // Window Active Flag Set To TRUE By Default bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window { if (height==0) // Prevent A Divide By Zero By { height=1; // Making Height Equal One } glViewport(0, 0, width, height); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } int InitGL(GLvoid) // All Setup For OpenGL Goes Here { glShadeModel(GL_SMOOTH); // Enables Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations return TRUE; // Initialization Went OK } int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_TRIANGLES); // Drawing Using Triangles glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd(); // Finished Drawing The Triangle glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad return TRUE; // Everything Went OK } GLvoid KillGLWindow(GLvoid) // Properly Kill The Window { if (fullscreen) // Are We In Fullscreen Mode? { ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop ShowCursor(TRUE); // Show Mouse Pointer } if (hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? { MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hRC=NULL; // Set RC To NULL } if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC { MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hDC=NULL; // Set DC To NULL } if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window? { MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hWnd=NULL; // Set hWnd To NULL } if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class { MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } } BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left=(long)0; // Set Left Value To 0 WindowRect.right=(long)width; // Set Right Value To Requested Width WindowRect.top=(long)0; // Set Top Value To 0 WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height fullscreen=fullscreenflag; // Set The Global Fullscreen Flag hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "OpenGL"; // Set The Class Name if (!RegisterClass(&wc)) // Attempt To Register The Window Class { MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Exit And Return FALSE } if (fullscreen) // Attempt Fullscreen Mode? { DEVMODE dmScreenSettings; // Device Mode memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (ChangeDisplaySettings(&dmScreenSettings,SHOW_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Run In A Window. if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen=FALSE; // Select Windowed Mode (Fullscreen=FALSE) } else { // Pop Up A Message Box Letting User Know The Program Is Closing. MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); return FALSE; // Exit And Return FALSE } } } if (fullscreen) // Are We Still In Fullscreen Mode? { dwExStyle=WS_EX_APPWINDOW; // Window Extended Style dwStyle=WS_POPUP; // Windows Style ShowCursor(FALSE); // Hide Mouse Pointer } else { dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window "OpenGL", // Class Name title, // Window Title WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN | // Required Window Style dwStyle, // Selected Window Style 0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Adjusted Window Width WindowRect.bottom-WindowRect.top, // Calculate Adjusted Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL))) // Don't Pass Anything To WM_CREATE { KillGLWindow(); // Reset The Display MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format bits, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } return TRUE; // Success } 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); } int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters int nCmdShow) // Window Show State { MSG msg; // Windows Message Structure BOOL done=FALSE; // Bool Variable To Exit Loop // Ask The User Which Screen Mode They Prefer if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) { fullscreen=FALSE; // Windowed Mode } // Create Our OpenGL Window if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } while(!done) // Loop That Runs Until done=TRUE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done=TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene() if (active) // Program Active? { if (keys[VK_ESCAPE]) // Was ESC Pressed? { done=TRUE; // ESC Signalled A Quit } else // Not Time To Quit, Update Screen { DrawGLScene(); // Draw The Scene SwapBuffers(hDC); // Swap Buffers (Double Buffering) } } if (keys[VK_F1]) // Is F1 Being Pressed? { keys[VK_F1]=FALSE; // If So Make Key FALSE KillGLWindow(); // Kill Our Current Window fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode // Recreate Our OpenGL Window if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } } } } // Shutdown KillGLWindow(); // Kill The Window return (msg.wParam); // Exit The Program } ===== Julio __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
|
From: Nurhidayat <dh...@ma...> - 2001-07-18 06:56:38
|
At 05:20 PM 7/17/01 EDT, you wrote: >I searched for and found both _imp__glColor3f@ and _imp__glClear@ in the libopengl32.a file. I couldn't understand all the characters in the file, but those two strings were in it. > >Putting -lopengl32 has the same effect as putting C:\Dev-C++\lib\libopengl32.a further option files box, correct? They both result in these error messages. Yes, putting -lopengl32 has the same effect as putting C:\Dev-++\lib\libopengl32.a further option files box. >Are you using a different version of the libraries than I am? I use opengl library from Dev-C++ 4.0 installation, and get glut library from downloadable source Glut-MingW-Dev-C++.Zip size=97.8KB (I forget the url, but I can sent you that file) ___Nurhidayat___ |
|
From: Nurhidayat <dh...@ma...> - 2001-07-18 05:45:56
|
>I'm trying to use the system() function in dev-c++ ... but it don't work >.... >Why ?? The system() is a function of stdio.h ?? why it don't work ... please >show me the correct mode ... if i'm making something wrong ... system() is a function of stdlib.h ___Nurhidayat___ |
|
From: <RPG...@ao...> - 2001-07-17 21:21:10
|
I searched for and found both _imp__glColor3f@ and _imp__glClear@ in the libopengl32.a file. I couldn't understand all the characters in the file, but those two strings were in it. Putting -lopengl32 has the same effect as putting C:\Dev-C++\lib\libopengl32.a further option files box, correct? They both result in these error messages. c:\my documents\simpleglmain.o(.text+0x19):simpleglmain.c: undefined reference to `_imp__glClear' c:\my documents\simpleglmain.o(.text+0x36):simpleglmain.c: undefined reference to `_imp__glColor3f' c:\my documents\simpleglmain.o(.text+0x46):simpleglmain.c: undefined reference to `_imp__glBegin' c:\my documents\simpleglmain.o(.text+0x6e):simpleglmain.c: undefined reference to `_imp__glVertex3f' c:\my documents\simpleglmain.o(.text+0x96):simpleglmain.c: undefined reference to `_imp__glVertex3f' c:\my documents\simpleglmain.o(.text+0xbe):simpleglmain.c: undefined reference to `_imp__glVertex3f' c:\my documents\simpleglmain.o(.text+0xe6):simpleglmain.c: undefined reference to `_imp__glVertex3f' c:\my documents\simpleglmain.o(.text+0xf1):simpleglmain.c: undefined reference to `_imp__glEnd' c:\my documents\simpleglmain.o(.text+0xf9):simpleglmain.c: undefined reference to `_imp__glFlush' c:\my documents\simpleglmain.o(.text+0x121):simpleglmain.c: undefined reference to `_imp__glClearColor' c:\my documents\simpleglmain.o(.text+0x134):simpleglmain.c: undefined reference to `_imp__glMatrixMode' c:\my documents\simpleglmain.o(.text+0x13f):simpleglmain.c: undefined reference to `_imp__glLoadIdentity' c:\my documents\simpleglmain.o(.text+0x170):simpleglmain.c: undefined reference to `_imp__glOrtho' c:\my documents\simpleglmain.o(.text+0x1a3):simpleglmain.c: undefined reference to `glutInit' c:\my documents\simpleglmain.o(.text+0x1b0):simpleglmain.c: undefined reference to `glutInitDisplayMode' c:\my documents\simpleglmain.o(.text+0x1c5):simpleglmain.c: undefined reference to `glutInitWindowSize' c:\my documents\simpleglmain.o(.text+0x1d4):simpleglmain.c: undefined reference to `glutInitWindowPosition' c:\my documents\simpleglmain.o(.text+0x1e4):simpleglmain.c: undefined reference to `glutCreateWindow' c:\my documents\simpleglmain.o(.text+0x1f9):simpleglmain.c: undefined reference to `glutDisplayFunc' c:\my documents\simpleglmain.o(.text+0x201):simpleglmain.c: undefined reference to `glutMainLoop' Are you using a different version of the libraries than I am? |
|
From: Julio L. <ju2...@ya...> - 2001-07-17 20:24:39
|
I used the GDB debugger included in Dev-C++ to debug one of my programs which would constantly crash, no matter how many things I changed in the code. When I ran the debugger and it crashed the debugger said the program got a signal (SIGSEGV I think) and said it was a segmentation fault. Does anyone know what that is, what might cause it, or how I can fix it in my code?? ===== Julio __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
|
From: Julio L. <ju2...@ya...> - 2001-07-17 19:40:47
|
You can use the tutorials on nehe.gamedev.net for OpenGL and get their sample code to compile perfectly on Dev-C++, I have done it myself. The only thing is that you have to make the smaple code projects yourself, not download the projects they have at the bottom of the page. Try this: 1.Create a new project in Dev-C++ with a source file. 2.Go to the NeHe OpenGL tutorial lessons page and copy all the green lines of code and paste it into your source code file. 3.Go to Project Options and in the first blank line(Further Object Files or linker options) put " -lkernel32 -lopengl32 -lglu32 -lglaux " and compile the project. It should now compile without a problem. ===== Julio __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
|
From: Luigi S. <gi...@li...> - 2001-07-17 18:09:17
|
In a C program you can ask for memory in a "static fashion" (i.e. at compile time) and in a "dynamic fashion" (i.e. at execution time). When you define "linha1" by the line: char linha1[31]; /* 1 is for the terminating '\0' */ you are using static memory, this means that linha1 will be made of 30 chars during the whole execution, and its size is known at compile time. If you wish to use dynamic memory, then I suggest you use calloc instead of malloc (calloc is for arrays) char *linha1; ... linha1 = (char *)calloc(31, sizeof(char)); /* 1 is for the terminating '\0' */ When you no longer need the dynamically allocated variable linha1, you should release the memory by the following: free(linha1); Dynamic memory is used when the size of the string is not known in advance, since in your code, you already know that no string has more than 30 chars, you should use static memory. In my opinion your code should be: --- #define MAX_SIZE 31 char linha1[MAX_SIZE]; ... fgets(linha1, MAX_SIZE, script); ... --- At 12.51 17/07/01 -0300, you wrote: >I can't find any tutorial about Malloc for strings. >I want to read a string (line) from a file named 'script'. Each line has >one string with diferent size. >The MAX string will have 30 chars. >I know it is very simple, but I can't find the solution. > Thanks, > Iuri >--------- > char linha1 [30]; > char *linha1_ptr = linha1; > linha1_ptr = malloc (30); >... > fgets (linha1_ptr , sizeof(linha1_ptr) , script); > printf(linha1_ptr,"\n"); > fputs(linha1_ptr, tudo); > write(sockfd, linha1_ptr, sizeof(linha1_ptr)); > write(sockfd, "\n\r",2); >------------ --- gisan |
|
From: Luigi S. <gi...@li...> - 2001-07-17 18:09:16
|
First: when you need the function "system" you should include <stdlib.h>.
then the prototype of "system" says:
int system(const char *s);
this means that you are allowed to pass only one string to "system", in
other words: "system" resembles "puts" and not "printf".
Try the following:
---
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BUF 50 /* "echo " and var will surely fit in it */
int main()
{
char var[15];
char buf[MAX_BUF];
printf("\nType the environment that u want see the value: ");
scanf("%s",&var);
strcpy(buf, "echo ");
strcat(buf, var);
system(buf);
return(0);
}
At 14.21 17/07/01 -0300, you wrote:
>Hi,
>
>I'm trying to use the system() function in dev-c++ ... but it don't work
>....
>
>I was trying of this mode:
>
>#include <stdio.h>
>#include <conio.h>
>
>int main()
>{
> char var[15];
>
> printf("\nType the environment that u want see the value: ");
> scanf("%s",&var);
>
> system("echo %s",var);
>
> return(0);
>}
>
>Then when i try compile this program i get the error:
>
>16 f:\dev-c_~1\untitl~1.cpp
> implicit declaration of function `int system(...)'
>
>
>Why ?? The system() is a function of stdio.h ?? why it don't work ... please
>show me the correct mode ... if i'm making something wrong ...
>
>thkz
>
>Cheers
>
>[ ]'s
>
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
---
gisan
|
|
From: Wendel <we...@ha...> - 2001-07-17 17:19:45
|
Hi,
I'm trying to use the system() function in dev-c++ ... but it don't work
....
I was trying of this mode:
#include <stdio.h>
#include <conio.h>
int main()
{
char var[15];
printf("\nType the environment that u want see the value: ");
scanf("%s",&var);
system("echo %s",var);
return(0);
}
Then when i try compile this program i get the error:
16 f:\dev-c_~1\untitl~1.cpp
implicit declaration of function `int system(...)'
Why ?? The system() is a function of stdio.h ?? why it don't work ... please
show me the correct mode ... if i'm making something wrong ...
thkz
Cheers
[ ]'s
|
|
From: Iuri K. <IK...@am...> - 2001-07-17 15:51:41
|
I can't find any tutorial about Malloc for strings.
I want to read a string (line) from a file named 'script'. Each line has one
string with diferent size.
The MAX string will have 30 chars.
I know it is very simple, but I can't find the solution.
Thanks,
Iuri
---------
char linha1 [30];
char *linha1_ptr = linha1;
linha1_ptr = malloc (30);
...
fgets (linha1_ptr , sizeof(linha1_ptr) , script);
printf(linha1_ptr,"\n");
fputs(linha1_ptr, tudo);
write(sockfd, linha1_ptr, sizeof(linha1_ptr));
write(sockfd, "\n\r",2);
------------
|
|
From: Nurhidayat <dh...@ma...> - 2001-07-17 06:36:42
|
Try search _imp__glClear@ and _imp__glColor3f@ in libopengl32.a file using your text editor. Be carefull. Don't modified by your text editor, because *.a is a binary file. ___Nurhidayat___ |
|
From: Nurhidayat <dh...@ma...> - 2001-07-17 06:32:56
|
At 01:55 AM 7/17/01 EDT, you wrote:
>I read the faq in the built in help about OpenGL, and put these two
options in the Project/Further Object files
>
>-lopengl32 -lglut32
>
>I try to compile this source from an OpenGL book, but get many errors.
Skip the code if you want... I doubt that's the problem.
>All the errors I get look like this... so no point in pasting them all.
Different errors for every gl/glut call made in the program.
>
>c:\my documents\simpleglmain.o(.text+0x19):simpleglmain.c: undefined
reference to `_imp__glClear'
>c:\my documents\simpleglmain.o(.text+0x36):simpleglmain.c: undefined
reference to `_imp__glColor3f'
>
>What am I doing wrong?
>
I try recompile your source code, but I don't found any errors.
Two functions: glClear and glColor3f those your compiler reported, are
contained by libopengl32.a library. Try search _imp__glClear@ and
_imp__glColor3f@ in libopengl32.a file using your text editor. If you
wouldn't find them, you may have incomplete/broken library file. If you
find, please check your project options.
-lopengl32 with ('l' lowercase) is different to -Lopengl32 ('L' uppercase).
___Nurhidayat___
|
|
From: <RPG...@ao...> - 2001-07-17 05:55:36
|
I read the faq in the built in help about OpenGL, and put these two options in the Project/Further Object files
-lopengl32 -lglut32
I try to compile this source from an OpenGL book, but get many errors. Skip the code if you want... I doubt that's the problem.
-------------------------CODE------------------------
#include <GL/glut.h>
#include <GL/gl.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}
-------------------------END CODE------------------------
All the errors I get look like this... so no point in pasting them all. Different errors for every gl/glut call made in the program.
c:\my documents\simpleglmain.o(.text+0x19):simpleglmain.c: undefined reference to `_imp__glClear'
c:\my documents\simpleglmain.o(.text+0x36):simpleglmain.c: undefined reference to `_imp__glColor3f'
What am I doing wrong?
|
|
From: Jeethu R. <je...@sa...> - 2001-07-17 05:12:00
|
go to www.gamecoding.co.uk they have a tutorial on OpenGL with DevC++ Regards, Jeethu Rao > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of Brasier > Sent: Monday, July 09, 2001 1:37 AM > To: dev...@li... > Subject: [Dev-C++] help please > > > Hi, > > Can someone PLEASE tell me a website that is HTML (no downloads) > that can give me a full a-z tutorial on OPEN GL for the DEV C++ > compiler... > i have tried nehe.gamedev.net but that is for visual C++ and i am > far too new to translate :) > > Thanks for any info.... > > Steve.B > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: <Kai...@me...> - 2001-07-16 23:03:56
|
Ich werde ab 16.07.2001 nicht im B=FCro sein. Ich kehre zur=FCck am 17.08.2001. = |