Click here to Skip to main content
15,909,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Opening and Displaying TIFF images Pin
Chris Losinger1-Jul-02 9:13
professionalChris Losinger1-Jul-02 9:13 
GeneralRe: Opening and Displaying TIFF images Pin
Marc Richarme1-Jul-02 11:07
Marc Richarme1-Jul-02 11:07 
Questionstr to double? Pin
briefcase1-Jul-02 7:36
briefcase1-Jul-02 7:36 
AnswerRe: str to double? Pin
Chris Losinger1-Jul-02 7:46
professionalChris Losinger1-Jul-02 7:46 
GeneralRe: str to double? Pin
David Viggiano1-Jul-02 9:21
David Viggiano1-Jul-02 9:21 
AnswerRe: str to double? Pin
Stuart Dootson1-Jul-02 13:24
professionalStuart Dootson1-Jul-02 13:24 
GeneralActiveX Woes Pin
1-Jul-02 7:09
suss1-Jul-02 7:09 
QuestionWhy can't I draw a triangle to the screen? Pin
Alan Chambers1-Jul-02 7:01
Alan Chambers1-Jul-02 7:01 
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
Generalhelp writing add-in... Pin
RenGirion1-Jul-02 6:59
RenGirion1-Jul-02 6:59 
GeneralBeginner question: Limit number of MDI pages open at one time... Pin
John Soares1-Jul-02 6:42
John Soares1-Jul-02 6:42 
GeneralRe: Beginner question: Limit number of MDI pages open at one time... Pin
Chad Koehler1-Jul-02 6:50
Chad Koehler1-Jul-02 6:50 
GeneralExporting template based class from a Dll Pin
PinkPanter1-Jul-02 6:17
PinkPanter1-Jul-02 6:17 
GeneralRe: Exporting template based class from a Dll Pin
Mike Nordell2-Jul-02 7:17
Mike Nordell2-Jul-02 7:17 
GeneralCArchiveRxception : badClass Pin
Olivier REIX1-Jul-02 6:07
Olivier REIX1-Jul-02 6:07 
GeneralRe: CArchiveException : badClass Pin
Olivier REIX2-Jul-02 21:32
Olivier REIX2-Jul-02 21:32 
GeneralRe: CArchiveException : badClass Pin
zebbedi15-Dec-03 10:47
zebbedi15-Dec-03 10:47 
GeneralRe: CArchiveException : badClass Pin
Olivier REIX15-Dec-03 20:20
Olivier REIX15-Dec-03 20:20 
GeneralRe: CArchiveException : badClass Pin
zebbedi15-Dec-03 20:44
zebbedi15-Dec-03 20:44 
GeneralProbelm regarding cpp Pin
SamirSood1-Jul-02 4:44
SamirSood1-Jul-02 4:44 
GeneralRe: Probelm regarding cpp Pin
[James Pullicino]1-Jul-02 5:06
[James Pullicino]1-Jul-02 5:06 
GeneralCEdit Control Co-Ordinates Pin
Chavez1-Jul-02 4:18
Chavez1-Jul-02 4:18 
GeneralRe: CEdit Control Co-Ordinates Pin
dazinith1-Jul-02 4:41
dazinith1-Jul-02 4:41 
GeneralNeed a DialogBar HOWTO Pin
bisserke1-Jul-02 3:56
bisserke1-Jul-02 3:56 
GeneralRe: Need a DialogBar HOWTO Pin
[James Pullicino]1-Jul-02 4:00
[James Pullicino]1-Jul-02 4:00 
GeneralRe: Need a DialogBar HOWTO Pin
bisserke1-Jul-02 4:07
bisserke1-Jul-02 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.