|
do you think this would be substantially enough for a DX game?
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Because you're using PeekMessage rather then GetMessage your loop spins in the outer while loop even when there is no message to process. Unless you have an else not show in the code above in the if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) statement this code is needlessly inefficient. I would suggest you replace it with a GetMessage and watch the CPU usage go down.
Steve
|
|
|
|
|
thank you for the comment, and yes I do have an else statement in the block but forgot to write it in. so you think it will still be good if it has an else block or should i stick with getmessage?
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Normally you'd use PeekMessage and perform some idle time processing in the else part. I'm not sure what's going on in the else bit but it looks ok to me. I find myself a little concerned that you may be busy waiting but I'd have to see the else bit to be sure.
Steve
|
|
|
|
|
Does anyone know of a good C++ lib that is free and can replace ATL functionality, specifically implementing enough for the Web Browser component?
[edited:]
This is specifically to implement the set of COM interfaces needed to host the IWebBrowser control. I'd prefer not to have to write all this nonsense from scratch, hence the interest in a library other than ATL to do so for me. MFC won't work, it needs to be freely redistributable in source form (and no GPL crap licensing either).
[/edited]
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
-- modified at 13:37 Sunday 22nd January, 2006
|
|
|
|
|
MFC although wouldn't recommend it... WTL which is on sourceforge... found here http://sourceforge.net/projects/wtl[^]
ALSO TRY USING .NET WHICH IS LIKE MFC ON ULTRA STERIODS.
I personally think that .NET will eventually replace windows programming, not including game programming.
IM PROUD TO BE A GMAIL;
-- modified at 11:01 Sunday 22nd January, 2006
|
|
|
|
|
ATL is a library to write COM code, right? How does it relate to MFC, which is primary targeted for GUI development?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
He didn't say it had to support COM code, right? and also, I said that I wouldn't recommend it (MFC);)... also I said WTL which is actually based off of ATL. Any more questions about what I said?
Doesn't MFC support Web Browser functionality?
IM PROUD TO BE A GMAIL;
-- modified at 11:41 Sunday 22nd January, 2006
|
|
|
|
|
tom_dx wrote: I personally think that .NET will eventually replace windows programming,
|
|
|
|
|
I suggested that he use .net instead of atl for gui programming.
IM PROUD TO BE A GMAIL;
|
|
|
|
|
|
|
Because I need to add WebBrowser support in the VCF. Currently I'm using ATL to do so, but I have been told that it's not usable on compilers like MINGW, because the ATL headers/libs are not re-distributable. So I need something else.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
|
Yeah I found that too. It looks like good wrapper for the basic COM stuff, but sadly they don't implement any of the OLE container junk you need to host activeX controls like IWebBrowser.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hi!
I need to write code, which convert series of images to animated gif.
Is some opensource solution for this problem?
Thanks.
|
|
|
|
|
finally, after 3 weeks and more than 2000 pages c & c++ books I write my project.
I should thanks for anybody who help me during this time and specially codeproject.
now I have two complete program:
1-ARRAY ADT
2-TEXT MANIPULATION
who want these project or for any sharing and testing;
vatanpoor@gmail.com
vatanpour@msn.com
Best Regards,
Pouya
|
|
|
|
|
I'm writing an application which will change the PCs IP settings (IP, gateway, DNS, etc)
Any pointers on how to do this? Thanks, mutty
|
|
|
|
|
I too have been looking in to it. And havent found any way... well except writing a kerner driver. So I use the "netsh" command. I think its available on all windows installations. You can change the IP for the current window session with the help of the IPHelper API (MSDN has examples of its use). But I guess you want to change it permanently.
This is how you would write to change the IP address.
netsh interface ip set address <connection> static <ip> <mask> <gateway> <gateway metric="">
Magnus
|
|
|
|
|
|
Hello there,
I'm having problems with displaying graphics - I use a timer to update a panel every few seconds, and CPU load increases linearly with run time of my little program.
It looks like this:
//Timer that triggers my paint panel:
public: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler( this, &Form1::panel1_Paint);
panel1->Invalidate();
}
//Paint panel
public: System::Void panel1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
e->Graphics->DrawImage(test, 1, 1);
}
There's probably something wrong with the way I call up panel1_Paint -- but it's the only way I could figure out from the Visual C++ help file..
Oh and it would be great if anybody knew how to call up panel1_Paint and have it not delete all things I previously painted on it.
Thanks in advance.
|
|
|
|
|
ruzu wrote: //Timer that triggers my paint panel:
public: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler( this, &Form1::panel1_Paint);
panel1->Invalidate();
}
Why do you subscribe to Paint (using the += operator) inside every timer tick? It should be sufficient to do this once, preferably in the constructor after the InitializeComponent method call.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
That would explain why the "CPU load increases linearly". If I understand the code properly each "+=" operation on the delegate adds another entry to the delegates list of functions to call. Looks like after running for a bit panel1_Paint is probably getting called god knows how many times (when once would suffice).
Steve
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN // no to MFC
///////////////////////////////////////////////////////////////////////////////////////////
// INCLUDE DIRECTIVES /////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <d3d9.h>
#pragma warning( disable : 4996 ) // disable deprecated warning
#include <strsafe.h>
#pragma warning( default : 4996 )
///////////////////////////////////////////////////////////////////////////////////////////
// DEFINES ////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// for D3D objects that don't have an explicit release function
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
// free up anything allocated with "new"
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
// anything allocated with new []
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
// The window caption.
#define WINDOW_CAPTION L"D3D Tutorial 01: CreateDevice"
// The window class.
#define WINDOW_CLASS L"D3D Tutorial"
///////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION PROTOTYPES ////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
HRESULT InitD3D( HWND hWnd );
VOID Cleanup();
VOID Render();
///////////////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
///////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION DEFINITIONS ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object, which is needed to create the D3DDevice.
if( ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) == NULL )
{
return E_FAIL;
}
// Set up the structure used to create the D3DDevice. Most parameters are
// zeroed out. We set Windowed to TRUE, since we want to do D3D in a
// window, and then set the SwapEffect to "discard", which is the most
// efficient method of presenting the back buffer to the display. And
// we request a back buffer format that matches the current desktop display
// format.
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the Direct3D device. Here we are using the default adapter (most
// systems only have one, unless they have multiple graphics hardware cards
// installed) and requesting the HAL (which is saying we want the hardware
// device rather than a software one). Software vertex processing is
// specified since we know it will work on all cards. On cards that support
// hardware vertex processing, though, we would see a big performance gain
// by specifying hardware vertex processing.
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
VOID Cleanup()
{
SAFE_RELEASE(g_pd3dDevice)
SAFE_RELEASE(g_pD3D)
}
VOID Render()
{
if( g_pd3dDevice == NULL )
{
return;
}
// Clear the backbuffer to a blue color
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Rendering of scene objects can happen here
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
Cleanup();
PostQuitMessage( 0 );
return 0;
case WM_PAINT:
Render();
ValidateRect( hWnd, NULL );
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_CLASSDC;
wc.lpfnWndProc = MsgProc;
wc.cbClsExtra = 0L;
wc.cbWndExtra = 0L;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = WINDOW_CLASS;
wc.hIconSm = NULL;
RegisterClassEx( &wc );
// Create the application's window
HWND hWnd = CreateWindow( WINDOW_CLASS, WINDOW_CAPTION,
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
NULL, NULL, wc.hInstance, NULL );
// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) )
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
while( TRUE )
{
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if ( msg.message == WM_QUIT )
{
break;
}
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
}
UnregisterClass( WINDOW_CLASS, wc.hInstance );
return 0;
}
IM PROUD TO BE A GMAIL;
|
|
|
|
|
How to determine how much data stored in pipe object without reading it with ReadFile, that is some equvalent that we are able to determine amount of bytes in internet windows socket to allocate buffer and read it all in one function call.
9ine
|
|
|
|
|