Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Apple OpenGL (AGL) Question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 blueshogun96   Crossbones+   -  Reputation: 1713

Like
0Likes
Like

Posted 12 August 2012 - 11:42 PM

I have a casual game I started developing for Windows and I would like to port the game to Mac OS X using AGL or CGL (a C based OpenGL implementation). I've never written an app for Mac OS X, but I have written a complete game for iOS. Since I personally don't like Objective-C, I prefer to avoid using it when possible and integrate C/C++ code for the aspects that don't require Cocoa, etc. So what I'd like to do is find some starting point to writing a basic but functional app for Mac OS X's app store.

I opened up a Cocoa based template project in XCode, but I'm not sure where to start. I tried searching Google for answers, but it was not my friend, and I'm quite confused as to where I should add my game loop, etc. Any ideas? Thanks.
Follow Shogun3D on the official website: http://shogun3d.net

Posted Image Posted Image Posted Image Posted Image

"Yo mama so fat, she can't be frustum culled." - yoshi_lol

"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.

Sponsor:

#2 SaTANO   Members   -  Reputation: 463

Like
1Likes
Like

Posted 13 August 2012 - 09:43 AM

ObjC approach is based on subclassing NSOpenGLView:
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_drawing/opengl_drawing.html#//apple_ref/doc/uid/TP40001987-CH404-SW8

If you don't like ObjC you should check this
http://ttjcrew.com/2009/06/27/beginning-opengl-on-os-x/
You should also check this one (correctly setting target)
http://www.autofasurer.net/wp/?p=106

#3 blueshogun96   Crossbones+   -  Reputation: 1713

Like
0Likes
Like

Posted 13 August 2012 - 11:49 PM

I couldn't get the first one to work (the code) and the other two links are things I've already gotten to work. Will Apple allow you to release an app built as a console application on their app store? If that's true, I'll stick with that.
Follow Shogun3D on the official website: http://shogun3d.net

Posted Image Posted Image Posted Image Posted Image

"Yo mama so fat, she can't be frustum culled." - yoshi_lol

"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.

#4 blueshogun96   Crossbones+   -  Reputation: 1713

Like
0Likes
Like

Posted 13 August 2012 - 11:59 PM

Sorry for the double post, but I can't get OpenGL to work to save my life, and drawRect never gets called! I've also searched google, but I can't find any clear results.

#import <Cocoa/Cocoa.h>
#include "OpenGL/OpenGL.h"
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

@interface AppDelegate : NSOpenGLView
{
    NSWindow *window;
}
- (void) drawFirstOpenGLFrame;
- (void) drawRect:(NSRect)dirtyRect;
@property (assign) NSWindow *window;
@end

#import <Cocoa/Cocoa.h>
#include "OpenGL/OpenGL.h"
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>

@interface AppDelegate : NSOpenGLView
{
    NSWindow *window;
}
- (void) drawFirstOpenGLFrame;
- (void) drawRect:(NSRect)dirtyRect;
@property (assign) NSWindow *window;
@end



#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window;

- (void) drawFirstOpenGLFrame
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f (0.25, 0.25, 0.0);
    glVertex3f (0.75, 0.25, 0.0);
    glVertex3f (0.75, 0.75, 0.0);
    glVertex3f (0.25, 0.75, 0.0);
    glEnd();
    glFlush();
}
- (void) drawRect:(NSRect)dirtyRect
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f (0.25, 0.25, 0.0);
    glVertex3f (0.75, 0.25, 0.0);
    glVertex3f (0.75, 0.75, 0.0);
    glVertex3f (0.25, 0.75, 0.0);
    glEnd();
    glFlush();
}
- (void) keyUp:(NSEvent *)theEvent
{
   
}
- (void) keyDown:(NSEvent *)theEvent{
   
}
- (void)dealloc
{
    [window release];
    [super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
//    [self drawFirstOpenGLFrame];
}
@end

I'm still lost, and it looks like Apple requires you to use Cocoa to release anything on their app store (I hate obj-C!).
Follow Shogun3D on the official website: http://shogun3d.net

Posted Image Posted Image Posted Image Posted Image

"Yo mama so fat, she can't be frustum culled." - yoshi_lol

"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.

#5 blueshogun96   Crossbones+   -  Reputation: 1713

Like
0Likes
Like

Posted 14 August 2012 - 09:13 PM

Okay, I figured it out. I had to set some options in my .xib file. Now my only problem is resizing. When I try to do so, it causes my window contents to become distorted.
Follow Shogun3D on the official website: http://shogun3d.net

Posted Image Posted Image Posted Image Posted Image

"Yo mama so fat, she can't be frustum culled." - yoshi_lol

"One objection to a “critique of C#” would be that you can’t talk about C# without talking about the whole “.Net experience”. However, one can approach the topic of Hitler without a complete discussion of Nationalist Socialism, so I feel justified." - Steve White.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS