|
Hi all, I want to draw a mere triangle on the screen using Direct3D and DirectDraw(which is becoming more and more of a pain in the a**e). I have done the following:
1.) Set up my custom window.
2.) Initialised DirectDraw.
3.) Set Cooperative level.
4.) Set Display Mode (1280x1024x16).
5.) Created Primary Surface with 1 Backbuffer.
6.) Obtained an IDirect3D7 pointer using QueryInterface with the DirectDraw pointer.
7.) Used 3D7->CreateDevice(GUID, PS Backbuffer, &D3DDevice7);
where the GUID is IID_Direct3DTnLHalDevice as detected by an enumeration function, D3DDevice7 is a pointer to the structure you expect (initialised to NULL).
8.) The viewport is created.
None of these initialisation aspects return an error. The app then enters the WindowProc callback function to process any messages. The WindowProc function uses PeekMessage to see if there are any pending messages, if there are NOT it calls the Render() function, which uses the following code to render ONE gouraud shaded triangle:
HRESULT CDarkSoldier::Render()
{
if (SUCCEEDED(m_DXControl.m_pD3DDevice7->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_DXControl.m_pD3DDevice7->DrawPrimitive(D3DPT_TRIANGLELIST, D3DVT_TLVERTEX, (LPVOID)v, 3, NULL);
return m_DXControl.m_pD3DDevice7->EndScene();
}
return S_OK;
}
However, the screen is blank when my app runs. I have added a MessageBox() function into the BeginScene() block and re-run the code, the messagebox pops up instantly (even when pressed ok), which means this block of code IS being run. I have also used a HRESULT to test the values that come out of DrawPrimitive and EndScene functions, they are both OK (no errors). I have not got a clue why it doesn't work, I have tried flipping the primary surface all to no avail. Also, when my app exists I have the following code:
CDApp::~CDApp()
{
if (m_pD3D)
{
m_pD3D->Release();
m_pD3D = NULL;
}
if (m_pDD)
{
m_pDD->Release();
m_pDD=NULL;
}
}
Strangely enough if I add this:
if(m_pD3DDevice)
{
m_pD3DDevice->Release();
m_pD3DDevice = NULL;
}
ANYWHERE in the destructor block, the application causes an unhandled exception upon release of the m_pD3DDevice, which has been initialised and is NOT NULL. Why the hell is this happening. Do you think the problem is interlinked? I would appreciate any views or links to web sites that deal with this kind of problem. I cannot see where the problem lies at all. I have managed to load a bitmap into an offscreen surface, blit it to the backbuffer and flip it and the image gets displayed, so the problem isn't with that. Anyway, thanks for reading the problem this far, just hope you can take some time to suggest some PC saving ideas, or else PC will be going out the window, Direct3D attached to its BackSIDE.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I'm trying to write a visual studio add-in and I need help doing what I think should be a relatively simply task: writing to the visual studio's build or output window.
I have seen add-ins that do this, but can't find source code to show how it is done. I am unexperienced with COM so I find it difficult to understand the IApplication class provided by DevStudio Add-in Wizard generated code to see if it provides such a function (which I don't think it does). I am using the Workspace Whiz Interface, but it also does not seem to present such a function. I have downloaded source code to add-ins that supposedly write to the output or build windows in MSVC++, but I can't find the code chunks where it does it, and many of them won't compile to test them further.
I have read about the "undocumented visual C++" which is an article on this site somewhere, but it only makes vague references to the fact that this can be done, without explaining how it is done. Well, it implies that you have to set up window hooks, but it doesn't give any more specifics than that.
Can somebody with experience in the matter just implement this function for me, or point me to some documentation on how I can implement this function?
void WriteToBuildWindow(const CString& sMessage)
{
//TODO: write the contents of sMessage to the build window of MSVC++
// or output window if the build window can't be done
// or any other equivalent window as applicable
}
|
|
|
|
|
I have an MDI application. What I need to do is limit the number of MDI windows open at one time to two(2).
How can I do this easily? I thought of using OnFileOpen() and then counting the number of times it went to this function was called, but I can still open multiple windows. Then I thought of going into the resources. I saw they had about 28 files that could be opened, so I limited that to two. That didn't work either.
I have no other code to show you, but any hints would be appreciated.
Best,
John Soares
support@onlinescamreports.com
|
|
|
|
|
Do you have multiple document templates? Or multiple views off of the same document... Either way what you are asking is possible. Just two different ways to do it.
|
|
|
|
|
How can we build a Dll with template-based-class export capability?
Can we export classes like this:
#ifdef INSIDE_DLL_PROJECT
#define DLL_OBJ __declspec(dllexport)
#else
#define DLL_OBJ __declspec(dllimport)
#endif
template<class T>
class DLL_OBJ SimpleTemplateClass
{
//declarations and class interface
};
I want to hide my implementation template classes and build a Dll (as we do for non-template export Dll) instead of distributing all class codes in an .h unit.
Does the same problem prevent MS to build WTL Dlls?
I use MS Visual C++ 6.
|
|
|
|
|
Since your < and > signs disappeared I can't really say. But you can _not_ ship anything where you are not exporting the explicit instantiations of a template class without shipping the code itself.
It's three steps:
1 - Class template (the code).
2 - Template class (the code instantiation of that template class).
3 - Exporting 2.
|
|
|
|
|
Hi,
(FYI : Moving my project from VC6 to VC7, I have an horrible amount of problems.)
The last one is I can not read my old files. The same code compiled with VC6 is OK. Now if I compile with VC7, I have a CArchiveException::badClass.
The output window of the debugger write :
"Warning: Cannot load DCStoreContents from archive. Class not defined.
CArchive exception: badClass."
Any idea ?
|
|
|
|
|
The answer was found on Microsoft forum : this is a bug of VC7 (modification of the IMPLEMENT_SERIAL macro) and we just have to wait for the service release.
|
|
|
|
|
I have just got this same error under visual studio 2003 when trying to serialize a CMapStringToOb class from disk back into the hash table from inside a MFC DLL. The strange thing is im also serializing about another 6 CArray objects which work with no problem what so ever.
From what i can gather this bug was found in 2002 .NET and has still not been fixed??
Did you ever get your code working?
Thanks
zebbedi
|
|
|
|
|
Wow, this was one year ago !
As I wrote, there was a bug in the IMPLEMENT_SERIAL macro in the VS.NET 2002, which was signaled in Microsoft Forum.
In June this year, I tried again to move our VC6 project to the (then) new VS.net 2003 and this time I think it worked correctly from the beginning (I do not remember having any of this problem - but I did have others).
So I don't think I have had the problem with VS 2003, and I can not see how to help, sorry.
Best regards,
Olivier
|
|
|
|
|
Thanks for the reply,
Just out of interest were you using a collection class of some type (CArray, CMap etc). If so please could you tell me which.
My DLL currently has another 6 CArray collections in it which serialize no problem. Its only this CMapStringToOb that is giving me grief.
Soon as i take the exact same code outside the DLL it works perfectly.
|
|
|
|
|
I have a probelm that one of my cpp files is converted into the Hex code automatically . The exe is working fine but i am not able to trace the code back.
Can you suggest some Solution
Samir Sood
|
|
|
|
|
|
Hi, I would like to get hold of the co-ordinates of an Edit control on a dialog.
I've tried creating a control var for that Edit box and using of it's functions but am having no joy.
I would appreciate any help you could give me.
Jacques Victor
|
|
|
|
|
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_MYEDIT);
CRect EditRect;
pEdit->GetWindowRect(EditRect); // puts coordinates into CRect
ScreenToClient(EditRect); // converts from screen coordinates to relative to the dialog its in
EditRect.top -= 50; // subtract 50 from the top pos
// set the position to the new position
pEdit->SetWindowPos(&wndTop, EditRect.left, EditRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
// hope that helps
-dz
|
|
|
|
|
I'm looking for a decent DialogBar HOWTO.
Need a kind of tool window like those neat panels from macromedia.
I know it can be done with a CDialogBar and with dockable disabled.
It aint so hard to for a single dialog, but i want to use tabs. I cant get it done, so ...
Anybody got an idea how to get the job done, where to find a decent HOWTO ?
ps. i'm quite new to MFC thus... keep answers not too technical
thx all
I used to have a life ... now I have a computer
|
|
|
|
|
|
sure i can. I aint that dumb.
But i got problems creating child windows.
And catching their messages.
I used to have a life ... now I have a computer
|
|
|
|
|
I don't know about child windows, but catching there messages might involve overrriding the following function: CControlBar::WindowProc()
Check the source code for it and you will see something like this:
<br />
LRESULT CControlBar::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
ASSERT_VALID(this);<br />
<br />
switch (nMsg)<br />
{<br />
case WM_COMMAND:<br />
case WM_DRAWITEM:<br />
case WM_MEASUREITEM:<br />
case WM_DELETEITEM:<br />
case WM_COMPAREITEM:<br />
case WM_VKEYTOITEM:<br />
case WM_CHARTOITEM:<br />
return ::SendMessage(::GetParent(m_hWnd), nMsg, wParam, lParam);<br />
}<br />
return CWnd::WindowProc(nMsg, wParam, lParam);<br />
}<br />
Add the desired messages you wish to capture after
case WM_CHARTOITEM:
For more info, search for the following article in the MSDN:
Using CDialogBar in 32-Bit MDI Applications
Nigel Thompson
Microsoft Developer Network Technology Group
Created: September 27, 1994
James
Drinking In The Sun
Forgot Password?
|
|
|
|
|
How do you remove (without resulting to error) or hide the Menu in an MDI window (CMDIFrameWnd)?
|
|
|
|
|
|
No I haven't tried that, but will try.
Got a solution though: I am currently trying to set the Menu of the Main Frame Window menu to NULL:
////
BOOL CMainFrame::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
if (GetMenu ())
SetMenu (NULL);
return CMDIFrameWnd::OnEraseBkgnd(pDC);
}
////
It works.. except sometimes there are some minor flicker when adding or closing child windows.
Other ideas are much appreciated
Thanks.
|
|
|
|
|
I have a property sheet, which I added a button.
The button brings up a modeless dialog, using the Visual C++'s sample modeless code. The dialog is never visually created, but successfully returns from the Create call (i.e., 1).
m_pCrowsFeet_modeless = NULL;
if (m_pCrowsFeet_modeless == NULL){
m_pCrowsFeet_modeless = new CrowsFeet_Dlg(this);
BOOL dana1 = m_pCrowsFeet_modeless->Create();
if (dana1 == TRUE)
GetDlgItem(IDOK)->EnableWindow(FALSE);
}
else
m_pCrowsFeet_modeless->SetActiveWindow();
The value of dana1 from the Create is 1. But the error occurs when
EnableWindow(FALSE) is invoked. That is the ASSERT(::IsWindow(m_hWnd) is violated and aborts.
CWnd* CWnd::GetDlgItem(int nID) const
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlCont == NULL)
return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));
else
return m_pCtrlCont->GetDlgItem(nID);
}
The dialog works when called from an application, but not from a property sheet.
Is not a property derived from Cwnd and therefore an IsWindow?
The this from the dialog code does not appear to have a m_hWnd.
Is this true of a propertysheet?
Although the same parent is used to create a window
BOOL ret = Create(NULL, windowName, WS_OVERLAPPEDWINDOW | WS_VSCROLL,
CRect(10,10,300,400), parent, 0);
Thanks, dana
|
|
|
|
|
try removing the 'this' in the line
m_pCrowsFeet_modeless = new CrowsFeet_Dlg(this);
and then see.
|
|
|
|
|
I click Build/Start Debug/Attach to process. Normally i must get the processes list as i can choose something from it. But the list is empty.
Do you know how could i bring the PIDs into the list?
rechi
|
|
|
|
|