亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ogl_benchmark_sphere.cpp

?? 一個VC編寫的顯示地球小程序員,可隨鼠標移動轉動
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
	glEnable( GL_TEXTURE_2D );
	glEnable( GL_DEPTH_TEST );

    loadTexture();

	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective( 45.0f, 640.0f / 480.0f, 0.1f, 100.0f );

    //
    // Create the first sphere...
    //

    // Inform the user of the current mode
    cout << "Render Method: Immediate Mode" << endl;

    createSphereGeometry( 0.0f, 0.0f, 0.0f, 1.5f, g_nPrecision );
}

//-----------------------------------------------------------------------------
// Name: shutDown()
// Desc: 
//-----------------------------------------------------------------------------
void shutDown( void )	
{
    glDeleteTextures( 1, &g_textureID );
        
	if( g_hRC != NULL )
	{
		wglMakeCurrent( NULL, NULL );
		wglDeleteContext( g_hRC );
		g_hRC = NULL;							
	}

	if( g_hRC != NULL )
	{
		ReleaseDC( g_hWnd, g_hDC );
		g_hDC = NULL;
	}
}

//-----------------------------------------------------------------------------
// Name: renderSphere()
// Desc: Create a sphere centered at cy, cx, cz with radius r, and 
//       precision p. Based on a function Written by Paul Bourke. 
//       http://astronomy.swin.edu.au/~pbourke/opengl/sphere/
//-----------------------------------------------------------------------------
void renderSphere( float cx, float cy, float cz, float r, int p )
{
    const float PI     = 3.14159265358979f;
    const float TWOPI  = 6.28318530717958f;
    const float PIDIV2 = 1.57079632679489f;

    float theta1 = 0.0;
    float theta2 = 0.0;
    float theta3 = 0.0;

    float ex = 0.0f;
    float ey = 0.0f;
    float ez = 0.0f;

    float px = 0.0f;
    float py = 0.0f;
    float pz = 0.0f;

    // Disallow a negative number for radius.
    if( r < 0 )
        r = -r;

    // Disallow a negative number for precision.
    if( p < 0 )
        p = -p;

    // If the sphere is too small, just render a OpenGL point instead.
    if( p < 4 || r <= 0 ) 
    {
        glBegin( GL_POINTS );
        glVertex3f( cx, cy, cz );
        glEnd();
        return;
    }

    for( int i = 0; i < p/2; ++i )
    {
        theta1 = i * TWOPI / p - PIDIV2;
        theta2 = (i + 1) * TWOPI / p - PIDIV2;

        glBegin( GL_TRIANGLE_STRIP );
        {
            for( int j = 0; j <= p; ++j )
            {
                theta3 = j * TWOPI / p;

                ex = cosf(theta2) * cosf(theta3);
                ey = sinf(theta2);
                ez = cosf(theta2) * sinf(theta3);
                px = cx + r * ex;
                py = cy + r * ey;
                pz = cz + r * ez;

                glNormal3f( ex, ey, ez );
                glTexCoord2f( -(j/(float)p) , 2*(i+1)/(float)p );
                glVertex3f( px, py, pz );

                ex = cosf(theta1) * cosf(theta3);
                ey = sinf(theta1);
                ez = cosf(theta1) * sinf(theta3);
                px = cx + r * ex;
                py = cy + r * ey;
                pz = cz + r * ez;

                glNormal3f( ex, ey, ez );
                glTexCoord2f( -(j/(float)p), 2*i/(float)p );
                glVertex3f( px, py, pz );
            }
        }
        glEnd();
    }
}

//-----------------------------------------------------------------------------
// Name: createSphereDisplayList()
// Desc: Build Sphere Display List
//-----------------------------------------------------------------------------
void createSphereDisplayList()
{
    glDeleteLists( g_sphereDList, 0 );

    static bool firstPass = true;

    if( firstPass )
    {
        g_sphereDList = glGenLists(1);
        firstPass     = false;
    }

    if( g_sphereDList != 0 )
    {
        glNewList( g_sphereDList, GL_COMPILE );
        // Cache the calls needed to render a sphere
        renderSphere( 0.0f, 0.0f, 0.0f, 1.5f, g_nPrecision );
        glEndList();
    }
}

