Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quick Question on Carmack's OpenGL code

Started by Chrysaor Jul 12, 2004 at 1:41 AM 7 replies 1.4k views
Original Post
Chrysaor
Chrysaor
Hey, I was looking at carmack's quake 2 and quake 3 code, and i noticed that he puts a q infront of all opengl functions. for example: qglBegin(), qglEnd(), etc... I was wondering why he does this. I know that in qgl_win.c (in the win32 folder for the quake 2 source code), he gets the proc addresses for all those functions, so i know why they work, but i dont get why he does this. Any ideas?
Ainokea
Ainokea
q for quake?
______________With the flesh of a cow.
Luctus
Luctus
I believe the q-abstraction layer was put there so the engine could handle more than one kind of renderer (OpenGL, Glide, software..), just change the function pointers and you're set to use another renderer.
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
exa_einstein
exa_einstein
why he does it? maybe cross-platform purposes? (is there some qgl_unix.c?) or do-it-yourself dogma?
When I was younger, I used to solve problems with my AK-47. Times have changed. I must use something much more effective, killing, percise, pernicious, efficient, lethal and operative. C++ is my choice.
_the_phantom_
_the_phantom_
at the time Quake2 was written there was no garenteed OpenGL support on any system, so it needed an easy fall back to software path, using function pointers is the simplest way todo this and afaik the only way todo it with C.
Sunray
Sunray
Because he cares about compile times. Including windows.h/gl.h in every file leads to huge comple times. Q2 compiles on 10 seconds on my machine.
[size="1"]Perl - Made by Idiots, Java - Made for Idiots, C++ - Envied by Idiots | http://sunray.cplusplus.se
Promit
Promit
You'll also notice that implementations for all of those functions exist in the software renderer. (They might not be named exactly the same, but that's where the function pointers go.)
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.