code,starting,point,gamers,quest,design,game,
Quick Search for:  in language:    
code,starting,point,gamers,quest,design,game,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 481,463 lines
 Jobs: 1,069 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for C/ C++.
SQL 'LIKE' clause clone in C
By José Luis Gallego on 10/19


Determing File Version, System Language and Memory Status
By Ixac on 10/19


How to create custom messages
By Xeron on 10/18


DeathBrain
By DeathBrain on 10/18


Click here to see a screenshot of this code!A C++ Tutorial for Complete Beginners #2
By Jared Devall on 10/18

(Screen Shot)

Click here to see a screenshot of this code!_PAGE REPLACEMENT ALGORITHMS (FIFO)_
By ENRICO X on 10/18

(Screen Shot)

extract file from resource and write it to disk
By cpsim on 10/18


Click here to see a screenshot of this code!CurrencyConvert er 2002
By Xeron on 10/17

(Screen Shot)

File Saver/Opener
By Jek on 10/17


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

A 3D World (OpenGL walk through city) *FIXED*

Print
Email
 
winzip icon
Submitted on: 1/9/2001 7:23:42 PM
By: Dustin Davis 
Level: Advanced
User Rating: By 16 Users
Compatibility:C++ (general), Microsoft Visual C++

Users have accessed this code 25737 times.
 
(About the author)
 
     This code is the starting point of any 3d gamer's quest to design a 3d game. It will show you how to use openGL to load and display 3d models and show you basic keyboard input along with mouse input. Move around just like in UT or Half-Life. Use mouse look, strafe and take a nice walk around this very very small city. I got the textures working, i made a mistake...sorry. But since the file was almost 1mb with the textures as they were, i had to make em 256 color so they dont look all that pretty! <P> Make sre to extract the 3dworld folder to c:\windows\desktop otherwise the textures wont work! Sorry but this is the only way i could fix it.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzipto decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
1/9/2001 7:25:54 PM:Dustin Davis
Hey guys. If this doesnt load right, or 
it doesnt look right when it does load, 
let me know. I left out the material 
files due to size of the zip but the 
program seems to run with out them...go 
figure. Anyways, Please Please let me 
know if there are any problems.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/9/2001 11:08:19 PM:Mouse
i can load it allright.. but, the sky 
is black, and the building are all 
white.. i can see a sillouette of the 
buildings though... the mouse movements 
look good.. this is a neat example i 
hope you can give me some pointers on 
how to load the graphix correctly
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 1:23:40 AM:
wow nice picture. i dont know anything 
about c/c++ but can you make a .exe 
with the "material 
files" so i can 
see how this looks like..... and than 
post a link where i can download the 
.exe.
Thanks alot.
Man, I love 
the picture its like a real 3d game.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 1:52:56 AM:Mouse
yeah this is too cool!! i wish i could 
figu±.Ð4ut why the textures dont load 
though =(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 1:58:28 AM:ASERB
Hey, Dustin
plz. upload the .zip i 
want to see how it looks with the 
textures. thx. alot. post the .zip or 
.exe link soon. 
plz. thx.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 2:02:15 AM:ASERB
o and make a .exe for the project i 
also dont know about Visual C++. lol... 
thx. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 2:15:03 AM:Mouse
i figured it out (i think)
its looking 
for a LIB that doesnt exist located 
here:
D:\nt\private\windows\opengl\tool
kits\libaux
it fails with this 
type:
AUX_RGBImageRec
something to do 
with IMAGE.C ?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 2:27:07 AM:Andrew Heinlein (Mouse)
haha ok i gotta stop posting.. this is 
too cool though... The model you sent 
wont work cause it doesnt store the 
pictures internally.  Its looking for 
the pictures on my computer, and they 
dont exist.  So i made my own model and 
the textures are in BMP format.  But 
when i load the model i get a bunch of 
errors saying "invalid DIB format" and 
im using bmp's saved by MSPaint.  What 
format of picture did you use to make 
your model?  atleast im making 
advances.. now i actually get errors 
=)
so can you let me know what 
format the pictures are supposed to be 
in?
thanks =)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 2:31:58 AM:
 hey mouse make a .exe and link it to 
