Showing posts with label OpenGL. Show all posts
Showing posts with label OpenGL. Show all posts

Saturday, October 29, 2016

macOS Sierra: C++: OpenGL Utility Toolkit (GLUT) Example

Command:

$ cat BasicGlut.cpp


Result:

#include<GLUT/GLUT.h>
#include<iostream>

void render(void);
void keyboard(unsigned char c, int x, int y);
void mouse(int button, int state, int x, int y);


int main(int argc, char** argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("Simple GLUT Application");

glutDisplayFunc(render);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop();
return 0;
}

void keyboard(unsigned char c, int x, int y){
if (c == 27) { //esc
exit(0);
}
}


void mouse(int button, int state, int x, int y){
if (button == GLUT_RIGHT_BUTTON){
exit(0);
}
}

void render(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0); //RGB
glVertex2f(-0.5, -0.5); //glVertex234fid
glColor3f(0, 1, 0);
glVertex2f(0.5, 0.0);
glColor3f(0, 0, 1);
glVertex2f(0.0, 0.5);
glEnd();

glutSwapBuffers();
}


Command:

$ g++ BasicGlut.cpp -o BasicGlut -framework OpenGL -framework GLUT


Result:

BasicGlut.cpp:10:2: warning: 'glutInit' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutInit(&argc, argv);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:431:22: note: 'glutInit' has been explicitly marked deprecated here
extern void APIENTRY glutInit(int *argcp, char **argv) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:11:2: warning: 'glutInitDisplayMode' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:432:22: note: 'glutInitDisplayMode' has been explicitly marked deprecated here
extern void APIENTRY glutInitDisplayMode(unsigned int mode) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:12:2: warning: 'glutInitWindowPosition' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutInitWindowPosition(100, 100);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:436:22: note: 'glutInitWindowPosition' has been explicitly marked deprecated here
extern void APIENTRY glutInitWindowPosition(int x, int y) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:13:2: warning: 'glutInitWindowSize' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutInitWindowSize(640, 480);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:437:22: note: 'glutInitWindowSize' has been explicitly marked deprecated here
extern void APIENTRY glutInitWindowSize(int width, int height) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:14:2: warning: 'glutCreateWindow' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutCreateWindow("Simple GLUT Application");
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:441:21: note: 'glutCreateWindow' has been explicitly marked deprecated here
extern int APIENTRY glutCreateWindow(const char *title) OPENGL_DEPRECATED(10_0, 10_9);
                    ^
BasicGlut.cpp:16:2: warning: 'glutDisplayFunc' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutDisplayFunc(render);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:505:22: note: 'glutDisplayFunc' has been explicitly marked deprecated here
extern void APIENTRY glutDisplayFunc(void (*func)(void)) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:17:2: warning: 'glutKeyboardFunc' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutKeyboardFunc(keyboard);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:507:22: note: 'glutKeyboardFunc' has been explicitly marked deprecated here
extern void APIENTRY glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:18:2: warning: 'glutMouseFunc' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutMouseFunc(mouse);
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:508:22: note: 'glutMouseFunc' has been explicitly marked deprecated here
extern void APIENTRY glutMouseFunc(void (*func)(int button, int state, int x, int y)) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:19:2: warning: 'glutMainLoop' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutMainLoop();
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:438:22: note: 'glutMainLoop' has been explicitly marked deprecated here
extern void APIENTRY glutMainLoop(void) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
BasicGlut.cpp:48:2: warning: 'glutSwapBuffers' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
        glutSwapBuffers();
        ^
/System/Library/Frameworks/GLUT.framework/Headers/GLUT.h:448:22: note: 'glutSwapBuffers' has been explicitly marked deprecated here
extern void APIENTRY glutSwapBuffers(void) OPENGL_DEPRECATED(10_0, 10_9);
                     ^
10 warnings generated.


Command:

$ ./BasicGlut


Result:

OpenGL Utility Toolkit (GLUT) Example on macOS Sierra



Tuesday, July 26, 2016

Polyworld: OS X: Installation, Configuration, and Execution

Requre:

  • Install Qt
  • Install GSL

Command (Download source):

$ git clone https://github.com/polyworld/polyworld.git


Command (Configure):


$ cd ~/polyworld
$ ./configure -q ~/Qt/5.7/clang_64/bin/qmake

Result:

Operating System: darwin
CXX: clang++
Toolchain: llvm
QMake: /Users/username/Qt/5.7/clang_64/bin/qmake
Optimization: optimized
OpenMP Supported: False
Configure complete.


Command (Run):

$ ./Polyworld worldfiles/hello.wf

Result:

hello.wf