|
Hello, I urgently need help getting Direct3D working, or at least find out where I am going wrong, so please read on. I am willing to send the full source code of my app to anyone willing and capable of maybe solving the problem. I have managed to setup DirectDraw, Direct3D the Primary Surface with one BackBuffer and the Direct3DDevice in one function (where I also set the Direct3DDevice viewport). I can load an image and blt it to the backbuffer and flip it, no problem. However, if I try and draw a simple triangle with gouraud shading with the following code:
HRESULT CDarkSoldier::Render()
{
if (SUCCEEDED(m_pD3DDevice->BeginScene()))
{
D3DTLVERTEX v[3];
v[0] = D3DTLVERTEX(D3DVECTOR(160,50,0), 1, D3DRGB(1,0,0), D3DRGB(0,0,0), 0, 0);
v[1] = D3DTLVERTEX(D3DVECTOR(440,200,0), 1, D3DRGB(0,1,0), D3DRGB(0,0,0), 0, 0);
v[2] = D3DTLVERTEX(D3DVECTOR(160,550,0), 1, D3DRGB(0,0,1), D3DRGB(0,0,0), 0, 0);
m_m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DVT_TLVERTEX, (LPVOID)v, 3, NULL);
return m_pD3DDevice->EndScene();
}
return DDERR_INVALIDPARAMS;
}
I get nothing, just a blank screen. This code is executed whenever there is no windows message pending (i.e. when the system is idle - and it is I have tested it). I have tried flipping the primary surface after this code, but nothing. Also, I have tried using m_pD3Device->Clear() to clear to another colour without success. Why is this happening? Is there something I MUST do before the Direct3DDevice will work? I receive no errors during setup, or during the app at all, come to think about it. I create the Direct3DDevice using m_pD3D->CreateDevice(pGUID, BackBuffer, &m_pD3DDevice); I have DirectX8.1 runtime and DirectX7 SDK. I have tested DirectX7 and DirectX8 using the system diagnostic indicator, and both are fine. So there MUST be something. Please...just highlight some areas or pitfalls where I might be falling down on. I am desperate to draw a friggin triangle...it shouldn't be this difficult.
P.S. Not sure if its linked, but immediately after window creation and d3d initialisation if I blt a surface to the back buffer and flip it, the image comes up. If I blt it to the primary surface, it never comes up no matter how many times I flip it (its blank). However, I can get this code to work provided it is located somewhere in the WindowProc message processing loop, but not before it enters...is that strange or what?
Thanks to all who read and reply.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I wish I could swear at this point. I have AT LAST found the problem of ALL problems, and I managed to do it myself (where is the smiley for pat yourself on the back??). Do you want to know why my D3DDevice structure wasn't drawing a triangle on the screen? Well I'm gonna tell you anyway. You wil note my code in the previous message (above) where it says m_pD3DDevice->DrawPrimitive(...) ok? See the flag D3DVT_TLVERTEX? yeah? well change it to D3DFVF_TLVERTEX and the b*****d thing works! I have wasted 4 or 5 days on this crappy problem and if there is ever an excuse NOT to use Direct3D over OpenGL, that is it! That flag worked in v6, but not in v7, watch out for more nasty problems I run into on this very web site.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I have an ATL dialog box, but when clicking OK, Cancel, or the X on the window border, the window does not close.
I have implemented the dialog box using CDialogImpl template class.
Tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hi,
I have an awefull problem with casting floats to doubles, for example:
float f = 0.2f;
double d = (double)f;
results in d == 0.20000000232323442 or other garbage after the precision of float.
I'll be glad to any ideas other than fitting the result to float precision since float precision might be change between platforms. (theoreticly speaking).
thanks,
BishGada.
|
|
|
|
|
I think there is some compiler switch for that....but not sure.
/Magnus
- A dog who attends a flea circus most likely will steal the whole show
|
|
|
|
|
That problem has existed on every Intell computer that I know of for the last 30 years. Its not really Intell's fault, but rather the nature of the beast. Many numbers cannot be represented exactly by floating-point math due to the way they are calculated. It has something to do with powers of 2, but I don't recall the exact calculation.
Here's an article, if you can wade through it.
http://www.math.grin.edu/~stone/courses/fundamentals/IEEE-reals.html
|
|
|
|
|
How do you insert a scope pane item without making it appear in the result pane, when its parent node is selected?
I have a snapin which has its root node display some items in the result pane, with multiple column. This root node also has a child in the scope pane.
The problem is that when the root node is selected, the children is displayed in the result pane. I don't want it displayed.
I tried to return S_FALSE, S_OK, E_FAIL, E_NOTIMPL, E_INVALIDARG from GetResultPaneInfo but nothing works.
Any help?
Tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
set in GetResultViewType():
*pViewOptions |= MMC_VIEW_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST;
|
|
|
|
|
Normally I make everything with MFC, but the large mfc library and all the wizzards sometimes annoy me, so I'm going to try to make something -pure-, a normal win32 program.
But now I noticed many things I always used appear to be mfc only (TRACE for example). So what is a good place to start? Are there any good Tutorials, or books which cover the basics of win32 well?
All kinds of questions arose, such as...
o Where to define my variables? (I used to define them in the classes in which they were used, and I try to avoid to make them global)
o What functions to use to manipulate strings? (wsprintf uses LPTSTR as it should, but are there LPTSTR equivalents of sscanf and such?)
If you could give some advice I would be very grateful.
Thanks in advance!
- Griffith
|
|
|
|
|
"programming windows 95" (not sure about the title)
by charlez petzold (not sure bout the spelling )
might be a good book.
But i would suggest you look at WTL instead, it is a lightwight
framework for the win32 api. (or for the windowing part at least)
/Magnus
- A dog who attends a flea circus most likely will steal the whole show
|
|
|
|
|
Thanks, I'll check it out.
|
|
|
|
|
I think you might be better looking into WTL first before moving to straight Win32 API. WTL is a much smaller and cleaner framework than MFC.
The Charles Petzold book will give you a good grounding in Win32 programming. Not sure of the current title as my copy is Programming Windows 3.1
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
Would you happen to know any good books which cover the WTL basics then?
|
|
|
|
|
The Petzold book is an excellent tutorial. Btw, you can (and should!) continue to use classes.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks, I'll see if I can find it.
Oh.. and I didn't want to stop using classes, only the CString, CDialog, and those are the ones I wasn't particually fond of.
|
|
|
|
|
STL will handle the string classes using std::string. WTL will give you a nice thin framework for CDialog.
You could write your own framework, do a search for Windows++ for an example.
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
I've read "Win32 Programming" by Brent Rector and Joseph M. Newcomer. It's an excellent read and a great reference book. My copy started to fall apart because I used it so much when learning pure Win32 programming.
Also, Joseph is a registered CPian and well-respected programmer. Take a look at some of his articles to see the quality of his work. This is also reflected in the book.
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"Victims falling under chains ~ You hear them crying dying pains
The fist of terrors breaking through ~ Now there's nothing you can do"
Song: Phantom Lord - Album: Kill 'em All - Artist: Metallica
|
|
|
|
|
How can I obtain the handle to a disabled control(button) in one application and enable it from another application.
Thanks
|
|
|
|
|
use FindWindow function to get the handle of your control,then you can do what you want on that control.
|
|
|
|
|
Hi,
My application handles the CTRL+Z/Y to make my "undo/redo" stuff, but I´m having problems, when the focus is ( for example), in an edit control, then I don´t get that message ( the edit control handles it), is there anyway to aviod that ( without use the bag of problems called PreTranslateMessage...).
Thanks in advance, Greetings
Braulio
|
|
|
|
|
I've followed the tutorial about creating office addin's. The one I've created is an excel addin. It doesn't do anything, it's just a minimal addin.
But it doesn't show up in the excel addin-list, even though it's registered in windows registry.
The loadbehaviour should be set to 3 for automatic loading.
After compiling the project, using regedit shows 3 for loadbehaviour. So far so good.
But after running excel, eyeballing the addin is not there, the loadbehaviour in regedit changed to 2 ??????
What's going on here?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
I am a little embarrased having to ask about this, but I have a need to change the font size/style of a static text field and I can't remember how to do it. My old code library is at my last job and I don't have access to it anymore. Is there anyone out there with a lead on where I might go to quickly solve this problem? Thanks for any help you can give!
Dan Broomall
GIS Programmer/Analyst
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein
|
|
|
|
|
|
You can change the font for the whole dialog by bringing up the properties for the window in the dialog editor. This font will be used by everything else on the dialog too, though
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I got from the MSDN this snippet about enabling/disabling menus. I put it in a button click event (for starters). I got a debug /assert. Where should it go?
Please let me know.
Thanks,
ns
In the real project its supposed to happen after a successful login from a modal dlg box spawned off an MDI CFormView form:
In a doc menu click event:
{
CMyDialog cMyDlg;
int ret = cMyDlg.DoModal();
If (ret==5)
{
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->EnableMenuItem(ID_FILE_NEW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
}
|
|
|
|
|