pouët.net

Go to bottom

this might sound like a stupid question

category: general [glöplog]
 
but, i have limited c/c++ experience and was wondering. where the main function is in the quake 2 source code. from what i have read about it all the code is there. but, since i don't know much about c++ and have used find to look through the source. i was wondering if someone here could help me out with the whole thing. everything besides game source code seems to have a main function. i also noticed there wasn't one in the blood 2 source code. i did look up on google programs not having a main function. but, it stills said it's impossible to have one without one and they had this cryptic example of how you could accomplish this. using define. but, i saw nothing like that in either one of the game sources. i'm not really interested in c/c++. but, i am interested in how you make a game and thought it was a good place to start with the quake 2 source code or blood 2 source code. because, i heard the unreal source code doesn't include the game engine. i've played the above 2 games. so, i thought i might be able to visualize some of the things it was doing. everytime i have asked questions on here i have gotten answers. so, still believe this is the place to go for that type of stuff. every other programmer i know in life is to damn lazy to tell me anything new. so, i go here where people are actually working on new things. anyway, the point to all this is that i would like to be able to understand how to make a game. i don't need help on the functions or anything. but, i would like to see in which order this shit works. because a bunch of random functions just don't call themselves or maybe they do?!. lol. also, every game programming book i've read so far. seems to just have a main function and it was called "main". so, when i see 2 game sources that don't even have it in them. i think it helped to confuse me.
added on the 2008-11-25 03:45:42 by hexen hexen
awsome topic
added on the 2008-11-25 04:06:26 by quisten quisten
i'm glad someone thought so. anyway, here is was i was talking about the other way to do a main function. which i found nothing even close to it in either one of the sources.

_____

#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
{
printf(" hello ");
}
added on the 2008-11-25 04:38:55 by hexen hexen
Woah that's awesome.
added on the 2008-11-25 08:45:18 by Baz Baz
you mean defining an alternative entry point?
added on the 2008-11-25 10:08:08 by Gargaj Gargaj
Lol! You don't start learning about game programming from reading the quake2 source. Especially when you don't know much about programming or don't care about it. Also what Gargaj said.
added on the 2008-11-25 10:34:17 by Optimus Optimus
Actually, not only is it not stupid, it isn't even a question. :)
added on the 2008-11-25 10:41:18 by gloom gloom
make sure you have the correct source (there are two different ones available), the entry point can be found in the file sys_win.c, line 590 (assuming you want the windows entry point). The file is located in the win32 folder.
added on the 2008-11-25 10:49:49 by wb wb
uhm ...
you dont seriously think you "might be able to visualize some of the things it was doing" just by having played those games and apart from that not beeing interested or experienced in c/c++, do you?

apart from that the define orgy above made me laugh :)



added on the 2008-11-25 12:16:48 by gopher gopher
thanks wb. you were right. but, neither the visual cpp ide or the windows search functions were finding it and i was asking because there are alot of files there and i'm not used to the vc++ ide where they have 5 projects going on in one place and where 2 or 3 projects there make one file and then are used with another project. i'm not strictly trying to learn game programming by looking at the source for quake 2. i've read some books on it and opengl and directx. but i searched all around for that and i was getting no results. i got a few results. but none of them were (win)main. i did have the correct files though. also, by renaming main i didn't realize it would change the location of the entrypoint in the executable. because it was however still "main" in the example. i figured the compiler would pick up on that like you didn't define it at all. but, now i know. ;x
added on the 2008-11-25 14:55:42 by hexen hexen
notice that the system assume all global variables and stuffs are inited before entering the main(). In C++, if you define a global object like that:

myclass myobject;

...its contructor will be executed before the main, and its destructor after the main return.... Which allows to do tricky things (other globals are not necessarily inited).It is bad to do that btw: this is the kind of reason why everything should be re-entrant in an executable (nothing global.). Anyway main() should be present for C/C++ applications. The main is usually called by a "startup.o" which does the inits and is more on assembly level.
added on the 2008-11-25 15:28:15 by krabob krabob

login

Go to top