在mfc中改变opengl纹理的亮度和对比度 [英] Change brightness and contrast of opengl texture in mfc

查看:256
本文介绍了在mfc中改变opengl纹理的亮度和对比度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个opengl纹理,现在我需要设置它的亮度和对比度。



我尝试过:



我试过gltexparameter但没有用

I created an opengl texture , now i need to chnage its brightness and contrast how to do it.

What I have tried:

I tried gltexparameter but no use

推荐答案

GLuint glTexture ; 

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glEnable( GL_TEXTURE_2D );
 //   glEnable(GL_BLEND);
 //   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 //   glEnable(GL_ALPHA_TEST);
 //   glAlphaFunc(GL_GREATER,0.01);
    //glEnable (GL_LIGHTING); //enable the lighting
    //glEnable (GL_LIGHT0); //enable LIGHT0, our Diffuse Light
    //glEnable (GL_LIGHT1); //enable LIGHT1, our Ambient Light
    //glShadeModel (GL_SMOOTH); //set the shader to smooth shader
    glEnable(GL_COLOR_MATERIAL);
    glGenTextures( 1, &glTexture );
    glBindTexture( GL_TEXTURE_2D, glTexture );
    glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );    // Select modulate to mix texture with color for shading
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );   // When texture area is small, bilinear filter the closest mipmap
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );        // When texture area is large, bilinear filter the original
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );       // The texture wraps over at the edges (repeat)
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
    glColor4f( float( ( float )g_nRedSlider / 10 ), float( ( float )g_nGreenSlider/ 10 ), float( ( float )g_nBlueSlider / 10 ), float( ( float )g_nAlphaSlider / 10 ));
    glTexImage2D( GL_TEXTURE_2D, 0, GL_INTENSITY, WIDTH, HEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_pbyImageData ); 
    glEnable( GL_TEXTURE_2D );
    glBindTexture( GL_TEXTURE_2D, glTexture );
    glBegin( GL_QUADS );
    glTexCoord2d( 0.0,0.0 ); 
    glVertex2f( -0.8f, -0.8f ); 
    glTexCoord2d( 1.0,0.0 );
    glVertex2f( 0.8f, -0.8f );
    glTexCoord2d( 1.0,1.0 );
    glVertex2f( 0.8f,  0.8f );
    glTexCoord2d( 0.0,1.0 );
    glVertex2f( -0.8f,  0.8f );
    glEnd();
    SwapBuffers( m_hDeviceContextDC );
    glDisable( GL_TEXTURE_2D );
    glDisable( GL_COLOR_MATERIAL );


这篇关于在mfc中改变opengl纹理的亮度和对比度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