Advertisement Jump to content
Sign in to follow this  

How can I dispaly my map on half the screen

This topic is 4903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using "DIRECTDRAW" in windowed mode and I am trying to make a map editor. How can I draw my map only on part of the screen a display my tiles on the other part of the screen?

Share this post

Link to post
Share on other sites
check out the D3DVIEWPORT9
as i have not actually used direct draw i am not sure if this will solve your problem..

but basically the way i use it is to

D3DVIEWPORT9 m_viewPort;

m_viewPort.X = 10;
m_viewPort.Y = 10;
m_viewPort.Width = 500;
m_viewPort.Height = 300;
m_viewPort.MinZ = 0.0f; // i just use these
m_viewPort.MaxZ = 1.0f; //

m_device->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,D3DCOLOR_XRGB(50,50,200), 1.0f, 0); // clear the device backbuffer

m_device->SetViewport(&m_viewPort); // set the viewport to draw into

-then draw..
-then flip the buffer.. // when done with the view port
set a new viewport...
- repeat process

basically ..
you will draw your world map then draw the tile picker then draw every thing out side that....
you can get more info on viewports
on the sdk and here

Share this post

Link to post
Share on other sites
hi kingpinzs and MTclip,

I don't know directDraw, but I'm working on a editor too:D

I've realized that the popular tool "MilkShape 3D" has four separate windows on its main panel, so I decided to implement my tool with this style.

I use MFC, so I can split my main window into four subwindows easily by using CSplitterWnd class, and I set up a SWAP CHAIN to draw the individual view.

if your program could use swap chain, I think it will be more convenient to operate something in a exclusive view.

I hope this could be helpful.

about [swap chain]

Share this post

Link to post
Share on other sites
thanks for trying but that does not really help. Direct draw is differnt then using Direct3d.

Also I am not using mfc I code all win 32bit functions by hand so I know there is no extra stuff in my code and I know exactley what it all does and were it all belongs.

I just need a good tutorial on directdraw clippers if any one know were one is.

Thanks for trying. I do apertiate it. I am just looking for stuff that is out of date now so it is harder to find.

Share this post

Link to post
Share on other sites
hi there MTclip,

the following code demonstrates how to set up a window with four subwindows with winAPI, It seems quite like what you want.:)

And If I don't use Directx, say I use OpenGL, I should create four "RENDER-CONTEX"s for four subwindows, then I can draw the front view with the first "RENDER-CONTEX", and draw the top view with the second "RENDER-CONTEX", and so on.

I think there must be something similar to the "RENDER-CONTEX" in opengl or "DEVICE" in d3d, and it's "WINDOW-RELATED"(I don't konw what exactly it is :p), so you can create two subwindows in your program and create a "SOME-DXDRAW" object for each subwindow, then you can render what you want with them...

I use this method in my previous OpenGL-based program, and it really work well.

maybe there are some better way I don't know:)


#include "main.h"

HWND g_hWnd = NULL;

HRESULT CreateSubWindows();

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wndclass;
HWND hWnd;
MSG msg;

wndclass.cbSize = sizeof(wndclass); = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
wndclass.lpfnWndProc = MsgProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInst;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = g_szAppClass;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(RegisterClassEx(&wndclass) == 0)
return 0;

if (!(hWnd = CreateWindowEx(NULL, g_szAppClass,
"Main window",
GetSystemMetrics(SM_CXSCREEN)/2 ,
GetSystemMetrics(SM_CYSCREEN)/2 ,
380, 280, NULL, NULL, hInst, NULL)))
return 0;

g_hWnd = hWnd;
g_hInst = hInst;

while(GetMessage(&msg, NULL, 0, 0))

UnregisterClass(g_szAppClass, hInst);

return (int)msg.wParam;

switch(msg) {
case WM_KEYDOWN: {
switch (wParam) {
case VK_ESCAPE: {
PostMessage(hWnd, WM_CLOSE, 0, 0);
return 0;
} break;
} break;
case WM_DESTROY: {
return 1;
} break;

default: break;

return DefWindowProc(hWnd, msg, wParam, lParam);

* Create subwindows
HRESULT CreateSubWindows() {
HWND hWnd3D[4];
RECT rcWnd;
int x=0,y=0;

GetClientRect(g_hWnd, &rcWnd);

for (int i=0; i<4; i++) {
if ( (i==0) || (i==2) ) x = 10;
else x = rcWnd.right/2 + 10;

if ( (i==0) || (i==1) ) y = 10;
else y = rcWnd.bottom/2 + 10;

hWnd3D = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("static"),
x, y, rcWnd.right/2-20, rcWnd.bottom/2-20,
g_hWnd, NULL, g_hInst, NULL);

return S_OK;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!