Janehiwang 2019-05-06 18:08 采纳率: 0%
浏览 420
已采纳

opencv窗口是透明的,调不了,留残影


#include <iostream>
#include <process.h>
#include "stdafx.h"
#include <GL/glew.h> 
#include <GL/glut.h> 

#pragma comment(lib, "glew32.lib")

using namespace std;

void lagrange()
{
    float p[10][2];
    p[0][0] = 5, p[0][1] = 31.2;
    p[1][0] = 7, p[1][1] = 43.7;
    p[2][0] = 13, p[2][1] = 59.1;
    p[3][0] = 16, p[3][1] = 72;
    p[4][0] = 20, p[4][1] = 94.5;
    p[5][0] = 25, p[5][1] = 122;
    p[6][0] = 27, p[6][1] = 129.2;
    p[7][0] = 34, p[7][1] = 153;
    p[8][0] = 52, p[8][1] = 183;
    p[9][0] = 60, p[9][1] = 197.8;
    //得到数据点

    int nmax = 10;
    int n = 4;

    float x, y;
    int i, j, t;
    float temp;

    glColor3f(0.0, 0.0, 1.0);
    for (i = 0; i <= (nmax - 1); i += (n - 1))
    {
        glBegin(GL_LINE_STRIP);
        for (x = p[i][0]; x <= p[i + n - 1][0]; x += 1.0)
        {
            y = 0.0;
            for (j = 0; j<n; j++)
            {
                temp = 1.0;
                for (t = 0; t<n; t++)
                {
                    if (t == j)
                        continue;
                    temp *= (x - p[i + t][0]) / (p[i + j][0] - p[i + t][0]);
                }
                y += temp*p[i + j][1];
            }
            glVertex2f(x/nmax, y/200);
        }
        glEnd();
    }
    glFlush();
}
//拉格朗日插值法&画图



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

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(600, 600);
    glutCreateWindow("The first OpenGL Application");
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glutDisplayFunc(&lagrange);
    glutMainLoop();
    return 0;
    //lagrange(p, 4, 10);

}

图片说明

如图,透明的,我咋调glclearcolor的透明度都这样

  • 写回答

2条回答 默认 最新

  • Janehiwang 2019-05-07 10:06
    关注

    解决啦!!!添加glclearcolor后面加glClear(GL_COLOR_BUFFER_BIT)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退