• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

Guest Anonymous Poster

Drawing Lines in DirectDraw

6 posts in this topic

DirectDraw doesn't support line drawing... Check CGPP or preferably Abrash' black book of graphics programming for a really fast line drawing algorithm (it also has a fast one for antialiased lines)...

/Niels

0

Share this post


Link to post
Share on other sites
You can draw your own lines by plotting pixels on a surface. I can dig up some functions if you need them, but at least 3 books I've seen on DirectX go into this.
0

Share this post


Link to post
Share on other sites
Well. You want to draw lines.
And you have access to D3DIM?

Use DrawPrimitive with the LINE function.

If you dont have the D3DIM ( which you should have, its very simple to do lines with it ) , you either lock the surface
down and pixel it. Or you use the the GDI.

Locking the surface down and using a line
drawing routine would be the best if you
dont use D3DIM.

0

Share this post


Link to post
Share on other sites
Well, I hope this helps some. It just draws a straight vertical line. Pretty uselesse, but its just a few lines of code away from what you want

//--------------------------------------------------------------------------------------------
// Draw_VLine()
//--------------------------------------------------------------------------------------------
BOOL Draw_VLine( LPDIRECTDRAWSURFACE4 lpDDSTemp, int x, int y, int y2, WORD rgbColor )
{
int index;
WORD *wPixels;
DDSURFACEDESC2 ddsd;

ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );

if ( FAILED (lpDDSTemp->Lock( NULL, &ddsd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL ) ) )
return Error( "> Error: Couldn't lock the Temp surface.\n> Function: Draw_Pixel().\n", DEBUG );

wPixels = ( WORD * )ddsd.lpSurface;

for ( index = 0; index <= ( y2 - y ); index++ )
wPixels[( y + index ) * ( ddsd.lPitch >> 1 ) + x] = rgbColor;

if ( FAILED (lpDDSTemp->Unlock( NULL ) ) )
return Error( "> Error: Couldn't unlock the Temp surface.\n> Function: Draw_Pixel().\n", DEBUG );

return TRUE;
}

------------------
- mallen22@concentric.net
- http://members.tripod.com/mxf_entertainment/

0

Share this post


Link to post
Share on other sites
Here's some more! line drawing routines. Even though these are not written in
assembly, they might actually be faster than ones written in assembly if
you have VC++6.0 and optimizations turned on.

Don't ask me why this is faster, I guess MSVC++ can write better
assembly than me.

The locking/unlocking of the surface is done outside the function, so
you can use them several times if you need to draw more than one line, like
a rectangle. surface_buffer is your pointer to the DD surface. Oh yeah,
these were written for 16-bit color.

But, if you want to speed it up even more, just move everything
into one function.

code:

//
// Draw a horizontal line (dy=0) from left to right.
//
void
Draw_Primitive_HLine_No_Clip(INT width, WORD color, WORD *surface_buffer) {

while(width--) {

// set the color and advance one pixel
*surface_buffer++ = color;
}
}


code:

//
// Draw a vertical line (dx=0) from top to bottom.
//
void
Draw_Primitive_VLine_No_Clip(INT height, WORD color, WORD *surface_buffer, DWORD pitch) {

while(height--) {

// set the pixel
*surface_buffer = color;

// move to the next scanline pixel
surface_buffer += pitch;
}
}



Reaver

[This message has been edited by Reaver (edited November 05, 1999).]

0

Share this post


Link to post
Share on other sites
Personally, I wouldn't trust the VC optimizer, I got a double up in speed by handcoding a few inner loops (compared to optimized C++), and I'm NOT a Ix86 ASM wizard.

And I still recommend reading Abrash' black book - He starts out with plain Bresenhams line drawing, covers "run-length slice drawing", and ends up antialiasing it... Check it out - that book can not be recommended enough !

/Niels

0

Share this post


Link to post
Share on other sites
Hello everybody. I have a teensy little
question.

In DirectDraw I am writing a dodgy asteroids
clone. Now what I need is the ability to
draw straight lines, even quickly if possible.

Does Direct-X supply primitives?
How else could I do it? GDI?

I have little windows programming experience,
but if it's there's no quick way availble I
can always do a port of my DOS code.

0

Share this post


Link to post
Share on other sites