C++项目代码运行之后的弹窗为什么是全黑色的

为什么这个代码运行之后的窗口时全黑色的呀,明明设置的是白色的,该怎么解决这个问题

img


```c++
#include <windows.h> 
#include <gl\gl.h> 
#include <gl\glu.h>
#include <gl\glut.h>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define MAX_NOTES 100
#define MAX_TITLE 50
#define MAX_TEXT 500

int current_note = -1; // 当前笔记的编号
int note_count = 0; // 笔记数量
char note_titles[MAX_NOTES][MAX_TITLE]; // 笔记标题
char note_texts[MAX_NOTES][MAX_TEXT]; // 笔记内容
char note_categories[MAX_NOTES][MAX_TITLE]; // 笔记分类

void draw_text(float x, float y, char *text) {
// 在指定位置绘制文本
glRasterPos2f(x, y);
for (int i = 0; i < strlen(text); i++) {
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, text[i]);
}
}

void draw_main_menu() {
// 绘制主界面菜单
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
draw_text(10.0f, 480.0f, "Note Management System");
draw_text(10.0f, 460.0f, "1. Open Note");
draw_text(10.0f, 440.0f, "2. New Note");
draw_text(10.0f, 420.0f, "3. Delete Note");
draw_text(10.0f, 400.0f, "4. Save Note");
draw_text(10.0f, 380.0f, "5. Edit Note");
draw_text(10.0f, 360.0f, "6. Categorize Note");
draw_text(10.0f, 340.0f, "7. Search Note");
draw_text(10.0f, 320.0f, "8. Help");
draw_text(10.0f, 300.0f, "9. Exit");
glutSwapBuffers();
}

void draw_note() {
// 绘制笔记界面
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
draw_text(10.0f, 480.0f, note_titles[current_note]);
draw_text(10.0f, 460.0f, note_texts[current_note]);
draw_text(400.0f, 10.0f, "Press 's' to save, 'q' to quit");
glutSwapBuffers();
}

void open_note_dialog() {
// 打开笔记对话框
char input[MAX_TITLE];
printf("Enter note title: ");
scanf("%s", input);
for (int i = 0; i < note_count; i++) {
if (strcmp(input, note_titles[i]) == 0) {
current_note = i;
draw_note();
return;
}
}
printf("Note not found.");
}

void new_note_dialog() {
// 新建笔记对话框
if (note_count >= MAX_NOTES) {
printf("Maximum note count reached.");
return;
}
char title[MAX_TITLE];
char text[MAX_TEXT];
char category[MAX_TITLE];
printf("Enter note title: ");
scanf("%s", title);
printf("Enter note text: ");
scanf(" %[^]", text);
printf("Enter note category: ");
scanf("%s", category);
strcpy(note_titles[note_count], title);
strcpy(note_texts[note_count], text);
strcpy(note_categories[note_count], category);
note_count++;
printf("Note created.");
}

void delete_note_dialog() {
// 删除笔记对话框
char input[MAX_TITLE];
printf("Enter note title to delete: ");
scanf("%s", input);
int found = 0;
for (int i = 0; i < note_count; i++) {
if (strcmp(input, note_titles[i]) == 0) {
for (int j = i; j < note_count - 1; j++) {
strcpy(note_titles[j], note_titles[j+1]);
strcpy(note_texts[j], note_texts[j+1]);
strcpy(note_categories[j], note_categories[j+1]);
}
note_count--;
printf("Note deleted.");
found = 1;
break;
}
}
if (!found) {
printf("Note not found.");
}
}

void save_note_dialog() {
// 保存笔记对话框
printf("Note saved.");
}

void edit_note_dialog() {
// 编辑笔记对话框
char input[MAX_TEXT];
printf("Enter new note text: ");
scanf(" %[^]", input);
strcpy(note_texts[current_note], input);
printf("Note edited.");
}

void categorize_note_dialog() {
// 分类笔记对话框
char input[MAX_TITLE];
printf("Enter note category: ");
scanf("%s", input);
strcpy(note_categories[current_note], input);
printf("Note categorized.");
}

void search_note_dialog() {
// 查询笔记对话框
char input[MAX_TITLE];
printf("Enter category to search for: ");
scanf("%s", input);
int found = 0;
for (int i = 0; i < note_count; i++) {
if (strcmp(input, note_categories[i]) == 0) {
printf("%s - %s", note_titles[i], note_texts[i]);
found = 1;
}
}
if (!found) {
printf("No notes found in that category.");
}
}

void help_dialog() {
// 帮助对话框
printf("Usage:");
printf("1. Open Note - opens an existing note");
printf("2. New Note - creates a new note");
printf("3. Delete Note - deletes an existing note");
printf("4. Save Note - saves the current note");
printf("5. Edit Note - edits the current note");
printf("6. Categorize Note - sets the category of the current note");
printf("7. Search Note - searches for notes in a category");
printf("8. Help - displays this help message");
printf("9. Exit - exits the program");
}

void keyboard_handler(unsigned char key, int x, int y) {
// 键盘事件处理
switch (key) {
case '1':
open_note_dialog();
draw_note();
break;
case '2':
new_note_dialog();
draw_main_menu();
break;
case '3':
delete_note_dialog();
draw_main_menu();
break;
case '4':
save_note_dialog();
break;
case '5':
edit_note_dialog();
draw_note();
break;
case '6':
categorize_note_dialog();
break;
case '7':
search_note_dialog();
draw_main_menu();
break;
case '8':
help_dialog();
break;
case '9':
exit(0);
break;
case 's':
save_note_dialog();
break;
case 'q':
current_note = -1;
draw_main_menu();
break;
}
}

int main(int argc, char **argv) {
// 初始化OpenGL
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
glutInitWindowSize(600, 500);
glutCreateWindow("Note Management System");

// 注册事件处理函数
glutDisplayFunc(draw_main_menu);
glutKeyboardFunc(keyboard_handler);

// 进入事件循环
glutMainLoop();

return 0;
}