opengl学习篇之 画直线 圆 和矩形

这篇博客展示了如何使用OpenGL进行图形绘制,包括画直线、矩形和圆。通过定义不同的函数,如drawlines()、drawRect()和drawCircular(),实现了鼠标操作来动态画线、画矩形和画圆的功能。程序使用了GLUT库进行窗口和事件处理,并且使用了双缓冲技术来提高显示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// opengl画直线程序框架.cpp : 定义应用程序的入口点。
//

//鼠标画线小程序
#include "stdafx.h"
#include "opengl画直线程序框架.h"
#include <glut.h>
#include <math.h>


#define N 1000       //maximum line numbers
#define Pi 3.14159
int ww, hh;     // for display window width and height
int line[N][4], k = 0;  //for line's endpoint coordinates and line number

void Myinit(void);
void Reshape(int w, int h);
void myMouse(int button, int state, int x, int y);
void myMotion(int x, int y);
void Display(void);
void  drawlines();
void drawRect();
void drawCircular();

int APIENTRY _tWinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR    lpCmdLine,
    int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    char *argv[] = { "hello ", " " };
    int argc = 2; // must/should match the number of strings in argv

    glutInit(&argc, argv);  //初始化GLUT库;
    glutInitWindowSize(800, 600);  //设置显示窗口大小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值