|
Hi,
i've tried to initialize DirectDraw and to create a Primary Surface with an attached Back Buffer. The initialisation-function fails and I've no idea why. The CreateSurface-Function fails. I've tried to retrieve the error code returned by it but I've found no matching error defined in ddraw.h)
I've removed DDSCL_EXCLUSIVE for debugging purposes. It's hard to debug a program with exclusive access to video memory and input-devices
Thanks for you help.
[code]
BOOL DXGraph::InitGraphicsSystem(HWND hWnd)
{
DDSURFACEDESC2 ddPriSurf;
DDSCAPS2 ddCaps;
BOOL bSuccess = FALSE;
//Globales DirectDraw Objekt erzeugen
if (FAILED(DirectDrawCreateEx(NULL, (LPVOID*)&lpDD7, IID_IDirectDraw7, NULL)))
{
return FALSE;
}
//Kooperationsebene festlegen
if (FAILED(lpDD7->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_FULLSCREEN | /*DDSCL_EXCLUSIVE | */DDSCL_ALLOWREBOOT)))
{
lpDD7->Release();
return FALSE;
}
/* if (FAILED(lpDD7->SetDisplayMode(1024, 768, 16, NULL, NULL)))
{
lpDD7->Release();
return FALSE;
}
*/
//Primäre Oberfläche erzeugen
ZeroMemory(&ddPriSurf, sizeof(ddPriSurf));
ddPriSurf.dwSize = sizeof(ddPriSurf);
ddPriSurf.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddPriSurf.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddPriSurf.dwBackBufferCount = 1;
if (FAILED(lpDD7->CreateSurface(&ddPriSurf, &lpDDSPrimary, NULL)))
{
lpDD7->Release();
return FALSE;
}
//BackBuffer-Adresse abfragen
ddCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpDDSPrimary->GetAttachedSurface(&ddCaps, &lpDDSBackBuffer)))
{
lpDDSPrimary->Release();
lpDD7->Release();
return FALSE;
}
return TRUE;
}
[/code]
|
|
|
|
|
Problem:
Compuholic wrote:
if (FAILED(lpDD7->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_FULLSCREEN | /*DDSCL_EXCLUSIVE | */DDSCL_ALLOWREBOOT)))
DDSCL_NORMAL and DDSCL_FULLSCREEN are mutually exclusive. You cannot use them together. If you want a Fullscreen application use DDSCL_FULLSCREEN, and if you are going to run your app in a window use DDCSL_NORMAL.
Other than that things look ok to me. If you would like an example of some DirectDraw code, I have written a simple framework that I use in a Tetris game that I wrote and posted here on code project. You are welcome to check that out: Tetris[^]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks, you are right. I just checked the documentation on MSDN. But i'm wondering why SetCooperativeLevel succeded if it was just an invalid combination of flags.
Another Problem persists:
DDSCL_FULLSCREEN has to be used with DDSCL_EXCLUSIVE. Is there a way to debug such an application?
If I use DDSCL_NORMAL the CreateSurface function still fails. Is it possible that Double Buffering can't be done in a normal windowed application. I need some way to debug it
|
|
|
|
|
Compuholic wrote:
If I use DDSCL_NORMAL the CreateSurface function still fails. Is it possible that Double Buffering can't be done in a normal windowed application. I need some way to debug it
I am sorry, I didnt even think about that. You cannot use DirectDraws backbuffer support to do page flipping. You will need to do your own bitblt to the screen from the backbuffer.
Also, there are two ways to debug a full screen app, and neither one of them are available to a normal setup.
You can either use a Dual Monitor system, which is what I use.
Or you can use a second machine networked to the first machine and do remote debugging.
The Tetris Game that I wrote supports both modes if you want to look at that.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Im relatively new to MFC and Im trying to implement an automagically sorting list control (you know the one, click on the column header, and it sorts itself, etc), im fairly sure ive got it all figured, but i get the error;
'GetListCtrl' : undeclared identifier
I always thought, as does msdn that GetListCtrl is a function of afxcview.h, yet despite me including this file, i still get the message, is there a lib i need to link or something ?
|
|
|
|
|
hi all ,
hope u can help me with this brain-teasing (?) problem.
i have two classes:
class Surface {...},<br />
class Extent : public Surface {...},
let pMyPtr be a DWORD_PTR which can store a pointer to either an Extent or a Surface, ie.
Extent *myExtent=new Extent();<br />
Surface *mySurface=new Surface();<br />
<br />
pMyPtr=(DWORD_PTR)myExtent, or<br />
pMyPtr=(DWORD_PTR)mySurface,
say for example that at a particular time it is not known what DWORD_PTR actually points to - it could either be an Extent object or a Surface object.
Is it possible to determine this? I need some sort of function as shown below...
if(pMyPtr points to an instance of the extent class)<br />
AfxMessageBox "this is an extent"<br />
else<br />
AfxMessageBox "this is a surface"
hope u can help cos i am absolutely boggled by it!
thanks,
Paul.
|
|
|
|
|
It can be done if Surface has at least one virtual function:
if(dynamic_cast<Extent*>(reinterpret_cast<Surface*>(pMyPtr))){
}
else{
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Another option is to investigate RTTI (Run Time Type Information). I haven't used it in years, but it's basic premise is to do what you want.
Joel Lucsy
|
|
|
|
|
How can i catch the LBUTTONUP in the dropdownpart of a Combobox?
What i would like to do is to know which item that has been clicked
in the list. And the only thing that i can think of is catching
the mousebutton and caluculate which item the user has clicked.
Or is there another way?
|
|
|
|
|
The combo box sends CBN_SELENDOK and CBN_SELENDCANCEL messages when the drop list is closed. When you receive CBN_SELENDOK , use CB_GETCURSEL to get the selected item.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks for the reply.
Unfortunately that doesn't work for me. Maybe i should have said that i'm using the
CCheckComboBox that can be found on this site. And when a item is selected the list
doesn't close. The user can check/uncheck mutiple items before the list is closed.
I could go through all the items when the list is closed and look for what the user has
selected. But to catch when the mousebutton is pressed on a item would be a better
solution. If it is possible.
|
|
|
|
|
You need to handle the CBN_SELCHANGE notification from the control.
Software Zen: delete this;
|
|
|
|
|
hi every body !!
got a little problem
i'm doing a chat view. So what do i have to get in .
2 parts : one for reading and the other one for writng!
So that does mean if you do this with splitter window you need Row
ok
now the problem
i split my window with the 2 views (edit and edit or richedit)
i lock the split bar so that the user will not be move it nut my problem is that
:
1/ when you split and define 2 row you can just specifie the size of the first row.and this first row must be on the top the second on the bottom.
2/ that's not what i need because i would like to fix the bottom side or the second row which is the window where you can write.
in another word the size of the window in which the user will write must be fixed.
the problem is that this window is unfortunatly the second when you split your window .Indded this window is at the bottom
i would like to know a method to do this :
what i konw : split put the view and lock the bar
what i would like to know :
a°) specifie size of the second window (which on the second
row) which is the window where the user can write his text.
b°) for the first row where text will be display, which is on the top i don't care about his size.It can move
c°) what i want is to lock my split bar relativly to the bottom
having a fixed size for the bottom row
just that
if you don't anderstand ask me picture
or more question or code
this is what i try to do :
my idear was to reverse the coordinate so that the first row would be created on the bottom and fix and the second row on the top level widow but it doesn't work !!
i did this
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
/*if (!m_wndSplitter.CreateStatic(this,1,2) ||
!m_wndSplitter.CreateView
(0,0,RUNTIME_CLASS(Csearck),CSize(128,0),pContext)
||!m_wndSplitter.CreateView
(0,1,RUNTIME_CLASS(CScearchList),CSize(0,0),pConte
xt))
return FALSE;
m_wndSplitter.Locked(TRUE);*/
m_wndSplitter.CreateStatic(this,2,1);
CClientDC dc (&m_wndSplitter);
CRect rect;
m_wndSplitter.GetClientRect(&rect);
dc.SetViewportOrg(rect.Width(),rect.Height());
m_wndSplitter. CreateView(0,0,RUNTIME_CLASS(CEditView),CSize(0,12
8),pContext);
m_wndSplitter. CreateView(1,0,RUNTIME_CLASS(CScearchList),CSize(0
,0),pContext);
m_wndSplitter.Locked(TRUE);
return TRUE;
}
if you think that you can't , that means that you can : if you understand this there youn can
|
|
|
|
|
Hi,
I use PreSubclassWindow() to test font size in my edit control.
When I destroy my edit control and recreate it.... PreSubclassWindow() is called again but has no valid font set, eeks! The line CFont* pFont = GetFont() return a CFont with pFont->m_hObject == 1 , strange. Filling a LOGFONT structure fails.
Can anyone explain what happens & what can I do against?
Thx, Moak
PS: I think I used PreSubclassWindow() because OnCreate() is not called from dialogs (but I'm not sure on this).
|
|
|
|
|
I'm using a workaround: getting window's font once + catching changes.
|
|
|
|
|
I have "men.x"(<--this word) in Listbox when I double click at "men.x" , the 3D model is loaded to show in frame suddenly so... "men.x"'s type is CString. How can I convert CString to LPSTR? because I have to use D3DLoadMeshFromX(LPSTR pfilename,....)to call file.x
So .... How can I do????
Bug
|
|
|
|
|
Maybe (LPSTR)((LPCSTR)strFilename) works or make a strcpy to a char,
Gero
|
|
|
|
|
Converting CString to LPSTR is easy:
CString csString;
LPSTR lpString;
lpString = csString.LockBuffer();
csString.UnlockBuffer();
-Dominik
|
|
|
|
|
Try this:
CString csString;
LPSTR lpString;
lpString=(LPSTR) csString.GetBuffer(0);
I hope, this will work!
A. Riazi
|
|
|
|
|
How do I control remote program over the network with Visual C++. I mean, for example, I want to move a button from that program to a new location or lock the program or what ever. Thank you very much in deep for your interest...
P.S. Please tell me a correct site if my problem is not related to this site. Thanks...
Phalanx
|
|
|
|
|
Do you know Client/Server architecture? Do you familier with programming sockets?
if so, use CSocket derived class to send data/information from one computer to another. Also its possible to use Named Pipe.
A. Riazi
|
|
|
|
|
How do I control remote program over the network with Visual C++. I mean, for example, I want to move a button from that program to a new location or lock the program or what ever. Thank you very much in deep for your interest...
P.S. Please tell me a correct site if my problem is not related to this site. Thanks...
Phalanx
|
|
|
|
|
|
I have my website located on a remote server, and there is a MDB database on the server. The Server is Win 2000 Advanced Server. I want to make such a software in VC++ that can import data from the remote database and show the filtered records to the client.
Can this thing be made in VC++, if yes then please help me how to make this thing.
Regards
|
|
|
|
|
Are you familier with Client/Server programming? Do you know how programming with sockets?
A. Riazi
|
|
|
|