• 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.

Gabriel

DDraw

9 posts in this topic

I have heard from numerous people that to blend 2 surfaces, you just add increased /decreased values together. Well, I did that to get a crude alpha blending function. the only thing that''s wrong is that it does half the screen. here''s the func: void TransAlpha( LPDIRECTDRAWSURFACE7 dest) { BYTE* lpSurf; BYTE* lpDest; DDSURFACEDESC2 srcDDSD, destDDSD; RECT rect; rect.top = 0; rect.left = 0; rect.right = 319; rect.bottom = 239; // Lock down both surfaces for read and write ZeroMemory(&srcDDSD, sizeof(srcDDSD)); srcDDSD.dwSize = sizeof(srcDDSD); g_pDDSPrimary->Lock(&rect, &srcDDSD, DDLOCK_WAIT, NULL); ZeroMemory(&destDDSD, sizeof(destDDSD)); destDDSD.dwSize = sizeof(destDDSD); dest->Lock(&rect, &destDDSD, DDLOCK_WAIT, NULL); // Initialize the pointers to the upper left hand corner of surface lpSurf = (BYTE*)srcDDSD.lpSurface; lpDest = (BYTE*)destDDSD.lpSurface; for(double ALPHA = 1.0; ALPHA > 0.0; ALPHA -=0.05) { for (int y = 0; y != 239; y++) { for (int x = 0; x != 319; x++) { lpSurf[x + srcDDSD.lPitch * y] = lpSurf[x + srcDDSD.lPitch * y] * ALPHA + lpDest[x + destDDSD.lPitch * y] * (1-ALPHA); } } } dest->Unlock(&rect); g_pDDSPrimary->Unlock(&rect); } I heard that the solution was to make the surface pointers a WORD instead of a BYTE, so I did so: WORD lpSurf; WORD lpDest; lpSurf = (WORD*)srcDDSD.lpSurface; lpDest = (WORD*)destDDSD.lpSurface; now it does the whole screen, but skips lines. why???
0

Share this post


Link to post
Share on other sites
1) If you''re using 16bit surfaces, divide the pitch by 2.
pitch = srcDDSD.lPitch >> 1;
Your pointers have to be WORD*

2) If you''re using 32bit surfaces, divide the pitch by 4.
pitch = srcDDSD.lPitch >> 2;
Your pointers have to be DWORD*


--Shannon Schlomer, BLAZE Technologies, Inc.
0

Share this post


Link to post
Share on other sites
Does anyone know whether the pitch is ever an odd number in 16-bit mode, on any video card? Seems this would break the code, which is why I''ve never divided the pitch, preferring to get around the problem another way. There is a small performance gain from dividing the pitch, but can we assume that it''s safe to do so?

Regards

Starfall
0

Share this post


Link to post
Share on other sites
According to the SDK, the pitch has to be a QWORD (8byte) multiple.

--Shannon Schlomer, BLAZE Technologies, Inc.
0

Share this post


Link to post
Share on other sites
I''ve only seen the need for DWORD pitch. (At least, DWord has always worked for ME)



Josh J
0

Share this post


Link to post
Share on other sites
I think 16 bit and 32 bit modes are alligned (allways start at a 16 or 32 multiple addresses (2 or 4 multiples, in terms of address values)) wich would implicate non-odd pitch numbers (each address has allways an even number of bytes between them)
As allways, should anyone know that i''m wrong in any way, may they write now or allow us to write bugged programs for ever.
0

Share this post


Link to post
Share on other sites
Interesting. I guess the best thing to do if you are going to divide the pitch, is write a bit of code in your startup routine to check that the pitch of the primary surface is aligned, and if not drop the user out with a message. Of course, you''d want to be reasonably sure that it wasn''t going to happen on 99.9% of video cards, but it''d probably be a better thing than attempting to run the game like that.

Regards

Starfall
0

Share this post


Link to post
Share on other sites
You''re probably right. But anyway, if someone knows wether words or dwords can not be alligned, or are allways alligned, (by the way, when you cast a byte * to a dword * in C, does it return a aligned pointer?)
please let the unilluminated know.
0

Share this post


Link to post
Share on other sites
by the way, when you cast a byte * to a dword * in C, does it return a aligned pointer?

No, it only returns an aligned pointer if the byte pointer was aligned to whatever alignment you are talking about (4 byte I assume). The reason is that it still has to point to exactly the same spot as the byte, be it aligned or not.

Regards

Starfall
0

Share this post


Link to post
Share on other sites
Ok, thanks (I had a suspition it would work that way, but it''s better to be sure)
Well the main question still stands; does DirectDraw (or graphics boards) keep they dword and word alligned?
0

Share this post


Link to post
Share on other sites