小编Zi0*_*ch0的帖子

OpenGL黑屏/没有绘制?

为什么这段代码会产生黑屏(没有画出来......)?

我正在创建一个Pong克隆但是如果没有让它工作,我就无法继续.

#include <GL/glut.h>

struct Rectangle {
    int x;
    int y;
    int width;
    int height;
};

struct Ball {
    int x;
    int y;
    int radius;
};

typedef struct Rectangle Rectangle;
typedef struct Ball Ball;

Rectangle rOne, rTwo;
Ball ball;

void display(void);
void reshape(int w, int h);
void drawRectangle(Rectangle *r);

int main(int argc, char* argv[]) {

    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
    glutInitWindowSize(800,600);
    glutCreateWindow("Pong");
    gluOrtho2D(0,0,800.0,600.0);

    rOne.x = 100;
    rOne.y = 100;
    rOne.width = 100;
    rOne.height = 50;   

    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();

    return 0;

}

void display(void) …
Run Code Online (Sandbox Code Playgroud)

c opengl glut

2
推荐指数
1
解决办法
2894
查看次数

标签 统计

c ×1

glut ×1

opengl ×1