🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Creating a WINDOW !!

Started by
20 comments, last by Metal Typhoon 22 years, 12 months ago
OpenGL can be a lot easier when you first start because of the glut library - it will automatically create windows, switch screen modes, etc.

To answer the question... you create a window, and then ''put'' DX or GL to it.
Remember - Hard work pays off in the long run, but laziness pays off immediately.
Advertisement
If you use GLUT, you don''t have to worry about any window code.
It takes care of all that for you. You just have to supply the
OGL code. If you do know C++ and you want to learn windows, I
really suggest that you go out and purchase a book. Tricks of
the Windows Game Programming Gurus by Andre LaMothe would be
excellent for you. It was my first book and I see it being a
useful reference years down the road. It is well worth the $50.
Well... here is the code to simply initialize,create, and display a window that outputs the text "waaaaaaaaaaaaazup" using MFC and vc++ 6.0; make sure you check settings to: Use mfc in a shared dll , under project|settings menu; I definately suggest you buy a book there is alot of stuff to programming windows and you will need to apply a good deal of it programming games.

// hello.h

class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};

class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();

protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
/////////////////////////////////////////////////////////////////

// hello.cpp

#include
#include "Hello.h"

CMyApp myApp;

BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()

CMainWindow::CMainWindow ()
{
Create (NULL, _T ("waaaaaaaaazup"));
}

void CMainWindow::OnPaint ()
{
CPaintDC dc (this);

CRect rect;
GetClientRect (▭);

dc.DrawText (_T ("Hello, MFC"), -1, ▭,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
minizap, you're stupid.

he said he knows the basics of C++, c++ has nothing to do with creating a window you fool. What are you some microsft lover that thinks ooh microsoft is the only OS so therefore creating a window must be a known thing?

[Now now, let's all play nice together -- deadlinegrunt*]

ok.. anyway.

If you're willing to spend some money. There is a huge ass book called Programming Windows by Charles Petzold, contains almost everything in the win32api.


CrappySoft - game production team with a punk attitude. Mail me if you want to make levels, art etc.

*Personally I see both yours and minizips points. Content edited regardless...


Edited by - deadlinegrunt on June 30, 2001 4:21:55 AM
CrappySoft - game production team with a punk attitude. Mail me if you want to make levels, art etc.
I was looking forward those two books, The programming window , the definiti guide to win32 API is 55 dollars and The Tricks of
the Windows Game Programming Gurus is 45. If i get those book will it get me started in windows programming ?

"The shortcut is not always the best way "

Metal Typhoon
Metal Typhoon
I've got Tricks of the Windows Game Programming Gurus and Programming Windows, and I've found them both to be excellent books.

Tricks has just a few chapters on strictly windows programming, before it delves in DirectX 6.1. It's a somewhat accelerated, streamlined introduction to windows programming: it doesn't tell you everything you'll need to know, just enough to get started. I found it very useful to be able to get windows progs up and running quickly. But then I reached a point where I wanted to do more.

So I got Programming Windows. That book, combined with the MSDN, shows you how to do pretty much anything that can be done in windows.

Both those books are excellent for teaching the windows api, but the best reference is simply the MSDN.

=======================================
Matt Welch

"What sounds to you like a big bloat of trashy old noise
is in fact the brilliant music of a genius--myself" ~ Iggy Pop

Edited by - the Dealy Lama on June 30, 2001 11:02:34 AM
=======================================Matt Welch"What sounds to you like a big bloat of trashy old noiseis in fact the brilliant music of a genius--myself" ~ Iggy Pop
Hi...

well, I gues that if you want to programm videogames with a basic knowledge od C++ you''re gonna have problems.... really

I really prefer programing on Linux-gtk, MUCH MUCH easyer than on windows , and you use about 10 lines of code to create a window ( vs 70 from windows)

how ever... I strongly recommend you "tricks of the Windows game programming gurus" to get started on windows game programing =)

nice day

jakovo
If your using c++ then you will probably want to buy PROGRAMMING WINDOWS WITH MFC by prosise as it is the oop implementation of the windows API. All mfc is is just an object oriented wrapper around the windows api. If you dont want to learn mfc then go ahead with petzold''s book. And if you dont have the money to buy either one then have fun searching the net for endless hours trying to find everything you need.
Well If you have MSVC then you have one of the greatest resources a windows programmer can have. That MSDN library disk covers almost every window''s api function. One quick search and I can find just about anything about Windows Programming. Also the extra articles included are priceless because sometimes the Microsoft technical references can sound like gibberish.

-Good luck
Thought I'd go ahead and post some simple junk:


// Includes
#define WIN32_LEAN_AND_MEAN

#include windows.h
#include stdlib.h
#include stdio.h
#include time.h
#include math.h


LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam );

// WinMain

HWND mWnd;

int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int iCmdShow )
{
WNDCLASS wc; HWND hWnd; HDC hDC; HGLRC hRC; MSG msg;
BOOL bQuit = FALSE;

// register window class
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_ICON1);
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "MyWindow";
RegisterClass( &wc );

hWnd = CreateWindowEx(NULL, "MyWindow", "MyWindow", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL);

// Display the window
ShowWindow(hWnd,SW_SHOW);
UpdateWindow(hWnd);

mWnd = hWnd;

// program main loop
while ( !bQuit ) {

// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {

// handle or dispatch messages
if ( msg.message == WM_QUIT ) {
bQuit = TRUE;
} else {
TranslateMessage( &msg );
DispatchMessage( &msg );
}

} else {


}

}

// destroy the window explicitly
DestroyWindow( hWnd );

return msg.wParam;

}

// Window Procedure

LRESULT CALLBACK
WndProc( HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam )
{

switch ( message ) {

case WM_CREATE:
return 0;

case WM_CLOSE:
PostQuitMessage( 0 );
return 0;

case WM_DESTROY:
return 0;

case WM_KEYDOWN:
switch ( wParam ) {

case VK_ESCAPE:
PostQuitMessage( 0 );
return 0;

}
return 0;

default:
return DefWindowProc( hWnd,
message, wParam, lParam );

}

}







Edited by - Scooter on June 30, 2001 9:28:52 PM
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.

This topic is closed to new replies.

Advertisement