Inventory, text game [Archive] - C Board

PDA

View Full Version : Inventory, text game


Pages : [1] 2

Blizzarddog
01-14-2003, 10:48 AM
I don't want to use my previous engine. it was this:


int sword = 0;

if (sword == o)
this
else if (sword == 1)
that


I want to be able to pick up and item when crossed, then use it or drop it later on.
How would i do that?

no-one
01-18-2003, 03:47 PM
thats kind of vague, please elaborate.

RoD
01-18-2003, 03:53 PM
you mean if u "step" on it?

RoD
01-18-2003, 04:07 PM
well if thats what u meant, when i first started programming i had a text game, heres how i did it for picking up the amulet:


/************************************************** *************
************************************************** **************
Code for Amulet
************************************************** **************
************************************************** *************/
if (User_Location_X == 0 && User_Location_Y == 5)
{
if (Amulet == 1)
{
cout <<"You have returned to where you found Soris's Amulet.\n\n";

}

else if (Amulet == 0)
{
cout <<"You found Soris's Amulet!\n\n";
cout <<"You feel protected and are awarded ten points.\n\n";
Amulet = 1;

}
}



If you want to see all of the code just ask i'll post it as an attachment.

Jeremy G
01-18-2003, 05:37 PM
Here are some of the data structures I've used for text games


enum eItemFunction { eOnce, eInfinite, eFinite, eTimeLimited }; // how many times can you use item?

enum eRoomType { ePath, eWall, eRoom }; // types of rooms

struct sItem {
char* itemName;
int itemStrBonus;
int itemLifeBonus;
eItemFunction itemUse;
}


struct sMapRoom {
eRoomType roomType;
sItem roomItems[4]; // max of 4 items
char* roomDescription;
bool bNeedKey;
char* keyName;
}

struct sMap {
sMapRoom mapRooms[100][100];
char* mapDescription;
// map details like geography etc.
}

struct sPlayer {
sItem Inventory[32];
int Life;
int x; // map co-ordinates
int y;
// etc.
}

Blizzarddog
01-20-2003, 09:23 AM
That helps out a little... but how would i ADD the items to the inventory? My first game was using RoDs engine. i created about 1800 lines of that crap.... and the game was really bad. after 6 games of that i got into using structures... my latest source is this
attached. Its a game to rival my dads Beave hunter (beave is my nickname). So It's called Dad Hunter. LOL. But when i start the game, im already on that wierd floor with the trap on it.. no matter what, then when i add to the skill, max_y etc, it performs an illegal operation. That really irritates me.

Travis Dane
01-20-2003, 09:34 AM
Originally posted by Blizzarddog
My first game was using RoDs engine.

Hm, wha? where? huh? RoD made an engine? Tell me about it!
Dad Hunter makes me think of my time in BASIC :p
You should do something about it, put some things in functions.

RoD
01-20-2003, 09:42 AM
it was in my first week of C++, i had a junky-at-best txt game that ran on if's, a switch or two, and user input...i mean it was ok but i wouldn't consider it an engine...

Travis Dane
01-20-2003, 09:45 AM
My first game was using RoDs engine and the game was really bad.

I love Cut & Paste
:D

Blizzarddog
01-20-2003, 09:46 AM
I call anything that the game runs on an engine, what makes things happen. In my experiance in ZZT, my company made a game call mech trainer with the player at the bottom of the screen controlling the mech above him. That is an engine. If (sword == 2) do this, i consider that an engine because else if (sword == 1) do that

RoD
01-20-2003, 09:47 AM
if its an engine its a ford....prone to problems....

Blizzarddog
01-20-2003, 09:49 AM
And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
And i dont care much for sarcaasm.. bad week.

Blizzarddog
01-20-2003, 09:49 AM
Originally posted by RoD
if its an engine its a ford....prone to problems....
I hear ya.

Travis Dane
01-20-2003, 09:51 AM
Originally posted by Blizzarddog
And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
And i dont care much for sarcaasm.. bad week.

Hmmmmm, it was a joke for RoD, anyhow sorryZ.

RoD
01-20-2003, 09:53 AM
i got the joke, guess he missed it...

Blizzarddog
01-20-2003, 09:55 AM
Okay... but my other nickname is some how CNP... Cut 'n Paste because i was to busy to answer my dad when he asked me what && is, what cpp programmer doesn't know what && is?

