Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6011041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:12:09+00:00 2026-05-23T02:12:09+00:00

I have had some problems and questions in general regarding setting up an OpenGL

  • 0

I have had some problems and questions in general regarding setting up an OpenGL context and using it correctly on MacOSX using Snow Leopard. There are many different tutorials and code floating around the web that are all different ranging anywhere from 10.4 to 10.6. I intend to not use GLUT for my peripheral interactions and to handle my GL context.

To get to the question at hand, what i want to be able to do is be able to draw my scene as i resize the window. my reshape function isnt working correctly for some reason. I also don’t know whether i should be use the NSOpenGLView or the CustomView in the interface builder. From what I gather it seems that if you need more than the default rendering attributes that you can select in the NSOpenGLView Object then you should use a CustomView. In my case I have subclassed NSOpenGLView and connected my class to this Object in IBuilder.

At any rate, here is my code below. As stated below i really want to be able to go back and forth between ortho space(pixel space) and perspective(world space). I get a warning when trying to use gluOrtho2D()(implicit declaration of function). I am not sure how to get this to work correctly yet so any help is appreciated. Sorry for the output of my code – for some reason it isn’t wanting to format it correctly:

#import "MyOpenGLView.h"


@implementation MyOpenGLView

-(void)reshape {
  NSRect rectView = [self bounds];
  if( m_rectView.size.width != rectView.size.width || m_rectView.size.height != rectView.size.height ) {
    glViewport( 0, 0, rectView.size.width, rectView.size.height );
    m_rectView = rectView;
  }

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glMatrixMode(GL_MODELVIEW);
}

-(void) drawRect:(NSRect)bounds {
  glClearColor(0, 0, 0, 0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glColor3f(1.0, 0.85, 0.35);
  glBegin(GL_TRIANGLES);
  {
    glVertex3f(0.0, 0.6, 0.0);
    glVertex3f(-0.2, -0.3, 0.0);
    glVertex3f(0.2, -0.3, 0.0);
  }
  glEnd();
  glFlush();
}
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:12:10+00:00Added an answer on May 23, 2026 at 2:12 am

    You got a few things confused: The OpenGL context is not “started”, it is created. In the case of MacOS X a proper context is created by simply instanciating a NSOpenGLView.

    Something a lot of tutorials do, but is fundamentally flawed is placing the code setting the projection and viewport in the reshape handler. The far cleaner solution is setting all state when it’s needed in the display function. This brings us to the last misconception, namely that people think, some OpenGL states could be set only once.

    gluOrtho2D is not part of OpenGL, it’s part of GLU, a very old OpenGL helper library, of very little use for today’s modern OpenGL implementations. In the case of gluOrtho2D I never understood, why this function is there at all, because gluOrtho2D could be recreated by

    void mygluOrtho2D(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top)
    {
        glOrtho(left, right, bottom, top, -1., 1.);
    }
    

    You see it’s just two additonal parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already had some problems when I was using jQuery 1.4.2 (http://stackoverflow.com/questions/8158739/ie-memory-leak-and-eval-with-jquery/8176724#8176724) Now I've
I’ve got a problem and it seems some before me have had similar problems
I have a little problem. I had some JComboBox to a JDialog but they
In my limited experience, I've been on several projects that have had some sort
Here is a question that I have had for some time but never actually
What are some strategies that people have had success with for maintaining a change
I have had a hard disk failure which resulted in some files of a
I have a live database that had some data deleted from it and I
I would love to get some tips from other people that have had this
I'm sure that all of us have had to deal with telecommuters at some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.