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

  • SEARCH
  • Home
  • 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 6556485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:57:01+00:00 2026-05-25T12:57:01+00:00

I’m a beginner in d3d development and I’m stuck on my first issue. I’ve

  • 0

I’m a beginner in d3d development and I’m stuck on my first issue. I’ve created a little program that draws a terrain with random heights in each vertex and a light that moves from left to right (plus basic keyboard management). Problem is the animated light is very skippy, input recognition fails pretty often and cpu usage is 50% constant (I have a dual core cpu). I thought that this issue was caused by incorrect throttling, but even after fixing the code i still have problems. My main loop is

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
    HWND wndHandle;
    int width = 640;
    int height = 480;

    wndHandle = InitWindow(hInstance, width, height);
    InitDirect3D(wndHandle, width, height);
    DInputInit(hInstance, wndHandle);
    SceneSetUp();
    MSG msg = {0};
    QueryPerformanceFrequency((LARGE_INTEGER *) &perf_cnt);
    time_count = perf_cnt / fixedtic;
    QueryPerformanceCounter((LARGE_INTEGER *) &next_time);
    while (WM_QUIT != msg.message)
    {
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            continue;
        }
        HandleInput();
        QueryPerformanceCounter((LARGE_INTEGER *) &cur_time);
        if (cur_time>next_time) {
            Render();
            next_time += time_count;
            if (next_time < cur_time)
                next_time = cur_time + time_count;
        }
    }
    ShutdownDirect3D();
    return (int)msg.wParam;
}

while the Render function is

void Render()
{
    QueryPerformanceCounter((LARGE_INTEGER *) &curtime);
    timespan = (curtime - last_time) * time_factor;
    last_time = curtime;
    model.pD3DDevice->ClearRenderTargetView(model.pRenderTargetView, D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f));
    lightpos.x = (float)cos(ang) * 256.0f;
    ang += timespan * 0.5;
    lpvar->SetFloatVector((float *) lightpos);
    D3DXMatrixLookAtLH(&V, &model.campos, new D3DXVECTOR3(0.0f, 0.0f, 0.0f), new D3DXVECTOR3(0.0f, 1.0f, 0.0f));
    D3DXMATRIX VP = V*P;
    camvar->SetFloatVector((float *)model.campos);
    ViewProjection->SetMatrix((float *) &VP);
    for(UINT p=0; p < techniqueDescription.Passes; ++p)
    {
        pTechnique->GetPassByIndex(p)->Apply(0);
        model.pD3DDevice->DrawIndexed(numIndices, 0, 0);
    }
    model.pSwapChain->Present(0, 0);
}

Any help is appreciated

  • 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-25T12:57:02+00:00Added an answer on May 25, 2026 at 12:57 pm

    Ok, I nailed it and I think I deserve a punch in my face. I was creating a reference device instead of a hardware device

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an XML file, the creators of it stuck in a bunch social

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.