//-----------------------------------------------------------------------------
// Name: setVertData()
// Desc: Helper function for createSphereGeometry()
//-----------------------------------------------------------------------------
void setVertData( int index,
                 float tu, float tv, 
                 float nx, float ny, float nz, 
                 float vx, float vy, float vz )	
{
    (g_pSphereVertices+index)->tu = tu;
    (g_pSphereVertices+index)->tv = tv;
    (g_pSphereVertices+index)->nx = nx;
    (g_pSphereVertices+index)->ny = ny;
    (g_pSphereVertices+index)->nz = nz;
    (g_pSphereVertices+index)->vx = vx;
    (g_pSphereVertices+index)->vy = vy;
    (g_pSphereVertices+index)->vz = vz;
}

//-----------------------------------------------------------------------------
// Name: createSphereGeometry()
// Desc: Creates a sphere as an array of vertex data suitable to be fed into a 
//       OpenGL vertex array. The sphere will be centered at cy, cx, cz with 
//       radius r, and precision p. Based on a function Written by Paul Bourke. 
//       http://astronomy.swin.edu.au/~pbourke/opengl/sphere/
//-----------------------------------------------------------------------------
void createSphereGeometry( float cx, float cy, float cz, float r, int p )	
{
    const float PI = 3.14159265358979f;
    const float TWOPI = 6.28318530717958f;
    const float PIDIV2 = 1.57079632679489f;

    float theta1 = 0.0;
    float theta2 = 0.0;
    float theta3 = 0.0;

    float ex = 0.0f;
    float ey = 0.0f;
    float ez = 0.0f;

    float px = 0.0f;
    float py = 0.0f;
    float pz = 0.0f;

    float tu  = 0.0f;
    float tv  = 0.0f;

    //-------------------------------------------------------------------------
    // If sphere precision is set to 4, then 20 verts will be needed to 
    // hold the array of GL_TRIANGLE_STRIP(s) and so on...
    //
    // Example:
    //
    // total_verts = (p/2) * ((p+1)*2)
    // total_verts = (4/2) * (  5  *2)
    // total_verts =   2   *  10
    // total_verts =      20
    //-------------------------------------------------------------------------

    g_nNumSphereVertices = (p/2) * ((p+1)*2);

    if( g_pSphereVertices != NULL )
    {
        delete []g_pSphereVertices;
        g_pSphereVertices = NULL;
        g_pSphereVertices = new Vertex[g_nNumSphereVertices];
    }
    else
    {
        g_pSphereVertices = new Vertex[g_nNumSphereVertices];
    }

    // Disallow a negative number for radius.
    if( r < 0 )
        r = -r;

    // Disallow a negative number for precision.
    if( p < 4 ) 
        p = 4;

    int k = -1;

    for( int i = 0; i < p/2; ++i )
    {
        theta1 = i * TWOPI / p - PIDIV2;
        theta2 = (i + 1) * TWOPI / p - PIDIV2;

        for( int j = 0; j <= p; ++j )
        {
            theta3 = j * TWOPI / p;

            ex = cosf(theta2) * cosf(theta3);
            ey = sinf(theta2);
            ez = cosf(theta2) * sinf(theta3);
            px = cx + r * ex;
            py = cy + r * ey;
            pz = cz + r * ez;
            tu  = -(j/(float)p);
            tv  = 2*(i+1)/(float)p;

            ++k;
            setVertData( k, tu, tv, ex, ey, ez, px, py, pz );

            ex = cosf(theta1) * cosf(theta3);
            ey = sinf(theta1);
            ez = cosf(theta1) * sinf(theta3);
            px = cx + r * ex;
            py = cy + r * ey;
            pz = cz + r * ez;
            tu  = -(j/(float)p);
            tv  = 2*i/(float)p;

            ++k;
            setVertData( k, tu, tv, ex, ey, ez, px, py, pz );
        }
    }
}

//-----------------------------------------------------------------------------
// Name: doBenchmark()
// Desc: 
//-----------------------------------------------------------------------------
void doBenchmark()
{
    timeb start;
    timeb finish;
    float  fElapsed = 0.0f;
    int    nFrames  = 1000;

    ftime( &start );  // Get the time

    while( nFrames-- ) // Loop away
        render();

    ftime( &finish ); // Get the time again

    fElapsed  = (float)(finish.time - start.time);                // This is accurate to one second
    fElapsed += (float)((finish.millitm - start.millitm)/1000.0); // This gets it down to one ms

    cout << endl;
    cout << "-- Benchmark Report --" << endl;

    if( g_nCurrentMode == IMMEDIATE_MODE )
        cout << "Render Method:     Immediate Mode" << endl;
    if( g_nCurrentMode == DISPLAY_LIST )
        cout << "Render Method:     Display List" << endl;
    if( g_nCurrentMode == VERTEX_ARRAY )
        cout << "Render Method:     Vertex Array" << endl;

    cout << "Frames Rendered:   1000" << endl;
    cout << "Sphere Resolution: " << g_nPrecision << endl;
    cout << "Primitive Used:    GL_TRIANGLE_STRIP" << endl;
    cout << "Elapsed Time:      " << fElapsed << endl;
    cout << "Frames Per Second: " << 1000.0/fElapsed << endl;
    cout << endl;
}

