zoukankan      html  css  js  c++  java
  • 放射线

    代码如下:

    #include <windows.h>
    //#include <GLUT/glut.h>
    #include <GL/glut.h>
    #include <math.h>
    #include <iostream>
    using namespace std;
    
    #define GL_PI 3.1415f
    
    void RenderScene()
    {
        GLfloat sizes[2];
        GLfloat step;
        GLfloat curSize;
    
        glClear(GL_COLOR_BUFFER_BIT);
    
        glGetFloatv(GL_POINT_SIZE_RANGE,sizes);
        glGetFloatv(GL_POINT_SIZE_GRANULARITY,&step);
    
        curSize = sizes[0];
    
        GLfloat x,y,angle;
        glBegin(GL_LINES);
        for(angle = 0.0f;angle <= GL_PI;angle += 0.1f)
        {
            x = 50.0f*sin(angle);
            y = 50.0f*cos(angle);
            glVertex2f(x,y);
    
            x = 50.0f*sin(angle+GL_PI);
            y = 50.0f*cos(angle+GL_PI);
            glVertex2f(x,y);
        }
        glEnd();
        glFlush();
    }
    
    void ChangeSize(GLsizei w,GLsizei h)
    {
        if(h==0)
            h = 1;
    
        GLfloat aspectRatio = (GLfloat)w/(GLfloat)h;
    
        glViewport(0,0,w,h);
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
    
        if(w<=h)
            glOrtho(-100,100,-100/aspectRatio,100/aspectRatio,1.0,-1.0);
        else
            glOrtho(-100*aspectRatio,100*aspectRatio,-100,100,1.0,-1.0);
    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    
    }
    
    void SetupRC()
    {
        glClearColor(0.0f,0.0f,0.0f,1.0f);
        glColor3f(1.0f,0.0f,0.0f);
    }
    
    
    int main(int argc, char *argv[])
    {
       glutInit(&argc,argv);
       glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
       glutInitWindowSize(800,600);
       glutCreateWindow("Simple");
    
       glutDisplayFunc(RenderScene);
       glutReshapeFunc(ChangeSize);
    
       SetupRC();
       glutMainLoop();
       return 0;
    }
    态度决定高度,细节决定成败,
  • 相关阅读:
    Syntactic_sugar
    processor, memory, I/O
    he time that it takes to bring a block from disk into main memory
    How MySQL Uses Indexes CREATE INDEX SELECT COUNT(*)
    mysqli_multi_query($link, $wsql)
    UTC ISO 8601
    but this usually doesn’t gain you anything.
    SET GLOBAL slow_query_log=1
    SET GLOBAL long_query_time=0
    a read only variable
  • 原文地址:https://www.cnblogs.com/lxk2010012997/p/4198155.html
Copyright © 2011-2022 走看看