Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 15 Jul 2012
Offline Last Active Mar 28 2013 03:48 PM

Topics I've Started

Rotate 4x4 matrix formula

22 February 2013 - 07:41 PM

I am trying to figure out how to work with a 4x4 matrix, in particular rotating them. I have been searching and reading differnt things but I keep hitting a brick wall when I see the formulas. I can see which parts of the matrix need to be changed depending on if I rotate on the x, y or z axis. But I cannot interpet their formulas so as to use them in code.


I have tried several experiments and I am not geting the right numbers. And since they use letters and greek letters and give no point of refernce for them I am sure additional calculation are need but there is no clear reference to the correct calculation. In one fomula I saw they used cosine and sine with the theta character in parenthases which previously in the article it was defined as pi/2 (which makes no sense at all) but that didn't work when I used it.


I am hoping someone has some nice clearly defined formulas I can work with.


Can I avoid the hassle of these IDE's?

18 July 2012 - 11:34 AM

Likely someone is going to look at me side ways, I may even get my head knocked off and handed back to me, but I have to ask.

I am getting tired of fighting IDE's. Everything from the frameworks not being found (even though it is installed and works with other programs) to having to track down some obscure setting. Or a library file needing to be "linked", sometimes in more than one spot. And all compounded by poor documentation, or what is there is missing some key note. When did programing turn into something sort of using AutoCAD. I want to type (well copy, paste at least) and solve impossible coding dilemmas, not change settings on poorly constructed software.

I build PHP based web apps for a living, while the PHP does some of the heavy lifting, it is almost night and day when it comes to dealing with IDE's for writing code in C++. PHP can be done in a text editor (obviously a bit nicer one is good), and with that text editor I can include "library" files, pass data to and from other programing languages (MySQL, XML, Javascript, etc), make graphics, create files, ect. Also, as showing the server generated error messages to the user is not preferred, I build my own error handling, which during development can be used to provide additional debugging info. And all that can be done without touching any software settings.

Now obviously a compiler is needed for C++ but after that why on earth do I have to leap tall buildings to get an IDE to work with C++. It seems to me one could write C++ in a text editor. Build your own error handling and debugging "library" and run it in a simple compiler. Or maybe these IDE's have finial driven me to looney bin.On top of all that, what is more disconcerting is I know Microsoft. It can be just about guaranteed that upgrading to the next version of Visual Studio will be about the same as having to buy your first copy of Visual Studio, hours and maybe even days learning how to just make your first "hello world" compile.

If it is possible to use a text editor and a compiler to do C++, please I'll read a 10,000 page tutorial over keep on fighting these IDE's. It would seem to me it's possible, just most rely on the IDE to take care of certain things that could likely be done fairly simply in one's code or with an additional library file.

Funny thing is PHP is written in C and C++ if it were all a C++ lib or .h files man would it make things easy on me (hmm, I wonder???), barring the linking thing that is.

Need help using D3DXCreateTextureFromFileEx

16 July 2012 - 10:14 PM

Been beating my head against the wall for the last few day and so I am hoping someone can help. I am relatively new to programming in C++ (been programming in PHP [and other languages] for several years) and in the last few months I started playing around with DirectX.

First, the original code I am trying to modify, and that does work (I think most of it came from a tutorial).
LPDIRECT3DTEXTURE9 Dx_Manager::GetTexture(char* filename)
  for (int i = 0; i < MAX_TEXTURES; ++i)
	if (!d3d_texture[i].texture && d3d_texture[i].inuse)
	d3d_texture[i].inuse = true;
	d3d_texture[i].filename = filename;

	D3DXCreateTextureFromFileA(d3d_device, d3d_texture[i].filename, &d3d_texture[i].texture);

	return d3d_texture[i].texture;
  return NULL;
Apparently "D3DXCreateTextureFromFileA" insists that graphics be sized to the power of 2 (2, 4, 8, 16, 32, etc), and while it can be dealt with, by making unused parts of the graphic transparent, I can foresee problems with scaling as well as interactive graphics elements overlapping each other. And on top of that there is the wasted memory for the larger than necessary graphic.

So I am thinking that using D3DXCreateTextureFromFileEx would be better. Here is what, I think, I need to replace line 12 (above) with:
	HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
	if (result != D3D_OK)
	 return NULL;

But in both the places that I use "filename.c_str()" I get this error
error C2228: left of '.c_str' must have class/struct/union
If take off the ".c_str()" I get errors similar to this
error C2664: 'D3DXGetImageInfoFromFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
I have tried changing the type of "filename" from "char*" to "WCHAR*", "TCHAR", "LPCWSTR", "LPCSTR" as well as looked up ways to convert "char*" to other types and all have failed to work. And really I am not even sure changing the type definition is the solution to the problem.

Any direction on this would be much appreciated.

Also in researching a solution, I read in one place that "D3DXCreateTextureFromFileA" is easier on graphics cards than "D3DXCreateTextureFromFileEx". So if there is a completely different approach I should be looking at let me know.