me. plz. i have visual c/c++ but dont 
know what the codes lines and errors 
mean..... lol plz. help me out...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 2:37:10 AM:Dustin Davis
Hey guys, i uploaded the new zip with 
the textures. Sorry but they are in 256 
colors due to zip size =( but you will 
get the idea. The sky is supposed to be 
black. I will update it tommorow with a 
sky and some fog if ya like. Let me 
know. Thanks for all your posts.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 3:27:11 AM:Mouse
YES!! THIS WORKED! woo whoo! thanks man 
this is too cool.. best code i have 
seen in a looong time!
imma have fun 
with this =)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 3:32:54 AM:Andrew Heinlein (Mouse)
ok if you want to see a working EXE go 
here:
http://www.theblackhand.net/mouse
/OpenGL.zip
Make sure you unzip this 
the correct way and retain the 
directory structure.
enjoy!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 3:35:38 AM:
 well no wo whoo! for me!!!!!!!!!!!!!
i need a .exe i dont know any visual 
c++ 
plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzz................
...... help.........woo whooooooooo
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 3:42:28 AM:ASERB
http://www.theblackhand.net/mouse
/Open
GL.zip
 got it....... Thsnk alot. 
about to download it.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 4:00:23 AM:ASERB
ok it works!  but its black and 
white?
i downloaded the fix version 
that is posted here, that doesn't 
work.
i also download the .exe form 
blackhand.net it works but no 
textures?
i tryed to put the images 
my the .exe and i also tryed to placed 
the default folder for the picures and 
still no texture.. any help? ?
o one 
more question: is there a way you can 
make this:
-
when i walk in to a 
building i dont go into it and get 
lost? Can you make me stop walking 
after i hit the wall.
anyway this is 
one of the best programs i have seen of 
PSC.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 12:43:07 PM:Mouse
there is something really wierd with 
how these type of models work.  When 
you download the ZIP make sure you 
extract the exe 
to:
c:\windows\desktop\
and the path 
of the BMPs and 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 12:48:59 PM:Andrew Heinlein (Mouse)
ops! scratch that!
ok to get the ZIP 
to work do this:
open it in 
WINZIP
extract everything 
to:
C:\windows\desktop\testaga\
that 
will get the models to work right.
(it 
has to be that exact path, or the 
program wont find the BMPs and it will 
be black and white)
im working on 
making this program load from its own 
resources and not use external 
resources so its a tad more 
portable.
this is a kick butt 
example though, thanks for sharing it 
with us =)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 4:29:57 PM:Ben Jacobs
Okay, I unziped it to 
c:\windows\desktop\testaga\ and it 
still just shows black and white.  Can 
someone tell me where to change the 
path to the images? 
Anyway, this 
code rocks, many lesser coders wouldn't 
have put this on an open source 
website. You rock!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 5:08:43 PM:Mouse
make sure the model/bitmaps are 
in:
C:\WINDOWS\Desktop\testaga\models
and the EXE is on the desktop.
it 
should work, i just tested it again
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 5:10:17 PM:Andrew Heinlein (Mouse)
i mean, make sure the EXE is 
in:
c:\windows\desktop\testaga\
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 5:15:25 PM:Andrew Heinlein (Mouse)
The reason why this is such a pain to 
set up is cause the .MS3d file is a 
project file from the MilkShape3d 
program.  It's not a real modle like 
from half life. This is like opening a 
MSVC++ .DSW file.  If the files are in 
the wrong place, you get errors. Im 
thinking of writing a program that will 
store the bitmaps in the .md3d 
internally.  Then rewrite this code to 
handle that.  I think that will make 
this a little more portable.
good 
luck!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 7:40:50 PM:Mouse
as a matter of fact, im doing that 
now.
so this will be the .MS3d model, 
but with the images stored within the 
.MS3d file, instead of just the paths.  
Maybe Dustin would like to work with me 
on making this into a newer model 
format?
either way, im going to go 
nuts with this.. i have always wanted 
to do this stuff =)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2001 10:08:54 PM:ASERB
ok i downloaded the .zip i extracted it 
to C:\windows\desktop\testaga\ the 
bitmaps are in 
C:\windows\desktop\testaga\models and 
the exe is in 
C:\windows\desktop\testaga and it still 
doesnt show the bitmaps?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/11/2001 2:55:10 PM:Dustin Davis
I dunno what this testtga stuff is, all 
u need ta do is extract the 3d world 
folder to your desktop not testtga!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/14/2001 2:39:12 PM:PsyVision
Wicked Demo. It works for me. Um, maybe 
some collision detection next :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/20/2001 6:10:21 PM:wolvenwraith
This is an EXCELLENT example, it worked 
for me just fine. If I understand this 
code well enough I could combine it 
with what I'm good at and make a pretty 
cool program. If I do this, you of 
course will get a lot of credit, I'm 
giving you an excellent vote.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/24/2001 8:58:24 PM:Richard Szalay
Alright, I'll be mailing this to the 
author anyway, but I'll post it here. 
To fix the problem with the textures 
loading, replace the function 
LoadGLTexture (in 3dSWorldMain.cpp) 
with this one (see below). It basically 
takes the filename off the path, and 
then re-allocates the path (ie. the 
project doesnt need to be in 
c:\windows\desktop\ or whatever).
I 
like though bud :) Nice 
work.
UPDATE: Ermm.. ok, I can't 
paste the function here, it makes my 
message too long.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/30/2001 6:02:24 PM:PyRoTeKNiC
Well done for putting such amazing code 
up for free! Thx! I'm having a little 
trouble downloading it, but from the 
shot it seems just like the HL engine. 
With any luck it might download before 
i fall asleep...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/2/2001 11:51:17 PM:Sean
I am on Windows 2000 and there is no 
C:\windows\desktop there is only 
C:\Documents and 
Settings\Administrator\Desktop so this 
sample will not work on my computer. :(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/3/2001 3:42:10 AM:RaX
Sean, it's an obvious awnser. make a 
windows\desktop directory :/
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/11/2001 2:06:43 PM:Miah
If you guys are having that "black and 
white" error, view the .msd or whatever 
file in there in text, you'll the see 
what directory this file looks for when 
trying to open those bitmaps! Hmmm, now 
i just need to make this program work 
faster, or maybe its just my 133Mhz 
computer!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/14/2001 2:11:42 PM:Mike Mc
help!I was experimenting and want2 
change the bitmaps but the program wont 
accept any different bitmaps besides 
the ones given.The new bitmap textures 
show up in MilkShape3d but when the 
program is compiled they are not there 
-just white!Whats going on?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/12/2001 11:36:19 AM:Mikael
Why did everyone write 
'C:\windows\desktop\testaga\' 
etc.?
It should 
be:
'C:\windows\desktop\3DWorld\'
then
 it works...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/12/2001 11:36:52 AM:Mikael Nordfelth
(Please answer via e-mail)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/21/2001 11:18:40 PM:Lord Tenchi
Ya know, if I didn't work next to 
Dustin every day, I'd have to think he 
was cool for putting this up...
DARN 
YOU DUSTIN!! Ya beat me to it!
heh heh
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/17/2001 2:32:50 PM:thamuz
Thanks much for making this awesome 
code. Im using it as a 'self-tutorial' 
in OpenGL etc... I like it alot. 5 
little planet thingies...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/3/2002 4:10:00 AM:Elie
Request: More info on file stuff.ms3d 
how to understand this binary 
file?
please reply at 
vipers58@hotmail.com
N.B:This file 
contains the bitmaps 
location.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/29/2002 10:39:02 AM:Mukade
EXELLENT!!
17 - MAN - KUWAIT
I WILL 
BE ABLE TO DO SO AFTER 2 YRS, AND TELL 
ME WHAT U EAT??   ;-/
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/7/2002 7:38:07 AM:Elie
I have added to the game's model a 
small animation (destruction of one of 
the buildings). I need to know how to 
activate it in the c++ code.
Please 
reply at vipers58@hotmail.com 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/9/2002 11:27:32 AM:RICH
Hey,
This is excellent!
Great work 
:)
I'd be perfect with collision 
detection though, and also if you can't 
turn upside down (You can only look 
straight up or down, not do a 360 
;))
So great work =D
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/10/2002 11:15:23 AM:Jefff
I love it. Cool!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/10/2002 9:18:57 PM:M DeKrey
I've figured out this code and made an 
editor in VB.  It works quite well, and 
makes it so that your files don't have 
to be in the proper directory as 
specified by the first comment.  
Unfortunately, I can't get it posted 
(I'm headed out for a week).  Thank you 
to Dustin for posting this!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/14/2002 10:05:09 AM:x_darkdude_x
cool dude can you make it so it stops a 
a wall or a building plz
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/21/2002 3:15:07 AM:
http://www.theblackhand.net/mouse
/Open
GL.zip doesnt work for me
does the 
file still exist?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.