OpenGL environment is configured under Mac OS system
1. Prepare resources
CLToolsglewlibGLTools.
a
file can be downloaded in baidu network backup, link: https://pan.baidu.com/s/13gkpLWjbKSBNFnA-IGo23A password: g3b5
2. Create a project
3. Import the system Framework
Import OpenGL. Framework and Glut. Framework.
4. Add prepared resources
Drag the include file down into the project;
Drag the libgltools.a file into the Framework group under your project;
Add glew.h and gltools.h Paths to Header Search Paths.
5. Delete the unwanted files and create Main.cpp
Delete AppDelegate.swift, ViewController.swift, and if there are any main.m files, delete them as well.
create main.cpp file, do not check “Also create a header file”.
6. Compile
If you encounter a compilation error, import mode from the system library to <; > Change to plain file to introduce "".
test as follows:
#include "GLShaderManager.h"
#include "GLTools.h"
#include <GLUT/GLUT.h>
GLShaderManager shaderManager;
GLBatch triangleBatch;
void changeSize(int w,int h)
{
glViewport(0, 0, w, h);
}
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
GLfloat vRed[] = {1.0,1.00,0.0,0.5f};
shaderManager.UseStockShader(GLT_SHADER_IDENTITY,vRed);
triangleBatch.Draw();
glutSwapBuffers();
}
void setupRC()
{
glClearColor(0.3f, 1.0f, 1.0f, 1);
shaderManager.InitializeStockShaders();
GLfloat vVerts[] = {
0.0f,0.8f,0.0f,
0.5f,0.0f,0.0f,
-0.5f,0.0f,0.0f
};
triangleBatch.Begin(GL_TRIANGLES, 3);
triangleBatch.CopyVertexData3f(vVerts);
triangleBatch.End();
}
int main(int argc,char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH|GLUT_STENCIL);
glutInitWindowSize(600, 400);
glutCreateWindow("Triangle");
glutReshapeFunc(changeSize);
glutDisplayFunc(RenderScene);
GLenum status = glewInit();
if (GLEW_OK != status) {
printf("GLEW Error:%s\n",glewGetErrorString(status));
return 1;
}
setupRC();
glutMainLoop();
return 0;
}
Read More:
- Vc2010 configuring OpenGL environment
- CodeBlocks configuring OpenGL environment
- Big hole in using OpenGL on Mac OS
- Mac clion configuring opencv environment
- Configuring OpenGL environment with code blocks16.0 in Windows 10
- Configuring OpenGL development environment in win10 + vs2015 (including the method of installing 32-bit and 64 bit libraries)
- A series of problems in configuring OpenGL development environment in vs2015
- Vs2015 configuring OpenGL development environment: configuration of glfw library and glad Library
- Problems encountered in configuring OpenGL development environment in vs2015
- Vs2015 configuring OpenGL (glfw Library)
- Configuration of OpenGL development environment under Windows environment, win10 + vs2019 + glfw + glad
- Vs2019 nuget configuring OpenGL
- Configuring OpenGL in VS
- The solution of configuring OpenGL in vs2017
- Xcode configuring OpenGL
- DEVC + + configuring OpenGL
- Configuring OpenGL in Code:: blocks
- Configuring OpenGL in Visual Studio
- Configuring OpenGL with win 10 + CodeBlocks
- CodeBlocks configuring OpenGL