AGL or CGL?

Acheron761
Unregistered
 
Post: #1
I'm new to OpenGL programming, so sorry if this seems simple;
I'm trying to write a Carbon GL app without having to use GLUT, and I've read on both AGL and CGL, but I can't figure out exactly what the relationship between them is; my documentation even lists AGL as 'unsupported' but I can't find any confirmation of this at Apple so I'm assuming my documentation is out of date by a few years (most of it seems fine, though). If anyone could offer some advice as to which set of APIs to use, I'd be very grateful.
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #2
AGL does work in Carbon; it's just not part of Carbon, which is why the documentation says it's unsupported in Carbon. What this means is you have to add the AGL Framework (or the AGL library if you're writing a CFM Carbon app) to have AGL work in Carbon.

CGL works only for fullscreen programs and works only in Mac OS X. If you want your code to run in OS 8 or 9, use AGL. If you're doing your OpenGL drawing into a window, use AGL. If you're writing a fullscreen OS X game, you can use either one, but CGL is lower-level than AGL so you'll get better performance with CGL.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #3
Most likely, since you're just learning, you should stay with GLUT. The only reason you shouldn't be using GLUT is if you need better windowing or input. Just because it is GLUT does not imply that it is for beginners only, just that it's a heck of a lot easier to get up and running with it. And it offers better performance than you might expect. In fact, I don't know that it's any slower than AGL or CGL in practice. Point is, if you're worried about speed, don't. Well written, logical code will move over into AGL or CGL very easily when more OS stuff is needed later. That said, here's my take:

-If you need better windows then AGL is it.

-If you don't need windows ( IOW, fullscreen all the time ) then CGL is it.

-AGL is written on top of CGL and is definitely supported.

-AGL and CGL are both buggy at times so steer clear unless you're absolutely convinced that's what you need. The performance difference between AGL and CGL is negligible in my experience.
Quote this message in a reply
Apprentice
Posts: 12
Joined: 2003.02
Post: #4
Quote:Originally posted by AnotherJake
Most likely, since you're just learning, you should stay with GLUT. The only reason you shouldn't be using GLUT is if you need better windowing or input.


I disagree. Look at the nehex or whatever. one of the simple ones shows you how to use agl. I fought and fought with glut but when i found that it made it really really simple to use nibs and whatnot. im a firm believer in starting with agl. though most of the tuts and stuff are written in so you will have to figure out only what code you can use and stuff but it doesnt take long to figure out and when you do its worth it.

laziness,impatience, and hubris
Quote this message in a reply
chainsawmcgraw
Unregistered
 
Post: #5
Quote:Originally posted by AnotherJake
-AGL and CGL are both buggy at times so steer clear unless you're absolutely convinced that's what you need. The performance difference between AGL and CGL is negligible in my experience. [/b]

Is there an alternative (aside from glut)?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #6
>Is there an alternative (aside from glut)?

Alternative to what? Your choices are GLUT, AGL, CGL, NSGL (Cocoa-only, I believe is a wrapper for CGL).
Quote this message in a reply
Member
Posts: 50
Joined: 2002.12
Post: #7
SDL?
Quote this message in a reply
chainsawmcgraw
Unregistered
 
Post: #8
I was just wondering if AGL and CGL are buggy and one should avoid them , what other options there would be for creating opengl contexts.
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #9
Quote:Originally posted by chainsawmcgraw
I was just wondering if AGL and CGL are buggy and one should avoid them , what other options there would be for creating opengl contexts.
Sorry, I didn't mean to mislead anyone. Steer clear by staying with GLUT unless it's totally necessary to use something else like AGL/CGL. There are definitely other alternatives like what others have pointed out but that isn't what he was asking. AGL and CGL are certainly just fine to use. The bugginess I was referring to is their tendency to not work as expected/advertised when switching into fullscreen mode. Specifically, I've found that capturing devices and expecting windows and icons to stay put does not work 100% of the time with dual monitors. I find it rather irritating but aside from that they're just fine, albeit more complicated to get up and running with.

EDIT: Oh yeah, and screen fading is hopelessly inconsistent. And then there's also the issue of a random changing of system gamma... Issues, issues, issues. AGL and CGL are going to offer the best performance but just be forwarned that you're likely to be spending plenty of time pulling your hair out. I don't think it's worth it for beginners.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #10
I've uploaded the source of a base structure I've been working on. There's just one AIFF file missing (the CoreAudio function needs a 44kHz, 16, stereo file to play all right), but you should be able to compile it with ProjectBuilder right away.

This a 1.2 Mb download. Here's the address: http://home.earthlink.net/~yexirocks/MyGameSource.dmg

It's a work-in-progress, and I've tried to steer away from any legacy APIs to be 100% OS X compatible. Let me know if this works for you. Any comments and suggestions would be greatly appreciated.
Quote this message in a reply
Post Reply