Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

OpenGl and GLEW on Mac?

Hello I am trying to install GLEW on my Mac operating system for my computer graphics course. The instructions to get C++ working with OpenGL are below. I am having trouble installing GLEW. That link below does not seem to exist. What are some ways to have my computer graphics code with C++ work on my Mac. I am also including the sample code that's in the textbook. As of now I am not able to run that C++ code I'm guessing because I have not downloaded GLEW or/and have not configured all the settings to work with that.



User uploaded file

////////////////////////////////////////////////////

// square.cpp

//

// Stripped down OpenGL program that draws a square.

//

// Sumanta Guha.

////////////////////////////////////////////////////



#include <iostream>



#ifdef __APPLE__

# include <GLUT/glut.h>

#else

# include <GL/glut.h>

#endif



using namespace std;



// Drawing (display) routine.

void drawScene(void)

{

// Clear screen to background color.

glClear(GL_COLOR_BUFFER_BIT);



// Set foreground (or drawing) color.

glColor3f(0.0, 0.0, 0.0);



// Draw a polygon with specified vertices.

glBegin(GL_POLYGON);

glVertex3f(20.0, 20.0, 0.0);

glVertex3f(80.0, 20.0, 0.0);

glVertex3f(80.0, 80.0, 0.0);

glVertex3f(20.0, 80.0, 0.0);

glEnd();



// Flush created objects to the screen, i.e., force rendering.

glFlush();

}



// Initialization routine.

void setup(void)

{

// Set background (or clearing) color.

glClearColor(1.0, 1.0, 1.0, 0.0);

}



// OpenGL window reshape routine.

void resize(int w, int h)

{

// Set viewport size to be entire OpenGL window.

glViewport(0, 0, (GLsizei)w, (GLsizei)h);


// Set matrix mode to projection.

glMatrixMode(GL_PROJECTION);



// Clear current projection matrix to identity.

glLoadIdentity();



// Specify the orthographic (or perpendicular) projection,

// i.e., define the viewing box.

glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);



// Set matrix mode to modelview.

glMatrixMode(GL_MODELVIEW);



// Clear current modelview matrix to identity.

glLoadIdentity();

}



// Keyboard input processing routine.

void keyInput(unsigned char key, int x, int y)

{

switch(key)

{

// Press escape to exit.

case 27:

exit(0);

break;

default:

break;

}

}



// Main routine: defines window properties, creates window,

// registers callback routines and begins processing.

int main(int argc, char **argv)

{

// Initialize GLUT.

glutInit(&argc, argv);


// Set display mode as single-buffered and RGB color.

glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

// Set OpenGL window size.

glutInitWindowSize(500, 500);



// Set position of OpenGL window upper-left corner.

glutInitWindowPosition(100, 100);

// Create OpenGL window with title.

glutCreateWindow("square.cpp");

// Initialize.

setup();

// Register display routine.

glutDisplayFunc(drawScene);

// Register reshape routine.

glutReshapeFunc(resize);



// Register keyboard routine.

glutKeyboardFunc(keyInput);

// Begin processing.

glutMainLoop();



return 0;

}

MacBook Pro, Mac OS X (10.7.4)

Posted on Jan 18, 2013 4:53 PM

Reply
Question marked as Best reply

Posted on Jan 21, 2013 11:29 AM

The code you supplied doesn't use GLEW so the problems with your code have nothing to do with the fact you haven't installed GLEW. You haven't said what's wrong when you run the code so there's no way for anyone here to help you. Do you get errors when you compile the code or do you get errors when you try to run the program? Talking to your teacher about the problems you're having may help too as there aren't a lot of people on this forum who use GLUT and GLEW.


Regarding the installation of GLEW, when I did a Google search for GLEW, the first search result is the GLEW homepage and the second search result is installation instructions for GLEW. You may also want to look into Homebrew, which may make installation easier.


http://mxcl.github.com/homebrew

3 replies
Question marked as Best reply

Jan 21, 2013 11:29 AM in response to jojojona

The code you supplied doesn't use GLEW so the problems with your code have nothing to do with the fact you haven't installed GLEW. You haven't said what's wrong when you run the code so there's no way for anyone here to help you. Do you get errors when you compile the code or do you get errors when you try to run the program? Talking to your teacher about the problems you're having may help too as there aren't a lot of people on this forum who use GLUT and GLEW.


Regarding the installation of GLEW, when I did a Google search for GLEW, the first search result is the GLEW homepage and the second search result is installation instructions for GLEW. You may also want to look into Homebrew, which may make installation easier.


http://mxcl.github.com/homebrew

OpenGl and GLEW on Mac?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.