Travis Dane
01-20-2003, 09:56 AM
I kinda like the idea of writing an Engine for ungifted c++
programmers. Is there much need for a Console App Engine?

Travis Dane
01-20-2003, 09:57 AM
Originally posted by Blizzarddog
what cpp programmer doesn't know what && is?

A beginning one?

RoD
01-20-2003, 09:59 AM
Nah, a dos engine is fairly simple. It needs a coord system, etc. Gimme your email and i'll send you mine if you want.

Blizzarddog
01-20-2003, 10:01 AM
I knew what it was when i first picked up a cpp book when i was 13, about 1/5 year ago. And i need it so that i can actually start a real game... I dont know any thing about the windows programming.

RoD
01-20-2003, 10:03 AM
If your serious about game programming, you should learn opengl or directx....at first i didn't know any winapi, and it was really confusing and intimidating as to where and when to start, been i've been in opengl for a few weeks now, and i'm getting prepared to build a game engine and do my first FPS, ever. Dive in, the water will be warm soon enough!

Blizzarddog
01-20-2003, 10:05 AM
Hey rod, your not talking about your Caverns game, are you?
the one like this:


cin >> name; /* Store users name*/

cout <<"Hello "<< name <<" , do u think you can escape the caverns?\n\n";
cout <<"Your objective is to stay alive and aquire 100 points.\n\n";
cout <<"Both of these tasks are possible, and with a little ";
cout <<"logic u will succeed.\n\n";

cout <<"You may see controls at any time by pressing (I)\n\n";

getch(); /* Wait for key push and continue.*/


do/* Start loop*/
{

/* Check user position.*/
if (User_Location_Y == 25)
{
cout <<"You cannot continue in this direction\n";
User_Location_Y--;
getch();
}

else if (User_Location_Y == -25)
{
cout <<"You cannot continue in this direction\n";
User_Location_Y++;
getch();
}

else if (User_Location_X == 25)
{
cout <<"You cannot continue in this direction\n";
User_Location_X--;
getch();
}

else if (User_Location_X == -25)
{
cout <<"You cannot continue in this direction\n";
User_Location_X++;
}


/* This decrements by 1 every loop, when it hits 0 game ends.*/
end_game--;

if (end_game == 0)
{

system("cls");
cout <<"You have used all your energy, GAME OVER!\n";
return 0;
}

/* This displays every loop.*/
system("cls");

cout <<"North (1)\nSouth (2)\nEast (3)\nWest (4)\n\n";
cin >>input;
cout <<"\n";


/* Key for user initiated exit.*/
if (input == 'Q' || input == 'q')
{
system("cls");
return 0;
}

RoD
01-20-2003, 10:08 AM
not in my last post no. What you have there is my really, really old engine, i improved some stuff since then but caverns is an abandoned newbie project.

I'm talking bout a 3d opengl graphics engine that my FPS (and prolly a few others as i improve) will be based off.

Blizzarddog
01-20-2003, 10:09 AM
when I start a windows project a window looks like this:

#include <windows.h>

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use light-gray as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);

/* Register the window class, if fail quit the program */
if(!RegisterClassEx(&wincl)) return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow(hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage( ) returns 0 */
while(GetMessage(&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}

/* The program return-value is 0 - The value that PostQuitMessage( ) gave */
return messages.wParam;
}

/* This function is called by the Windows function DispatchMessage( ) */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}

where exactly do i use textout and stuff?

RoD
01-20-2003, 10:11 AM
Run this:

/* Steven Billington
*/

/* Here we set the libraries to be used in the program, and
trim some of the excess off of windows
*/

#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glaux.lib")


/* Include all needed headers for the project. Windows brings in
everything needed for the basic application, and the other three
bring in OpenGL related functions.
*/

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


/* These are our global variables. These are ok in this program,
but i wouldn't reccomend making a habit out of using global
variables.

angle: Holds current angle of rotating triangle
g_HDC: Global Device Context
*/

float angle = 0.0f;
HDC g_HDC;


/* Function: SetupPixelFormat

Purpose: This function gets the setup for the pixel format,
go figure right?
*/

