织梦CMS - 轻松建站从此开始!

罗索

OPENGL-ES 三角形

落鹤生 发布于 2012-03-14 10:22 点击:次 
#include PVRShell.h #include PVRShellAPI.h class CLesson2: public PVRShell { public : virtual bool InitApplication(); virtual bool InitView(); virtual bool ReleaseView(); virtual bool QuitApplication(); virtual bool RenderScene(); protected : privat
TAG:

#include "PVRShell.h" 
#include "PVRShellAPI.h" 
 
 
class CLesson2 : public PVRShell 

public
    virtual bool InitApplication(); 
    virtual bool InitView(); 
    virtual bool ReleaseView(); 
    virtual bool QuitApplication(); 
    virtual bool RenderScene(); 
protected
private
}; 
 
bool CLesson2::InitApplication() 

    return true

 
bool CLesson2::QuitApplication() 

    return true

GLuint ui32Vbo = 0
GLuint uiQuatVbo = 0
bool CLesson2::InitView() 

    float afVertices[] = {    -0.4f,-0.4f,0.0f, // Position 
    0.0f,0.0f,0.0f,0.0f, // Colour  
    0.4f,-0.4f,0.0f, 
    0.0f,1.0f,0.00f,1.0f, 
    0.0f,0.4f,0.0f, 
    1.0f,1.0f,1.00f,1.0f}; 
 
    glGenBuffers(1, &ui32Vbo); 
    glBindBuffer(GL_ARRAY_BUFFER,ui32Vbo); 
    unsigned int uiSize = 3 * (sizeof(float) * 7);  
    glBufferData(GL_ARRAY_BUFFER, uiSize, afVertices, GL_STATIC_DRAW); 
 
    glBindBuffer(GL_ARRAY_BUFFER,0); 
    return true

 
bool CLesson2::ReleaseView() 

    return true

 
PVRShell * NewDemo(void

    return new CLesson2(); 

 
bool CLesson2::RenderScene() 
{         
 
    glLoadIdentity(); 
    glClearColor(0.70.70.71.0); 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    glEnableClientState(GL_VERTEX_ARRAY); 
    glEnableClientState(GL_COLOR_ARRAY); 
    glBindBuffer(GL_ARRAY_BUFFER,ui32Vbo); 
    glVertexPointer(3, GL_FLOAT, 7 * sizeof(float), 0); 
    glColorPointer(4, GL_FLOAT, 3*sizeof(float), (GLvoid*)(4*sizeof(float))); 
    glDrawArrays(GL_TRIANGLES, 03); 
    glDisableClientState(GL_VERTEX_ARRAY); 
    glDisableClientState(GL_COLOR_ARRAY); 
 
    return true

(cr0_3)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201203/15818.html]
本文出处:百度博客 作者:cr0_3 原文
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容