Quake C and Open GL

Discuss anything not covered by any of the other categories.
Post Reply
daemonicky
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Quake C and Open GL

Post by daemonicky »

Is there any mod (engine...) where you can directly use opengl commands from Quake C? Is it even possible, Quake probably redraws scene after physics and quake c.
Downsider
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Post by Downsider »

Quake-C is serverside. There are functions like this for CSQC, though.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

QuakeC is just a game logic scripting language, nothing else. It's entirely limited to the behaviours that are built into the engine, and you cannot go outside of those 4 walls.

Yes, Quake has a very specific order it does things in. Roughly put it goes like this:
  1. Send commands to server (SP).
  2. Run a server frame.
  3. Send commands to server (MP).
  4. Read from the server.
  5. Update screen.
  6. Finish up stuff.
Physics, QC, etc all happen at step 2, whereas OpenGL stuff happens at step 5. Step 2 might even be happening on a different machine than the rest of the frame (e.g. in a multiplayer game).

Now think about it a little more. Even if you could make OpenGL function calls directly from QC (or CSQC), it is not desirable to do at all. Why not? Some reasons:
  • OpenGL versions currently range from 1.0 to 4.1; if you make a call for a later version than the player has, interesting things might happen - like Quake crashing.
  • The display is updated in a very specific order; you can't just throw in calls wherever you want.
  • Some engines don't use OpenGL at all. What happens if the player is running an engine that uses software or Direct3D?
  • QC is slow, rendering needs to be fast.
  • OpenGL isn't just about making function calls. It also needs to work with complex and interesting data types, abstract objects, function pointers, a long long long list of #defines, arrays and structs, some operating system stuff, etc. You need to extend QC to support all these too.
The player won't care if whatever it is you want to do is the most fantastic mindblowing thing in the universe. If you crash, misbehave or run slow the player will be annoyed at you and won't want to touch your mod with a 10-foot pole.

So back to the first point. QC is a game logic scripting language. It's not the be-all end-all do-everything solution-for-all-problems answer-to-all-requirements ("when you have a hammer everything you see looks like nails"). So use it for scripting game logic and leave enginey stuff to the engine.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

csqc has an extension where it is able to draw explicit polys where it wants, reminisent of glBegin/glVertex/glEnd, which typically uses whatever shader system the engine supports, but its not a complete opengl api. that's never going to happen. and definitely not for ssqc. there's a separation of responsibilities.
daemonicky
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Post by daemonicky »

Thank You all very much. :)

mh : Thanks, for disadvantages list. I did not wanted fancy stuff, just some wireframe boxes and lines to visually debug (I use particles and prints now).

Spike : This "opengl" in CSQC is done in step 5, isnt't it? Is it commands which are inserted into some list in step 2 which is executed at step 5? Thanks. :)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

the csqc poly rendering API inserts polys during step 5a(csqccode), which are drawn in step 5b(call to renderscene builtin). You can't configure fancy stuff, like line rendering, but you can generally reconfigure the rendering by using shaders.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

Many engines already support showing bounding boxes for exactly this reason. Look for the r_showbboxes cvar.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Post Reply