//-----------------------------------------------------------------------------
// Name: render()
// Desc: 
//-----------------------------------------------------------------------------
void render( void )
{
	// Clear the screen and the depth buffer
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glTranslatef( 0.0f, 0.0f, -5.0f );
    glRotatef( -g_fSpinY, 1.0f, 0.0f, 0.0f );
    glRotatef( -g_fSpinX, 0.0f, 1.0f, 0.0f );

    if( g_bRenderInWireFrame == true )
        glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
    else
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

    //
    // Render test sphere...
    //

    glBindTexture( GL_TEXTURE_2D, g_textureID );

    if( g_nCurrentMode == IMMEDIATE_MODE )
    {
        // Render a textured sphere using immediate mode

        // To be fair to immediate mode, we won't force it incur the overhead 
        // of calling hundreds of math subroutines to generate a sphere each 
        // frame, instead, we'll use the same array that we would use for 
        // testing the vertex array, but we'll make the immediate mode calls 
        // ourselves. This is more typical of how a real app would use 
        // immediate mode calls.

        glBegin( GL_TRIANGLE_STRIP );
        {
            for( GLuint i = 0; i < g_nNumSphereVertices; ++i )
            {
                glNormal3f( (g_pSphereVertices+i)->nx,
                            (g_pSphereVertices+i)->ny,
                            (g_pSphereVertices+i)->nz );

                glTexCoord2f( (g_pSphereVertices+i)->tu,
                              (g_pSphereVertices+i)->tv );

                glVertex3f( (g_pSphereVertices+i)->vx,
                            (g_pSphereVertices+i)->vy,
                            (g_pSphereVertices+i)->vz );
            }
        }
        glEnd();
    }

    if( g_nCurrentMode == DISPLAY_LIST )
    {
        // Render a textured sphere as a display list
        glCallList( g_sphereDList );
    }

    if( g_nCurrentMode == VERTEX_ARRAY )
    {
        // Render a textured sphere using a vertex array
        glInterleavedArrays( GL_T2F_N3F_V3F, 0, g_pSphereVertices );
        glDrawArrays( GL_TRIANGLE_STRIP, 0, g_nNumSphereVertices );
    }

	SwapBuffers( g_hDC );
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品2024| 国产欧美日韩卡一| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 色婷婷亚洲综合| 日韩精品一区二区三区中文不卡| 亚洲欧洲成人自拍| 国产乱子轮精品视频| 欧美视频完全免费看| 国产清纯在线一区二区www| 亚洲第一福利一区| 99久久久无码国产精品| 337p日本欧洲亚洲大胆精品 | 成人欧美一区二区三区白人| 免费成人在线影院| 欧美无砖砖区免费| 中文字幕乱码亚洲精品一区| 蜜桃视频第一区免费观看| 91免费观看视频| 欧美国产97人人爽人人喊| 日韩高清电影一区| 一本色道久久综合狠狠躁的推荐| 久久久久高清精品| 久久国内精品视频| 91精品综合久久久久久| 亚洲妇女屁股眼交7| 91亚洲国产成人精品一区二区三| 国产欧美精品一区二区色综合| 日产欧产美韩系列久久99| 欧美视频在线一区二区三区| 亚洲黄色小视频| 99视频精品全部免费在线| 国产人妖乱国产精品人妖| 国产精品影视在线观看| 日韩欧美视频一区| 美国十次综合导航| 日韩情涩欧美日韩视频| 久久精品国产免费| 日韩欧美中文字幕精品| 美女在线观看视频一区二区| 91精品国产欧美一区二区18| 欧美bbbbb| 日韩精品在线网站| 国产资源在线一区| 久久久久国产精品麻豆ai换脸| 精品一区二区三区久久| 久久精品一区二区三区不卡| 国产精品99久久久久| 中文字幕精品三区| 日本久久一区二区三区| 亚洲自拍都市欧美小说| 制服丝袜国产精品| 精品一区二区在线看| 国产视频一区在线播放| 99精品久久久久久| 亚洲五码中文字幕| 日韩一区二区三区精品视频| 久久99国产精品久久99果冻传媒| 久久众筹精品私拍模特| 成人av资源在线| 国产精品99久久久久久似苏梦涵| 国产色婷婷亚洲99精品小说| 99riav久久精品riav| 亚洲电影视频在线| 2023国产精品| 91猫先生在线| 日本aⅴ免费视频一区二区三区| 精品国产免费一区二区三区香蕉| 成人小视频免费在线观看| 一区二区日韩av| 久久综合一区二区| 一本一道综合狠狠老| 蜜桃视频在线观看一区二区| 中国色在线观看另类| 欧美日韩一区二区三区不卡| 国产专区欧美精品| 亚洲欧洲综合另类在线| 欧美精品成人一区二区三区四区| 国产资源在线一区| 一区二区成人在线| 久久精品亚洲精品国产欧美| 欧美三级韩国三级日本一级| 国产成人精品免费网站| 亚洲尤物视频在线| 国产欧美日韩另类视频免费观看| 欧美在线观看一二区| 国产精品99精品久久免费| 亚洲国产成人精品视频| 国产婷婷色一区二区三区在线| 欧美日本在线观看| 成人av在线影院| 久久国产视频网| 亚洲chinese男男1069| 中文字幕二三区不卡| 欧美岛国在线观看| 欧美日韩精品一区二区三区| 99精品视频在线观看| 国产在线播精品第三| 日韩电影免费一区| 一区二区高清在线| 最新成人av在线| 国产精品污网站| 久久人人97超碰com| 欧美一区二区久久| 欧美精品自拍偷拍| 在线观看日韩电影| 色婷婷亚洲婷婷| 99精品国产一区二区三区不卡| 国产精品一线二线三线| 精品一区二区三区欧美| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲福中文字幕伊人影院| 一区二区三区资源| 亚洲女同一区二区| 亚洲欧美视频一区| 亚洲男同性恋视频| 亚洲乱码日产精品bd| 亚洲欧美一区二区不卡| 日韩理论电影院| 亚洲女同一区二区| 亚洲精品va在线观看| 一级特黄大欧美久久久| 亚洲卡通动漫在线| 亚洲国产一区在线观看| 亚洲一二三区在线观看| 亚洲va欧美va人人爽午夜| 婷婷成人综合网| 日本欧美一区二区| 精品系列免费在线观看| 国产精品18久久久久久久久久久久| 九九在线精品视频| 国产乱码字幕精品高清av| 国产乱码一区二区三区| 成人黄色777网| 日本韩国视频一区二区| 国产日韩av一区二区| 国产精品久久久一区麻豆最新章节| 欧美国产欧美亚州国产日韩mv天天看完整| 久久久99精品久久| 亚洲欧美在线视频观看| 亚洲在线成人精品| 蜜桃免费网站一区二区三区| 国产精品99久| 91性感美女视频| 7777女厕盗摄久久久| 精品福利在线导航| 日本一区二区三区dvd视频在线| 最新不卡av在线| 亚洲国产成人高清精品| 麻豆成人久久精品二区三区红| 国产高清亚洲一区| 91免费在线视频观看| 日韩欧美一二三区| **性色生活片久久毛片| 日韩综合小视频| 国产成人福利片| 欧美亚洲国产一卡| 精品国一区二区三区| 亚洲欧洲综合另类| 久久国产三级精品| 色综合视频一区二区三区高清| 日韩一二三四区| 中文字幕综合网| 美女在线视频一区| 91美女片黄在线观看91美女| 欧美一区二区三区视频免费| 国产精品欧美久久久久一区二区| 亚洲综合一区二区三区| 精品一区精品二区高清| 欧美优质美女网站| 中文字幕免费在线观看视频一区| 日韩成人一级大片| 91麻豆自制传媒国产之光| 3d成人h动漫网站入口| 亚洲丝袜另类动漫二区| 狠狠色狠狠色合久久伊人| 欧洲精品中文字幕| 国产精品伦理一区二区| 久久国产精品第一页| 欧美影院午夜播放| 亚洲视频在线一区| 国产91露脸合集magnet| 欧美一区二区三区四区高清| 亚洲女性喷水在线观看一区| 欧美在线影院一区二区| 国产精品免费丝袜| 国产毛片精品国产一区二区三区| 7777精品伊人久久久大香线蕉的| 亚洲欧美国产高清| av一区二区三区在线| 久久新电视剧免费观看| 日本不卡一二三| 欧美美女网站色| 亚洲成人av福利| 欧美视频中文一区二区三区在线观看| 中文字幕欧美一区| 99久久婷婷国产综合精品| 国产日韩欧美亚洲| 国产成人av影院| 久久久久久久久蜜桃| 国产乱人伦偷精品视频免下载|