void SetupPixelFormat(HDC hDC)
{
int nPixelFormat; /* Pixel format index*/

static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), //size of structure
1, //version, always set to one
PFD_DRAW_TO_WINDOW | //support window
PFD_SUPPORT_OPENGL | //support opengl
PFD_DOUBLEBUFFER, //support double buffering
PFD_TYPE_RGBA, //RGBA color mode
32, //32bit color mode
0,0,0,0,0,0, //ignore color bits, not used
0, //no alpha buffer
0, //ignore shift bit
0, //no accumulation buffer
0,0,0,0, //ignore accumulation buffers
16, //16 bit zbuffer size
0, //no stencil buffer
0, //no auxiliary buffer
PFD_MAIN_PLANE, //main drawing plane
0, //reserved
0,0,0 }; //layer masks ignored

/* Choose best matching pixel format, return index*/
nPixelFormat = ChoosePixelFormat(hDC,&pfd);

/* Set pixel format to device context*/
SetPixelFormat(hDC,nPixelFormat,&pfd);
}

/* Function: WndProc

Purpose: This is our Windows Procedure Event Handler
*/

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HGLRC hRC; //rendering context
static HDC hDC; //device context
char string[] = "Hello World!"; //display text
int width, height; //window width, height

switch(message)
{
case WM_CREATE: //window is being created

hDC = GetDC(hwnd); //get current windows device context
g_HDC = hDC;
SetupPixelFormat(hDC); //call your pixel format setup function

//create rendering context and make it current
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);

return 0;
break;

case WM_CLOSE: //window is closing

//deselect rendering context and delete it
wglMakeCurrent(hDC,NULL);
wglDeleteContext(hRC);

//send WM_QUIT to messagr queue
PostQuitMessage(0);

return 0;
break;

case WM_SIZE:

height = HIWORD(lParam); //get height and width
width = LOWORD(lParam);

if (height == 0) //don't want a divide by 0
{
height = 1;
}

//reset the viewport to new dimensions
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION); //set projection matrix
glLoadIdentity(); //reset proj matrix

//calculate aspect ratio of window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f);

glMatrixMode(GL_MODELVIEW); //set modelview matrix
glLoadIdentity(); //reset mdeolv matrix

return 0;
break;

default:
break;


}

return (DefWindowProc(hwnd,message,wParam,lParam));
}

/* Function: WinMain

Purpose: Do i need to state this? Ok, its the main function.
*/

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX windowClass; //window class
HWND hwnd; //window handle
MSG msg; //message
bool done; //flag saying when app is complete

/* Fill out the window class structure*/
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "MyClass";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

/* Register window class*/
if (!RegisterClassEx(&windowClass))
{
return 0;
}

/* Class registerd, so now create window*/
hwnd = CreateWindowEx(NULL, //extended style
"MyClass", //class name
"A Real OGL Win App", //app name
WS_OVERLAPPEDWINDOW | //window style
WS_VISIBLE |
WS_SYSMENU |
WS_CLIPCHILDREN |
WS_CLIPSIBLINGS,
100,100, //x/y coords
400,400, //width,height
NULL, //handle to parent
NULL, //handle to menu
hInstance, //application instance
NULL); //no extra parameter's

/* Check if window creation failed*/
if (!hwnd)
{
return 0;
}

ShowWindow(hwnd,SW_SHOW); //displays window
UpdateWindow(hwnd); //update window

done = false; //inititalize condition variable

//main message loop
while(!done)
{
PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);

if (msg.message == WM_QUIT)
{
done = true;
}

else
{
//do rendering here
//clear screen and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); //reset modelview matrix

angle = angle + 0.1f; //increase rotation angle counter

if (angle >= 360.0f) //reset angle counter
{
angle = 0.0f;
}

glTranslatef(0.0f,0.0f,-5.0f); //move back 5 units
glRotatef(angle,0.0f,0.0f,1.0f); //rotate along z-axis

glColor3f(1.0,0.0f,0.0f); //set color to red
glBegin(GL_TRIANGLES); //draw the triangle
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(1.0f,0.0f,0.0f);
glEnd();

SwapBuffers(g_HDC); //bring back buffer to foreground

TranslateMessage(&msg);
DispatchMessage(&msg);

}

}


return msg.wParam;;
}

Blizzarddog
01-20-2003, 10:11 AM
I was talking about the text game you were gonna send me in the email.

RoD
01-20-2003, 10:11 AM
i was going to send it to trav he asked what was involved in it, but ya thats the really old version.

Blizzarddog
01-20-2003, 10:13 AM
my dev c++ has an error in it.. it always gets a error in the resource file when i try to do a project... can i do that just by using a regular C++ file?

