#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddraw.h>
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 640
HWND global_hwnd = NULL;
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW4 lpdd4 = NULL;
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_CREATE:
{
return(0);
}break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return(0);
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}break;
default:break;
}
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
int Game_Init(int num_param = 0)
{
if(FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
{
return(0);
}
if(FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
{
return(0);
}
lpdd->Release();
lpdd = NULL;
lpdd4->SetCooperativeLevel(global_hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE |
DDSCL_ALLOWREBOOT | DDSCL_ALLOWMODEX);
if(FAILED(lpdd4->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8, 0, 0)))
{
return(0);
}
return(1);
}
int Game_Main(int num_param = 0)
{
if(KEYDOWN(VK_ESCAPE))
SendMessage(global_hwnd, WM_CLOSE, 0 , 0);
return(1);
}
void Game_ShutDown(int num_param = 0)
{
lpdd4->Release();
lpdd4 = NULL;
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
winclass.lpfnWndProc = WinProc;
winclass.hInstance = hinstance;
winclass.cbClsExtra = NULL;
winclass.cbWndExtra = NULL;
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
winclass.lpszClassName = "Winclass1";
winclass.lpszMenuName = NULL;
if(!(RegisterClassEx(&winclass)))
return(0);
if(!(hwnd = CreateWindowEx(NULL,
"Winclass1",
"My First Ecounter with DirectX!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0,0,
SCREEN_HEIGHT, SCREEN_WIDTH,
NULL,
NULL,
hinstance,
NULL)))
return(0);
Game_Init();
while(1)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Game_Main();
}
Game_ShutDown();
return(msg.wParam);
}
Set Display Mode()?
Why doesn''t this code make a *full* overlapped window pop up? The display mode and the screen size have the same variables.
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
The line MIGHT be this, I''m not sure:
WS_OVERLAPPEDWINDOW | WS_VISIBLE
At least when I do a window and then SetDisplayMode() with DirectX, I usually use WS_POPUP, not OVERLAPPEDWINDOW. Dunno if this is it at all, but give it a try, maybe.
WS_OVERLAPPEDWINDOW | WS_VISIBLE
At least when I do a window and then SetDisplayMode() with DirectX, I usually use WS_POPUP, not OVERLAPPEDWINDOW. Dunno if this is it at all, but give it a try, maybe.
Peon
I believe it is because when you initialize DirectX, it creates a layer over the window in fullscreen exclusive mode. It is just a speculation, I could be wrong.
When I use popup, same thing.
K I L A H M A N J A R O !
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
If I use numbers instead of #defines, it works...why?
K I L A H M A N J A R O !
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
Case closed
K I L A H M A N J A R O !
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
Your #define SCREEN_WIDTH is 480
Your #define SCREEN_HEIGHT is 640
I would be surprised if any card supports that
it should be 640 for width, 480 for height. Unless you mean by Case Closed you found out the problem?
______________________________________________
You know your game is in trouble when your AI says, in a calm, soothing voice, "I''m afraid I can''t let you do that, Dave"
Your #define SCREEN_HEIGHT is 640
I would be surprised if any card supports that
it should be 640 for width, 480 for height. Unless you mean by Case Closed you found out the problem?
______________________________________________
You know your game is in trouble when your AI says, in a calm, soothing voice, "I''m afraid I can''t let you do that, Dave"
Oh, thank you for that point. I didn''t notice that. That might be the problem because the blank part was on the right side of the screen. So, I think that was the problem. But, yes, Case Closed meant that I figured the problem out. Thanks!
K I L A H M A N J A R O !
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement