mingw里的GL
mingw里有opengl的头文件,不安装额外的库,请问可以写出图形界面吗?谁给段示例代码include/GL有以下头文件:
gl.h
glaux.h
glcorearb.h
glext.h
glu.h
glxext.h
wgl.h
wglext.h
2021-07-27 13:56
程序代码:
#define FREEGLUT_STATIC
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
void testb_display() //定义了所要绘制的图形实体
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);// 在RGB模式下,使用glClearColor清空之后画布的颜色
glClear(GL_COLOR_BUFFER_BIT);// 清空画布
glColor4f(1.0f, 0.0f, 0.0f, 0.1f);// 设置画笔颜色
// 画两个点
glBegin(GL_POLYGON);// GL_POLYGON绘制模式为多边形
glVertex2f(-0.5f, 0.0f);
glVertex2f(-0.5f, -0.5f);
glVertex2f(0.0f, -0.5f);
glVertex2f(0.0f, 0.0f);
glEnd();
glFlush();// 清空缓冲区,立即执行绘制命令
}
void testb_mouse_event(int button,int state,int x,int y){
printf("mouse_event running... button=%d, state=%d, x=%d, y=%d\n", button, state, x, y);
}
int main(int argc, char ** argv) //OpenGL的初始化
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);// 设置显示模式(RGB颜色|单缓冲,对应的还有索引颜色和双缓冲)
glutInitWindowPosition(200, 200);
glutInitWindowSize(600, 300);
glutCreateWindow("simple");
glutDisplayFunc(testb_display);
glutMouseFunc(testb_mouse_event);
glutMainLoop();
}
程序代码:C:\Windows\system32\cmd.exe /C C:/mingw64/bin/mingw32-make.exe -j 8 -e -f Makefile "----------Building project:[ testb - Debug ]----------" mingw32-make[1]: Entering directory 'D:/Dev/c/clspc/testb' C:/mingw64/bin/gcc.exe -o Debug/testb @"testb.txt" -L. -LD:\Dev\c\freeglut\lib\x64 -lfreeglut_static -lopengl32 -lwinmm -lgdi32 mingw32-make[1]: Leaving directory 'D:/Dev/c/clspc/testb' ====0 errors, 0 warnings====
[此贴子已经被作者于2021-7-29 22:27编辑过]
2021-07-29 22:16