473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programming Style with DirectX and Direct2D

4 New Member
I been trying to learn DirectX and Direct2D with C++. I'm proficient in C++, but I'm not sure how to do several things in working with these APIs.

First, I'm not sure how to program in a structured manner or style in context with DX and D2D. Is there reference material anyone would suggest?

For instance, in Direct2D in order to create a 'render target' you must initialize a 'factory'. This factory should retain its life through out the entire program. For a better understanding of this you can go here:
http://msdn.microsoft.com/en-us/library/dd535473(v=VS.85).aspx#step_2:_create_an_id2d1fact ory

I guess in asking for structured help, I'm also asking about encapsulation. I coded a class that would create a factory from the ID2D1Factory interface. I'm worried that what I'm doing is incorrect. Incorrect in that this code won't flow "properly" with anything else I program, or allow me to use D2D to its full extent.

basically my intentions are:
I don't want to make any objects of the interfaces (of DX or D2D) global, so I encapsulate it in a class. In doing that, isn't the object of that class still considered a global? Or how would I need to program so I can still use interface object effectively and keep the program efficient?

or do I have the wrong mindset in all of this? Thanks for any responses.
May 19 '10 #1
5 2945
RedSon
5,000 Recognized Expert Expert
Have you followed the DirectX tutorials that ship with the SDK? Have you considered something like XNA?
May 19 '10 #2
GoneFate
4 New Member
Yup, I followed those tutorials and some more I found online and in books. I have looked into XNA, which would require me to learn C#. I've actually heard good things about it, but I'd rather much stick with DirectX more or less for a learning experience.

Actually, in the DirectX tutorial for initializing Direct3D, they create a global of the Direct3D object with IDirect3D9::CreateDevice. I wanted to know if having the object as a global is "correct" or "good" practice. Isn't there some sort of conflict later on as you program more advanced things? If isn't good practice than what is?
May 19 '10 #3
RedSon
5,000 Recognized Expert Expert
I don't think a global direct 3d device object is a bad thing. In fact I think it is necessary. Since there is usually only one render target having more than one device object will not work. When you begin working on games you will see that many good coding practices are sacrificed to gain speed and performance. Globals are one way to increase this speed, but then it opens you up for more problems if you are not careful.
May 19 '10 #4
GoneFate
4 New Member
Okay, so this is a give and take situation. Performance vs Structure. I can understand that.

When you say problems you're referring to things like memory management? ie. if you create so many devices, buffers, render targets, etc, that inevitably have to be released at some point.
May 19 '10 #5
RedSon
5,000 Recognized Expert Expert
Yea memory would be the main concern.
May 19 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1506
by: Dave Kuhlman | last post by:
I'd like to learn more about this style of programming in Python. In this style or pattern, a high level class is given an instance (or a class from which it creates an instance), then uses that...
7
1518
by: KPB | last post by:
I have an O'Reilly Safari Online subscription. I decided to check out this book(C++ Templates) and am half way through it. For those of you who read this one, I don't know what you thought about...
16
2380
by: E. Robert Tisdale | last post by:
C++ Programming Style Guidelines http://geosoft.no/development/cppstyle.html I think that these guidelines are almost *all* wrong. For example: 11. Private class variables should have...
8
2369
by: Todd Smith | last post by:
I'm wondering if anyone knows where I can learn a good programming method for creating windows apps. I'm just starting to learn windows programming with MSVC++ 6.0. I want to learn low level...
43
2604
by: Sensei | last post by:
Hi! I'm thinking about a good programming style, pros and cons of some topics. Of course, this has nothing to do with indentation... Students are now java-dependent (too bad) and I need some...
13
1469
by: Mark | last post by:
Hi This is a fairly generic question about programming style and to a certain extent garbage collection. I have some methods that I write to text logs, the event log etc at various places in...
0
1311
by: MSFCLIPPER | last post by:
there are now new open source project presents new programming style design / paradigm vs OOP we invite all programmers to participate in this project project site :...
4
2126
by: Sreekanth | last post by:
Hi all, I have implemented a timing out version of fgets function call. I am pasting the entire code below. I have following doubts: 1. The code which I have written does it follow standard C...
10
1662
by: dydx31 | last post by:
Here is a simple program that I wrote: //This program takes in various inputs. //It calculates if the current balance exceeds the credit limit. //Programmer: Nathan D. Brown //Date: ...
14
1823
by: Astley Le Jasper | last post by:
I'm still learning python and would like to know what's a good way of organizing code. I am writing some scripts to scrape a number of different website that hold similar information and then...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.