Archived

This topic is now archived and is closed to further replies.

TheNerd Tk421

I feel quite stupid asking this...

Recommended Posts

TheNerd Tk421    122
...But how do i get a picture..backing up...i had made a blank windows app... i wanna know how i could add a background picture to it..heres the code: #include <windows.h> #define WIN32_LEAN_AND_MEAN #define WINDOWNAME "My soon to be game" HWND hWnd; LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); } int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int Cmd) { MSG msg; WNDCLASS wClass; wClass.style =CS_HREDRAW|CS_VREDRAW; wClass.lpfnWndProc =WindowProcedure; wClass.cbClsExtra =0; wClass.cbWndExtra =0; wClass.hInstance =hInstance; wClass.hIcon =LoadIcon(hInstance,IDI_APPLICATION); wClass.hCursor =LoadCursor(NULL,IDC_ARROW); wClass.hbrBackground =(HBRUSH)(COLOR_WINDOW-2); wClass.lpszMenuName =NULL ; wClass.lpszClassName =WINDOWNAME; RegisterClass(&wClass); hWnd = CreateWindow(WINDOWNAME, WINDOWNAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if(hWnd==NULL) return FALSE; else { ShowWindow (hWnd, Cmd); UpdateWindow(hWnd); } while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage (&msg); } return msg.wParam; } .... i want to have an image instead of (HBRUSH)(COLOR_WINDOW-2).. i like blue.. but if i make a game.. it wont be fun as it is

Share this post


Link to post
Share on other sites
vaneger    100
if you''re trying to makea game read up on directX. that is waht every one uses for graphics in games, not windows dialog boxes.....

Share this post


Link to post
Share on other sites
UltimaX    468
quote:
Original post by headshot
ya, but does opengl do 2d as well as 3d?


Ummm Yes! It's called an orthographic projection matrix. How do you think HUD's, GUI, Fonts, etc are made?

BTW:
>>that is waht every one uses for graphics in games<<
That is kinda of a broad statement isn't it? Look at the NeHe and NeXe forum topics and see which one is more "active." That alone tells me that not "everyone" is using Direct3D for graphics.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

[edited by - UltimaX on August 6, 2003 9:52:24 PM]

Share this post


Link to post
Share on other sites
cowsarenotevil    3005
quote:
Original post by TheNerd Tk421
every time i even look at ne directX code.. its just ...it looks like it will take for ever like a while b4 i get close to learning most of it


Then try opengl and see if you like it''s style more.

Share this post


Link to post
Share on other sites
Yes, DX code can be a little difficult to understand at first. For example, I am not that great with DX, but I am pretty good with math, logic, and game ideas in general. So once I got over the hurdle of understanding DX, which did take a while, and I still have DX related problems here and there, I was finally able to start working on my engine and actually be productive in making computer games.

So what does this all mean? Well, if you want to learn DX to make games, be prepared for a long journey. Game programming takes a long time, and a lot of time out of your day. I personally believe we will see a rise of more powerful game engines/templates/creators in the near future to help eliminate some of learning time.

If you don''t care to learn DX, and just want to make games without learning the itty bitty parts of DX, then you may be better off getting a good engine and working with that.


--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
TheNerd Tk421    122
I dont really want to jump in and make a game that does everything... i have troubles with creating basic basic basic text rpgs..i wanted to know how to get pictures on the screen of my comp..then i will go into it further.. i want to learn DX... but cant find any good tutorials... especialy ne that work with the compiler i have

Share this post


Link to post
Share on other sites
Raloth    379
There were some good tutorials up at www.andypike.com, but the site has been taken down. I believe it''s still in google''s cache so you can do a search for it and view it that way . Now, if you want to stick to just windows programming for now, then head on over to www.gametutorials.com and look at their Win32 section. It will show you how to create an HDC for your bitmap and blit it to the screen. It''s quite simple once you get it working.

Oh yeah... Whoever thought everyone uses DirectX, maybe you haven''t heard of the Quake games...

Share this post


Link to post
Share on other sites
Yog    122
http://www.gametutorials.com/Tutorials/win32/Win32_Pg3.htm

The second tutorials is loading a bitmap as the background

Share this post


Link to post
Share on other sites
TheNerd Tk421    122
Help me plz...
my source code:
<textarea ROWS=6 COLS=40>
#include <windows.h>


LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{

HWND hwnd;
MSG msg;
WNDCLASSEX wndclassex = {0};

char class_name[] = "My Game";


wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = WinProc;
wndclassex.hInstance = hinstance;
wndclassex.hIcon = LoadIcon(hinstance,IDI_APPLICATION);
wndclassex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclassex.lpszClassName = class_name;

RegisterClassEx(&wndclassex);


hwnd = CreateWindowEx(NULL,
class_name,
"My Game",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,

CW_USEDEFAULT,

450,
325,
NULL,
NULL,
hinstance,
NULL);

if(!hwnd)
{
UnregisterClass(class_name,hinstance);
return EXIT_FAILURE;
}


ShowWindow(hwnd, ishow);
UpdateWindow(hwnd);





HBITMAP hbitmap = (HBITMAP)LoadImage(hinstance,"ent.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

HDC hdc = GetDC(hwnd);
HDC image_dc = CreateCompatibleDC(hdc);



HBITMAP old_hbitmap = (HBITMAP)SelectObject(image_dc,hbitmap);



BitBlt(hdc,50,50,320,192,image_dc,0,0,SRCCOPY);





while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;

TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{


}

}


SelectObject(image_dc,old_hbitmap);

DeleteObject(hbitmap);
ReleaseDC(hwnd, hdc);

DeleteDC(image_dc);


UnregisterClass(class_name,hinstance);

return msg.wParam;
}



LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;

switch(message)
{

case WM_PAINT:
BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;


case WM_CLOSE:
case WM_DESTROY:

PostQuitMessage(0);
return 0;

}

return(DefWindowProc(hwnd, message, wparam, lparam));
}





</textarea>

when i try to compile it i get errors...
<textarea ROWS=6 COLS=40>
40 c:\windows\desktop\aotnsite\win_main.cpp
warning: converting NULL to non-pointer type
.......
45 c:\windows\desktop\aotnsite\win_main.cpp
`EXIT_FAILURE' undeclared (first use this function)
.......
45 c:\windows\desktop\aotnsite\win_main.cpp
(Each undeclared identifier is reported only once
.......
45 c:\windows\desktop\aotnsite\win_main.cpp
for each function it appears in.)
</textarea>
those lines have:
40: NULL);
45:return EXIT_FAILURE;
...........................
why wont it compile?



[edited by - TheNerd Tk421 on August 7, 2003 12:23:45 PM]

Share this post


Link to post
Share on other sites
Raptor85    180
www.destiny3d.com
www.genesis3d.com

www.siigna.net/raptor85 (my site)
www.geocities.com/nickanton7 (my old site, has a genesis3d tutorial i wrote, i think it''s still up)

www.genesis3d.com/~wog/

Share this post


Link to post
Share on other sites
cowsarenotevil    3005
quote:
Original post by Village Specialton
OpenGL is a lot easier and used more often. Go OpenGL!

Scott Simontis
Big Joke: C#


Ummm.In games Direct3D is generally used more often, and neither is really easier, it''s just the difference between C/C++.

Share this post


Link to post
Share on other sites
TempusElf    186
If this is your first game and it isn''t going to involve a lot of objects on the screen at one time, I would recommend using the Win32 GDI...

Lots of people are going to tell you to stay clear of GDI because it wasn''t meant for making games. This argument is extremely valid... however, it''s been my expirience that for small and simple 2d games, the GDI works great

GDI references:

WinProg.org
MSDN

Share this post


Link to post
Share on other sites
TempusElf    186
quote:
Original post by TheNerd Tk421
40: NULL);



I have no idea why it''s giving you this error... but I''m looking at my source code and notice that I always put HWND_DESKTOP where you put the first NULL in that function call.. I don''t think this will help at all but it''s worth a try

quote:

45:return EXIT_FAILURE;



EXIT_FAILURE is not defined... try just returning 0.. I don''t think it will hurt... much

Share this post


Link to post
Share on other sites
boysket    122
go to http://lonecoyote.home.mindspring.com/win32programming_01.html
so you can see the structure of the:

typedef struct __WNDCLASSEX
{
...;
}WNDCLASSEX;

There are a few fields that you have not defined ... try filling them in, they may not be any defaults set for these fields so set values for all of them.

View the world as i create it

[edited by - boysket on August 8, 2003 6:09:42 PM]

Share this post


Link to post
Share on other sites
remi    150
Since you've posted in the beginner forum and are just trying to draw a background picture in your program, i would rather advice you to have a look to GDI, it's quite simple and easy to use, not so fast but it has all u need!

Why? It's incorporated to windows, so no need to had other libs or include files instead of what you need to make a windows program! And it's much more easy to use than DirectDraw,Direct3D,OpenGL,... It's a really good place to start!

This is one of the games i made with it!

[edited by - remi on August 9, 2003 5:42:31 AM]

Share this post


Link to post
Share on other sites