Advertisement

Side Scroller and DirectDraw Clipping ?

Started by July 31, 2000 11:22 AM
4 comments, last by Lenny 24 years, 5 months ago
I am working on a side scroller type game, and the view port is smaller than the surface of 640X480 so this gives me problems when the sprites scroll into view. I just need to make a clipper for the primary surface but, I can''t seem to get a direct draw clipper working to save my life I think my problem is in setting the clip list. can anyone show me how to fill out the Region Data and related stuff to set up a single clipper from 32,32 to 608,448.
here you go... its a code snip from my engine

    	//create then attach clipper	if(Error(m_cdraw->m_pdd->CreateClipper(0,&m_clipper,NULL),"Holly:CDrawSurface:Init(CDraw*,int,int):CreateClipper"))		return false;	LPRECT rect=new RECT;	rect->top=0;	rect->left=0;	rect->right=m_width;	rect->bottom=m_height;	//memset(&m_list,0,sizeof(RGNDATA)+sizeof(RECT)*2);	m_list.rdh.dwSize=sizeof(RGNDATAHEADER);	m_list.rdh.iType=RDH_RECTANGLES;	m_list.rdh.nCount=1;	m_list.rdh.nRgnSize=0;	m_list.rdh.rcBound=*rect;	memcpy(m_list.Buffer,rect,sizeof(RECT));	if(Error(m_clipper->SetClipList(&m_list,0),"Holly:CDrawSurface:Init(CDraw*,int,int):SetClipList"))		return false;		if(Error(m_surface->SetClipper(m_clipper),"Holly:CDrawSurface:Init(CDraw*,int,int):AttachClipper"))		return false;    


this should give you an idea how to do it... let me know if you need more explanation =)


Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
Advertisement
Hi there, I believe you cannot set a cliplist to a fullscreen aplication. So if your running fullscreen (Sounds like it, otherwise I''d just resize the window) you''ll have to make your own clipper function.

Correct me if I''m wrong, but I''m pretty sure you can''t put a cliplist on a fullscreen app. If you wan''t to see my clipper function, I can show the pseudo code (Or post assembly), or you guys can help me get the clip list working on my fullscreen app!

See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
OK, if you insist, I''ll correct you. A clipper needn''t be assigned to a primary surface in full screen mode, but it can be assigned to a back buffer, this is useful, since without it, if part of a bitmap is offscreen, the whole thing fails, unless you have a clipper.
Thanks for the help everyone, I did get the clipper working from the code snipet (with some mods to suit my needs). however it does not work on the primary surface, but thats ok.

Here is what I came up with, if anybody finds anything wrong with it, or if there is a better way please let me know.

Thanks again.
if (FAILED(lpdd4->CreateClipper(0,&lpddclipper,NULL)))
return(0);

LPRGNDATA m_list;
LPRECT rect=new RECT;

rect->top=0;
rect->left=32;
rect->right=608;
rect->bottom=480;

m_list = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+1*sizeof(RECT));
m_list->rdh.dwSize=sizeof(RGNDATAHEADER);
m_list->rdh.iType=RDH_RECTANGLES;
m_list->rdh.nCount=1;
m_list->rdh.nRgnSize=0;
m_list->rdh.rcBound=*rect;

memcpy(m_list->Buffer,rect,sizeof(RECT));

if(FAILED(lpddclipper->SetClipList(m_list,0)))
return(0);

if(FAILED(lpddsback->SetClipper(lpddclipper)))
return(0);

looks good to me =)

cyberben: yes you can use a clipper in fullscreen mode... I''ve never tried to attach one to the primary surface in fullscreen(whats the point?) but a clipper can attach to almost any surface... in my engine I''ve even got clippers on my off screen surfaces... it helps alot...

unlike in windowed mode you can''t just attach a HWND handle to the clipper you need to tell it exacly where to clip using a rects structure.



Great Milenko

Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."


http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech

The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."

This topic is closed to new replies.

Advertisement