Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 902421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:42:49+00:00 2026-05-15T15:42:49+00:00

I’m really not sure what to do anymore. I’v made my application use VBO’s

  • 0

I’m really not sure what to do anymore. I’v made my application use VBO’s and my cpu usage still goes into the 70’s and 80’s. My render proceedure works like this:

Set the camera transformation
if the shape has not been tesselated, tesselate it.
create it’s VBO
if it has a VBO, use it.

You will notice I have display lists too, I might use these if VBO is not supported. I went and found an OpenGL demo that renders a 32000 poly mesh at 60fps on my PC and uses 4% cpu. I’m rendering about 10,000 polys @ 60fps using vbos and its using 70-80%.

Here is my render proc:

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        POINT hh = controls.MainGlFrame.GetMousePos();
        POINTFLOAT S;
        S.x = static_cast<float>(hh.x);
        S.y = static_cast<float>(hh.y);
        POINTFLOAT t;
        t.x = 256;
        t.y = 256;
        POINT dimensions;
        dimensions.x = 512;
        dimensions.y = 512;
        glDeleteTextures(1,&texName);
        texName = functions.CreateGradient(col,t,S,512,512,true);

        itt = true;
    }
    HDC hdc;
    PAINTSTRUCT ps; 
    glEnable(GL_MULTISAMPLE_ARB);
    glEnable(GL_BLEND);

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    hdc = BeginPaint(controls.MainGlContext.mhWnd,&ps);

    //start OGL code
    glClearColor( 1.0f, 1.0f, 1.0f, 0.0f );
    if(!current.isdrawing)
    glClear( GL_COLOR_BUFFER_BIT );

    glPushMatrix();
    glTranslatef(controls.MainGlFrame.GetCameraX(),
    controls.MainGlFrame.GetCameraY(),0);
    //glTranslatef(current.ScalePoint.x,current.ScalePoint.y,0);


    glScalef(current.ScaleFactor,current.ScaleFactor,current.ScaleFactor);
    //glTranslatef(-current.ScalePoint.x,-current.ScalePoint.y,0);


    if(!current.isdrawing)
    {
        for(unsigned int currentlayer = 0; currentlayer < layer.size(); ++currentlayer)
        {
            PolygonTesselator.Init(); 
            for(unsigned int i = 0; i < layer[currentlayer].Shapes.size(); i++)
            {
                if(layer[currentlayer].Shapes[i].DisplayListInt == -999)
                {
                    gluTessNormal(PolygonTesselator.tobj, 0, 0, 1);
                    PolygonTesselator.Set_Winding_Rule(layer[currentlayer].Shapes[i].WindingRule); 
                    glEnable(GL_TEXTURE_2D);
                    glBindTexture(GL_TEXTURE_2D, texName);

                    layer[currentlayer].Shapes[i].DisplayListInt = glGenLists(1);
                    glNewList(layer[currentlayer].Shapes[i].DisplayListInt,GL_COMPILE);

                    PolygonTesselator.SetDimensions(layer[currentlayer].Shapes[i].Dimensions,layer[currentlayer].Shapes[i].minima);
                    PolygonTesselator.Begin_Polygon(); 
                    for(unsigned int c = 0; c < layer[currentlayer].Shapes[i].Contour.size(); ++c)
                    {
                        if(layer[currentlayer].Shapes[i].Color.a != 0)
                        {
                            PolygonTesselator.Begin_Contour();

                            for(unsigned int j = 0; j < layer[currentlayer].Shapes[i].Contour[c].DrawingPoints.size(); ++j)
                            {
                                gluTessVertex(PolygonTesselator.tobj,&layer[currentlayer].Shapes[i].Contour[c].DrawingPoints[j][0],
                                    &layer[currentlayer].Shapes[i].Contour[c].DrawingPoints[j][0]);
                            }

                            PolygonTesselator.End_Contour();
                        }
                    }
                    PolygonTesselator.End_Polygon();
                    glEndList();
                    PolygonTesselator.TransferVerticies(layer[currentlayer].Shapes[i].OutPoints);
                    glGenBuffersARB(1,&layer[currentlayer].Shapes[i].VBOInt);
                    glBindBufferARB(GL_ARRAY_BUFFER_ARB,layer[currentlayer].Shapes[i].VBOInt);
                    glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * layer[currentlayer].Shapes[i].OutPoints.size(),
                        &layer[currentlayer].Shapes[i].OutPoints[0], GL_STATIC_DRAW_ARB);

                    InvalidateRect(controls.MainGlFrame.framehWnd,NULL,false);
                }
                else //run vbo
                {
                    //glEnable(GL_TEXTURE_2D);
                    //glDisable(GL_TEXTURE_2D);
                    //glBindTexture(GL_TEXTURE_2D, texName);
                    glColor4f(layer[currentlayer].Shapes[i].Color.r,
                    layer[currentlayer].Shapes[i].Color.g,
                    layer[currentlayer].Shapes[i].Color.b,
                    layer[currentlayer].Shapes[i].Color.a);
                    //glColor4f(1,1,1,1);

                    glBindBufferARB(GL_ARRAY_BUFFER_ARB, layer[currentlayer].Shapes[i].VBOInt);     
                    //glCallList(layer[currentlayer].Shapes[i].DisplayListInt);
                    glEnableClientState(GL_VERTEX_ARRAY);
                    glVertexPointer(2, GL_FLOAT, 0, 0);
                    glDrawArrays(GL_TRIANGLES, 0, layer[currentlayer].Shapes[i].OutPoints.size() / 2);

                    glDisableClientState(GL_VERTEX_ARRAY);
                    glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
                }

                glDisable(GL_TEXTURE_2D);
                //Draw outlines
                if(layer[currentlayer].Shapes[i].Outline.OutlinePoints.size() > 4)
                {
                    glColor4f(layer[currentlayer].Shapes[i].Outline.OutlineColor.r
                        ,layer[currentlayer].Shapes[i].Outline.OutlineColor.g
                        ,layer[currentlayer].Shapes[i].Outline.OutlineColor.b
                        ,layer[currentlayer].Shapes[i].Outline.OutlineColor.a);
                }

            }
            PolygonTesselator.End();
        }
    }

    glPopMatrix();

    //end OGL code
    glFlush();
    SwapBuffers(hdc);

    glDisable(GL_MULTISAMPLE_ARB);
    EndPaint(controls.MainGlContext.mhWnd,&ps);

}

Why could I be getting such high cpu usage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:42:51+00:00Added an answer on May 15, 2026 at 3:42 pm

    Under what conditions is that first bit of code run? There’s a couple of suspicious-looking lines in there:

    glDeleteTextures(1,&texName);
    texName = functions.CreateGradient(col,t,S,512,512,true);
    

    If you’re deleting and recreating a texture every time you paint, that could get expensive. I couldn’t say how expensive the OpenGL parts would be — I’d expect uploading texture data to be reasonably efficient, even if deleting and creating texture names might be less so — but perhaps CreateGradient is inherently slow. Or maybe you’re accidentally hitting some kind of slow path for your graphics card. Or the function is creating all the mipmap levels. And so on.

    Aside from that, some random ideas:

    • What is the present interval? If the buffer swap is set to sync with the monitor, you may incur a delay because of that. (You can use the WGL_EXT_swap_control extension to tweak this value.)

    • If all of this is being run in response to a WM_PAINT, check that you aren’t getting unexpected extra WM_PAINTs for some reason.

    • Check that the polygon tesselator Init and End functions aren’t doing anything, since they’re being called every time, even if there’s no tesselating to be done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.