LoginSignup
0
0

More than 5 years have passed since last update.

MacでGLUT+OGL#2

Posted at

記述の動機
GLUT+OGLがMacではサクッと環境構築できることを知りました。
使わない手はないので、少しづつまとめていきます。

point.cpp
#include <GLUT/glut.h>

#define WIDTH 640
#define HEIGHT 480

void Point(int x,int y,float size){
    glPointSize(size);
    glBegin(GL_POINTS);
    glVertex2i(x , y);
    glEnd();
}
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor4f(0.0f,0.0f,1.0f,1.0f);
    Point(50,50,2.0);
    glColor4f(0.0f,1.0f,0.0f,1.0f);
    Point(400,400,5.0);
    glFlush();
}
void Init(){
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);
}
int main(int argc, char *argv[])
{
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA);
    glutCreateWindow("Draw Points");
    glutDisplayFunc(display);
    Init();
    glutMainLoop();
    return 0;
}
g++ -o point.out point.cpp -framework GLUT -framework OpenGL

点の描画。簡単ですね。
スクリーンショット 2015-06-10 23.43.41.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0