RoD
01-20-2003, 10:16 AM
it should compile fine, make sure you have those three opengl libraries installed on your computer. If not you can get them at www.opengl.org

Travis Dane
01-20-2003, 10:16 AM
Originally posted by RoD
Nah, a dos engine is fairly simple. It needs a coord system, etc. Gimme your email and i'll send you mine if you want.

Nah, not really required, i'm going to write my own OpenGL
Engine soon and i know what's involved.

Blizzarddog
01-20-2003, 10:19 AM
I got these errors:

157 c:/mydocu~1/c__~1/test.cpp
(Each undeclared identifier is reported only
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
206 c:/mydocu~1/c__~1/test.cpp
`done' undeclared (first use this function)
206 c:/mydocu~1/c__~1/test.cpp
`done' undeclared (first use this function)

*EDIT*
I used PHP tags so its easier to read

Travis Dane
01-20-2003, 10:26 AM
Originally posted by Blizzarddog
I got these errors:

157 c:/mydocu~1/c__~1/test.cpp
(Each undeclared identifier is reported only
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
158 c:/mydocu~1/c__~1/test.cpp
`MSGmsg' undeclared (first use this function)
206 c:/mydocu~1/c__~1/test.cpp
`done' undeclared (first use this function)
206 c:/mydocu~1/c__~1/test.cpp
`done' undeclared (first use this function)

*EDIT*
I used PHP tags so its easier to read

Runs spotless on my compiler.

Blizzarddog
01-20-2003, 10:29 AM
Well, thats in a console app, otherwise, theres an error inthe resource file

Travis Dane
01-20-2003, 10:32 AM
Hoo, wait up, what are you trying to compile? Post code plz.

Blizzarddog
01-20-2003, 10:34 AM
that thing that RoD posted

Travis Dane
01-20-2003, 10:35 AM
/* Steven Billington
*/

/* Here we set the libraries to be used in the program, and
trim some of the excess off of windows
*/

#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glaux.lib")


/* Include all needed headers for the project. Windows brings in
everything needed for the basic application, and the other three
bring in OpenGL related functions.
*/

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


/* These are our global variables. These are ok in this program,
but i wouldn't reccomend making a habit out of using global
variables.

angle: Holds current angle of rotating triangle
g_HDC: Global Device Context
*/

float angle = 0.0f;
HDC g_HDC;


/* Function: SetupPixelFormat

Purpose: This function gets the setup for the pixel format,
go figure right?
*/

void SetupPixelFormat(HDC hDC)
{
int nPixelFormat; /* Pixel format index*/

static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), //size of structure
1, //version, always set to one
PFD_DRAW_TO_WINDOW | //support window
PFD_SUPPORT_OPENGL | //support opengl
PFD_DOUBLEBUFFER, //support double buffering
PFD_TYPE_RGBA, //RGBA color mode
32, //32bit color mode
0,0,0,0,0,0, //ignore color bits, not used
0, //no alpha buffer
0, //ignore shift bit
0, //no accumulation buffer
0,0,0,0, //ignore accumulation buffers
16, //16 bit zbuffer size
0, //no stencil buffer
0, //no auxiliary buffer
PFD_MAIN_PLANE, //main drawing plane
0, //reserved
0,0,0 }; //layer masks ignored

/* Choose best matching pixel format, return index*/
nPixelFormat = ChoosePixelFormat(hDC,&pfd);

/* Set pixel format to device context*/
SetPixelFormat(hDC,nPixelFormat,&pfd);
}

/* Function: WndProc

Purpose: This is our Windows Procedure Event Handler
*/

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HGLRC hRC; //rendering context
static HDC hDC; //device context
char string[] = "Hello World!"; //display text
int width, height; //window width, height

switch(message)
{
case WM_CREATE: //window is being created

hDC = GetDC(hwnd); //get current windows device context
g_HDC = hDC;
SetupPixelFormat(hDC); //call your pixel format setup function

//create rendering context and make it current
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);

return 0;
break;

case WM_CLOSE: //window is closing

//deselect rendering context and delete it
wglMakeCurrent(hDC,NULL);
wglDeleteContext(hRC);

//send WM_QUIT to messagr queue
PostQuitMessage(0);

return 0;
break;

case WM_SIZE:

height = HIWORD(lParam); //get height and width
width = LOWORD(lParam);

if (height == 0) //don't want a divide by 0
{
height = 1;
}

//reset the viewport to new dimensions
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION); //set projection matrix
glLoadIdentity(); //reset proj matrix

//calculate aspect ratio of window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f);

glMatrixMode(GL_MODELVIEW); //set modelview matrix
glLoadIdentity(); //reset mdeolv matrix

return 0;
break;

default:
break;


}

return (DefWindowProc(hwnd,message,wParam,lParam));
}

/* Function: WinMain

Purpose: Do i need to state this? Ok, its the main function.
*/

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX windowClass; //window class
HWND hwnd; //window handle
MSG msg; //message
bool done; //flag saying when app is complete

/* Fill out the window class structure*/
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "MyClass";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

/* Register window class*/
if (!RegisterClassEx(&windowClass))
{
return 0;
}

/* Class registerd, so now create window*/
hwnd = CreateWindowEx(NULL, //extended style
"MyClass", //class name
"A Real OGL Win App", //app name
WS_OVERLAPPEDWINDOW | //window style
WS_VISIBLE |
WS_SYSMENU |
WS_CLIPCHILDREN |
WS_CLIPSIBLINGS,
100,100, //x/y coords
400,400, //width,height
NULL, //handle to parent
NULL, //handle to menu
hInstance, //application instance
NULL); //no extra parameter's

/* Check if window creation failed*/
if (!hwnd)
{
return 0;
}

ShowWindow(hwnd,SW_SHOW); //displays window
UpdateWindow(hwnd); //update window

done = false; //inititalize condition variable

//main message loop
while(!done)
{
PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);

if (msg.message == WM_QUIT)
{
done = true;
}

else
{
//do rendering here
//clear screen and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); //reset modelview matrix

angle = angle + 0.1f; //increase rotation angle counter

if (angle >= 360.0f) //reset angle counter
{
angle = 0.0f;
}

glTranslatef(0.0f,0.0f,-5.0f); //move back 5 units
glRotatef(angle,0.0f,0.0f,1.0f); //rotate along z-axis

glColor3f(1.0,0.0f,0.0f); //set color to red
glBegin(GL_TRIANGLES); //draw the triangle
glVertex3f(0.0f,1.0f,0.0f);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(1.0f,0.0f,0.0f);
glEnd();

SwapBuffers(g_HDC); //bring back buffer to foreground

TranslateMessage(&msg);
DispatchMessage(&msg);

}

}


return msg.wParam;;
}



^ This? What kind of project are you running it in then?

Blizzarddog
01-20-2003, 10:39 AM
In a dev C++ wiindows app

Blizzarddog
01-20-2003, 10:42 AM
And what the f is pragma?

Travis Dane
01-20-2003, 10:42 AM
Then i don't understand much of the errors, you have all the
headers and libs? Check it in the dir

Blizzarddog
01-20-2003, 10:46 AM
I copied it

Travis Dane
01-20-2003, 11:03 AM
#Pragma's are compiler directive's.
I'm not sure about if you can compile OpenGL programs under
DEV++. I suggest look at the DEV forums.

Blizzarddog
01-21-2003, 10:22 AM
I've done it before, Dev came with those type of programs

Travis Dane
01-21-2003, 10:53 AM
Do keep in mind that the program RoD posted is developed
for a specific compiler, probably the one he has, and might
not work with DEV, ask RoD his compiler

Blizzarddog
01-21-2003, 11:01 AM
Yea, okay.. are you on 24/7, travis?

Travis Dane
01-21-2003, 11:02 AM
Originally posted by Blizzarddog
are you on 24/7, travis?

Nearly:p

Blizzarddog
01-21-2003, 11:05 AM
LOL Whats your best program/game?

Travis Dane
01-21-2003, 11:08 AM
Originally posted by Blizzarddog
LOL Whats your best program/game?

Hm, well i haven't made any games\programs, only test things.
But i plan to do a nice 3D game using OpenGL soon....

Blizzarddog
01-21-2003, 11:11 AM
Oh... how much C++ do you know??

Travis Dane
01-21-2003, 11:16 AM
Originally posted by Blizzarddog
Oh... how much C++ do you know??

Quite some bit, but i haven't done much on the advanced
aspects simply because i don't need them yet. I'm focussing on
Game Programming wich, at the state i'm right now, doesn't
require Polymorphism or Abstraction. I will get into it
as soon as it will be required.

Blizzarddog
01-21-2003, 11:18 AM
Uh-huh