6 Replies - 846 Views - Last Post: 05 May 2013 - 10:49 AM Rate Topic: -----

#1 Magn0733  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 57
  • Joined: 04-April 13

DirectX 11 Initialize

Posted 03 May 2013 - 12:28 PM

Hey guys.

I've been programming in directX for some days now, and things start to make sense to me now :)
But one things do seems to pass my mind.

The thing is when I prepare the Instantiate D3D etc. I call my InitD3D function in WinMain.
As far as i understod WinMain worked as the normal Main method? (Updating each frame?)
So i wonder do i intialize my D3D each frame and why call it in WinMain and not make a class and call it once with a constructor? :)

Hope you can anwser my question.

Thanks in adavance! :)

Is This A Good Question/Topic? 0
  • +

Replies To: DirectX 11 Initialize

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX 11 Initialize

Posted 03 May 2013 - 02:19 PM

WinMain() is the operating system entry point for your program, so the OS effectively only knows what is either directly or indirectly called within WinMain().

No you do not initialize D3D each frame, you initialize on startup and clean up on program shutdown. You should be seeing this in the SDK example that come with the DirectX distribution.
Was This Post Helpful? 0
  • +
  • -

#3 Magn0733  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 57
  • Joined: 04-April 13

Re: DirectX 11 Initialize

Posted 03 May 2013 - 03:07 PM

View PostButchDean, on 03 May 2013 - 02:19 PM, said:

WinMain() is the operating system entry point for your program, so the OS effectively only knows what is either directly or indirectly called within WinMain().

No you do not initialize D3D each frame, you initialize on startup and clean up on program shutdown. You should be seeing this in the SDK example that come with the DirectX distribution.


But WinMain is called each frame right?
So how is it that the Initialize function where i set up D3D is only called once?
:)
Sorry if i'm a bit slow on this but it seems a bit conffusing :)
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX 11 Initialize

Posted 03 May 2013 - 03:26 PM

No, WinMain() is not called each frame.
Was This Post Helpful? 0
  • +
  • -

#5 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,303
  • Joined: 22-October 08

Re: DirectX 11 Initialize

Posted 03 May 2013 - 05:08 PM

Hello,

WinMain is the applications entry point. Without this method, your compiler will chuck an Unresolved External Symbol error at you. As said, WinMain() is not called each frame. In your WinMain() method, you will have a 'while' loop that keeps the 'game' looping, hence, each frame, is when the while loop repeats.

In the 'while' loop, you call all the necessary functions that you need to call, such as BeginScene, EndScene(for your DirectX renderer), and such assortments as AI calls, Animation calls, GUI/HUD calls and even Physics calls.

I strongly suggest that you learn some more on C++, the WinApi and DirectX.

I've found some tutorials here on Dream.In.Code that may help you:

Dream.In.Code C++ Basics Tutorials
Introduction to the Windows API
Introduction to DirectX and C++
DirectX Tutorial Series

Hope it helps :)

Aaron1178
Was This Post Helpful? 1
  • +
  • -

#6 Magn0733  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 57
  • Joined: 04-April 13

Re: DirectX 11 Initialize

Posted 04 May 2013 - 04:14 AM

View Postaaron1178, on 03 May 2013 - 05:08 PM, said:

Hello,

WinMain is the applications entry point. Without this method, your compiler will chuck an Unresolved External Symbol error at you. As said, WinMain() is not called each frame. In your WinMain() method, you will have a 'while' loop that keeps the 'game' looping, hence, each frame, is when the while loop repeats.

In the 'while' loop, you call all the necessary functions that you need to call, such as BeginScene, EndScene(for your DirectX renderer), and such assortments as AI calls, Animation calls, GUI/HUD calls and even Physics calls.

I strongly suggest that you learn some more on C++, the WinApi and DirectX.

I've found some tutorials here on Dream.In.Code that may help you:

Dream.In.Code C++ Basics Tutorials
Introduction to the Windows API
Introduction to DirectX and C++
DirectX Tutorial Series

Hope it helps :)/>

Aaron1178

Ahh, thanks.
Don't think i need to study more c++ (of course you can never learn enough). But i don't seem to find myself questioning what thing does. Only the WinMain was a bit unclear for me cause the thing i read about it kinda made me belive that it was a every frame call. which didn't make much sense to me. And that was why i posted! :)
Anyways thanks it's much more clear now :)
Was This Post Helpful? 0
  • +
  • -

#7 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1010
  • View blog
  • Posts: 4,214
  • Joined: 14-February 08

Re: DirectX 11 Initialize

Posted 05 May 2013 - 10:49 AM

MSDN is awesome :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1