随笔 - 505  文章 - 1034  trackbacks - 0
<2012年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 894796
  • 排名 - 14

最新随笔

最新评论

阅读排行榜

评论排行榜

缘起:
为看这个做知识储备,因为OpenGL不熟悉
玩玩DirectShow--(2) NVIDIA SDK 9.5 GPU Video Effects

截图:

核心代码:

         渲染

void display()
{
    glClear(GL_COLOR_BUFFER_BIT 
| GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    camera.apply_inverse_transform();

    
object.apply_transform();
    glRotatef(
60.0f-1.0f1.0f0.0f );

    glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex.texture);
    glEnable(GL_TEXTURE_RECTANGLE_NV);

    quad.call_list();

    
    glPopMatrix();

    glutSwapBuffers();
}

         初始化
void init_opengl()
{
    
if (!glh_extension_supported("GL_EXT_texture_rectangle"&& 
        
!glh_extension_supported("GL_NV_texture_rectangle"))
    {
    cerr 
<< "Video card does not support texture rectangles" << endl;
        quitapp(
0);
    }

   
    glEnable(GL_DEPTH_TEST);


    array2
<vec3ub> img;

    tex.bind();  
// get a texture name and bind it
    read_png_rgb("nvlogo_rect.png", img);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 
1);
    glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 
0, GL_RGB, img.get_width(), img.get_height(), 0,
                 GL_RGB, GL_UNSIGNED_BYTE, 
& img(0,0)[0]);
                     

    

    
float aspect = img.get_width() / float(img.get_height());
    
// note texture coordinates use image dimensions, not [0,1]
    quad.new_list(GL_COMPILE);
    glPushMatrix();
    
if(aspect > 1)
        glScalef(
11/aspect, 1);
    
else
        glScalef(aspect, 
11);

    glBegin(GL_QUADS);
        glTexCoord2f(
00);
        glVertex3f(
-1-10);

        glTexCoord2f(
0, img.get_height());
        glVertex3f(
-1,  10);

        glTexCoord2f(img.get_width(), img.get_height());
        glVertex3f( 
1,  10);

        glTexCoord2f(img.get_width(), 
0);
        glVertex3f( 
1-10);
    glEnd();

    glPopMatrix();
    quad.end_list();
}

posted on 2008-12-24 03:11 七星重剑 阅读(1367) 评论(2)  编辑 收藏 引用 所属分类: Game Graphics

FeedBack:
# re: NVIDIA SDK 9.5 Simple Texture Rectangle 2008-12-24 21:02 xoyojank
flash在线视频画到纹理上你原意贴哪贴哪  回复  更多评论
  
# re: NVIDIA SDK 9.5 Simple Texture Rectangle 2008-12-25 00:00 七星重剑
@xoyojank
我整整把avi啥的画到纹理上  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理