GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


Disappearing GL scene by metimmee
Scene disappears after about 3 mins??
================================
void CMainWindow::DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 

///////////////////BEGIN PPI DRAW AND TEXTURE FILL ROUTINE
float vectorY1,vectorX1,originY,originX,vectorX,vectorY,radius,angle;
float DegreesPerSector = 360.0f/1024.0f;
float slice=1.0f/1024.0f;
float incslice=slice;
float PPIScanAngle = 360.0f;
float CircleStartAngle = 45.0f;
float CircleEndAngle = CircleStartAngle+PPIScanAngle;    
    
originX = 1.7f;//1.7f
originY = 0.0f;//0.0f
radius  = 4.30f;//4.3f    

vectorY1=originY;
vectorX1=originX;

//Take an array of 1024 x 1024 x 4 (checkImage) and fill it with noise and symbology prior to overwriting texture
NoisyTextureTest();

 
glTranslatef(0.0f,0.0f,-12.0f);
glPolygonMode( GL_BACK, GL_FILL);
glPolygonMode( GL_FRONT, GL_FILL);

glColor3f (1.0, 1.0, 1.0);


glEnable(GL_TEXTURE_2D);    
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,1024, 1024, GL_RGBA,GL_UNSIGNED_BYTE, checkImage);
glBindTexture(GL_TEXTURE_2D, texture[0]);     
glBegin(GL_TRIANGLES);
    for(float i=CircleStartAngle;i<=CircleEndAngle;i=i+DegreesPerSector)
    {
        //Draw a number of triangles to create a circle
        //Fill each triangle with a single row of pixels from the texture
        //

        angle=(float)(((double)i)/57.29577957795135);    
        vectorX=originX+(radius*(float)sin((double)angle));
        vectorY=originY+(radius*(float)cos((double)angle));        
        
        glTexCoord2f(0.0f,slice);//LHS
        glVertex2d(originX,originY);
        
        glTexCoord2f(1.0f,slice);//top right
        glVertex2d(vectorX1,vectorY1);

        glTexCoord2f(1.0f,slice);//bottom right
        glVertex2d(vectorX,vectorY);

        vectorY1=vectorY;
        vectorX1=vectorX;
        slice=slice+incslice;
    }
glEnd();
///////////////////////////////////////////////////////////////
/////////////END PPI DRAW AND TEXTURE FILL ROUTINE

glDisable(GL_TEXTURE_2D);


//BEGIN DRAW BACKGROUND BOX
glColor3f (0.1f, 0.1f, 0.1f);

     
glBegin(GL_QUADS);
    glVertex3f (-2.75f, -4.5f, -0.5f);
    glVertex3f (2.75f+radius, -4.5f, -0.5f);
    glVertex3f (2.75f+radius, 4.5f, -0.5f);
    glVertex3f (-2.75f, 4.5f, -0.5f);
glEnd();
//END DRAW BACKGROUND BOX

        
SwapBuffers(clientDC->m_hDC);



}