|
Have you looked a the sample programs with the DirectX SDK. There is a game called donuts, and there are a few other examples that describe how to setup display surfaces and paint bitmaps.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
I've played the game donuts, but when ever i click on the tutorial, it comes up and says that it cannot find the tutorial of hh.exe. How do ill look at the source of the donuts game?
Thanks
~SilverShalkin
|
|
|
|
|
Did you choose to install the source files along with all of the sample applications?
If so, then you simply need to navigate to the directories where the samples are, and open them up in Dev Studio.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
Have you tried msdn.microsoft.com ? It's got heaps of stuff on DirectX. I believe www.codeguru.com has a column on it as well, or on game programming at least.
You shouldn't need DirectX for a Tetris game though - I believe there's a couple here on CP if you want to see how other people have done it. It's probably worth it to do it with and without DX IMO.
SilverShalkin wrote:
Also, just for fun kind of question: How do you bring an image to the screen?
Do you mean with or without DX ?
I have an Asteroids game, which uses DX 6, that I'm going to write an article for and post tonight. It was my 'write a simple game to learn game programming' project, so it's probably a little rough, but it's just sitting there, so I thought someone might find it useful.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
That would be cool :
Christian Graus wrote:
I have an Asteroids game, which uses DX 6, that I'm going to write an article for and post tonight. It was my 'write a simple game to learn game programming' project, so it's probably a little rough, but it's just sitting there, so I thought someone might find it useful.
Im getting a book that teaches DirectX... I'll learn from that and any other question... i got four forums to ask it
Thanks for your help
~SilverShalkin
|
|
|
|
|
The big problem ( and it will be a problem with my code as well ) is that DX changes so often, to write in DX 8, you need a book on DX 8. The book you buy will come with the SDK for the version it teaches, and for 2D stuff it probably won't matter so much, but still, be aware that the code changes between versions, therefore when you find code online you need to know what version it is for.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Thats got to be anoying at times like this i usually think- "why learn it, you'll have to learn it again..." but if you learn it once, the next time you'll have to learn it, you'll only have to change a little here and learn a little more there.
~SilverShalkin
|
|
|
|
|
hi friends
nice to introduce ..
i am suju,new to codeproject and c++
any one have an idea nice book for c++
my defination to nice book:
eg:
class A
{
virtual void function1()=0;
};
that explain to me what complier can do,linker can do and process can do for above class declaration.
that book teach me more about memory and os .
r u people think bore please execuse.
ok friends we will meet again with good discussion.
|
|
|
|
|
"Thinking in C++" - Bruce Eckel
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
What on earth is causing this to copy nothing to the CPaintDC??
-----------
void CCustomStaticControl::OnPaint()
{
// Do we have an update rect?
if (this->GetUpdateRect(NULL))
{
CPaintDC dcPaint(this);
CDC dcMem;
CRect rcRect;
this->GetClientRect(rcRect);
dcMem.CreateCompatibleDC(&dcPaint);
CBrush brushBack(this->m_rgbBack);
dcMem.FillRect(rcRect, &brushBack);
// Blit to the painting device context.
dcPaint.BitBlt(rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(), &dcMem, rcRect.left, rcRect.top, SRCCOPY);
}
}
It just refuses to draw anything. Works fine if I do it straight to the CPaintDC directly tho.
|
|
|
|
|
You have to have a bitmap selected into your memory DC.
have a look in MSDN for the CreateCompatibleBitmap() function.
void CCustomStaticControl::OnPaint()
{
if (this->GetUpdateRect(NULL))
{
CPaintDC dcPaint(this);
CDC dcMem;
CRect rcRect;
CBitmap bmp;
this->GetClientRect(rcRect);
dcMem.CreateCompatibleDC(&dcPaint);
bmp.CreateCompatibleBitmap(&dcPaint, rcRect.Width(), rcRect.Height());
CBitmap *oldbmp = (CBitmap *)dcMem.SelectObject(&bmp);
CBrush brushBack(this->m_rgbBack);
dcMem.FillRect(rcRect, &brushBack);
dcPaint.BitBlt(rcRect.left, rcRect.top, rcRect.Width(), rcRect.Height(), &dcMem, rcRect.left, rcRect.top, SRCCOPY);
dcMem.SelectObject(oldbmp);
}
}
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Hi.
I have been wondering about the possibility of *disabling* resize feature in a window. For example, when a window is in restore setting, the user can change the size of the window via dragging one of its four size or four corners. I there a way to disable that feature completely? I am basically describing a dialog window without having to derive the class from CDialog.
In the program I am working on, I have disabled the maximize feature. The window stays restored throughout. However, the user can resize it. I would like to disable that feature too. The bottom line is the window looks better if it remains in its original settings (size).
Thanks,
Kuphryn
|
|
|
|
|
|
That small change works perfect! Thanks.
Kuphryn
|
|
|
|
|
Can some one please tell me how i can add a simple tooltip text mouse over, on a button?
Thanks!
|
|
|
|
|
|
I was wondering if there is anyway for the modeless dialog to know when the mouse moves focus away from it and to something else.
Right now I created a modeless dialog in one of my views. I do not want it destroyed when finished but just want it to hide. That is easy since it won't be destroyed until the View is gone in this case. However, I also want it to hide when I click something other than it after showing it to tell it I don't need it. I have tried onkillfocus etc but it doesn't work because that is never called.
Any suggestions?
Thanks in advance.
|
|
|
|
|
|
I was wondering if it is possible to remove the button of the app running from the task bar. I do not mean for a dialog based project as Nish has pointed out a great solution. I mean for a SDI or MDI?
Thanks.
|
|
|
|
|
|
I used CListView in an SDI program, I want the view to handle WM_CHAR event but it did not seem to respond to any key stroke at all.
I guess that's because the CListCtrl occupied full area and thus took control over the view, so maybe I should look into LVN_KEYDOWN instead of WM_CHAR? I dunno but neither way worked.
Any help are appreciated.
|
|
|
|
|
Has anybody faced the need to create up to k n-dimensional arrays at runtime? Here is an example:
Suppose that at the moment of running the program, it needs 3 2-dimensional arrays, each of them has different dimensions. The dimensions of each table are stored in another 2-dimensional array. Then, you start creating the names of each array obtaining array1, array2 and array3. Then, how do you:
a) Declare array1, array2 and array3 as dynamic arrays (i.e. double *array1, *array2, array2;)
b) How do you re-declare them, i.e.
array1 = new double[newdimension];
The problem is not how to create the name of the variables, because you can do it by handling strings and concatenating a number so they can be identified.
The main problems are (a) and (b).
If someone has a potential response, please emailme...
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
First, you will need to create an array to hold your dynamic number of variables. Lets say that you are working with doubles, just for the example. You can either mess with dynamic array allocation like this:
double vars[];
vars = new double[3];
...
double newVars[];
newVars = double[5];
memcpy(newVars, vars, sizeof(double) * 3);
delete[] vars;
vars = newVars;
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
Depending on what you are doing, I would recommend that you check out the Standard Template Library (STL). It makes dynamic memory allocation and management a snap, and there are a few tricks that you can do to make accessing the varaibles much easier.
At first glance the vector seems to be what you are looking for, because it is an array that will dynamically grow and manage its own memory. However there are problems with using an array, even if you are doing it the straight C++ way. As long as you will be using STL, I would recommend the map . A map you have a key, and a value that the key represents. You could make the key a string, and the value a double. Here is an example.
#include <map>
using std::map;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
typedef map<char*, double, ltstr> mapVars;
Here is how you will use what we just setup:
mapVars vars;
vars.insert("variable1", double*);
double value = vars["variable1"];
vars.erase("variable1");
Now you have a set of dynamically defined variables with names. Now you need a way to dynamically allocate the array of variables. This case would either be good for a vector or a map . Both of these objects will manage their own memory, and grow automatically for your. Here is how you would use the vector:
#include <vector>
using std::vector;
typedef vector<double> vecDouble;
typedef map<char*, vector<double>, ltstr> mapVecVars;
mapVecVars vars;
vecDouble newVar;
newVar.push_back(1.0);
newVar.push_back(3.14);
newVar.push_back(98.6);
vars.insert("variable1", newVar);
cout << vars["variable1"][0] << endl;
cout << vars["variable1"][2] << endl;
For efficiency, you may want to hold pointers to doubles, and vector<doubles> to prevent all of the data from being copied each time it is accessed, however, the concepts are pretty much the same.
There is a lot of information here, on something that has a million ways to implement. This way I believe will get you up and running the quickest.
The arrays will work, but they will get messy when you have more than a few dynamic variables, and you start to erase varaibles in the middle of the array.
Good Luck
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
I have started a Win 32 Console Application with MFC support and I have created a dialog box with two buttons(RUN PROGRAM and EXIT buttons). I have also selected the class for the dialog box and set up the buttons correctly.
My source files and header files have been inserted into the source and header folders but I don't know how to link my RUN PROGRAM button with the main source file in my program.
Also there was a .cpp .rc and .h file already created which when compiled printed out to the screen Hello from MFC! should these files be deleated and replaced with my own.
caoimhin
|
|
|
|
|