Skip to main content
gamedev.net
🔒 Locked

create surface

Started by djsteffey Nov 29, 2000 at 9:58 PM 6 replies 350+ views
Original Post
djsteffey
djsteffey
  
//mainDD is the DirectDraw4 object

// surface is a LPDIRECTDRAWSURFACE4 surface

// w and h are variable width and height


    DDSURFACEDESC2 ddsd;
    ZeroMemory(&ddsd, sizeof(ddsd));
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    ddsd.dwWidth = w;
    ddsd.dwHeight = h;
    if (mainDD->CreateSurface(&ddsd, &surface, NULL) != DD_OK)
		return false;
	return true;
  
what is wrong with this. It returns true (this is in a function) that the surface was created. But then I go to lock the surface and draw pixels to the surface, that doesnt give me any errors. Then i go to draw the surface and that doesnt give me any errors.......but nothing is ever showed on the screen !!! I draw to the backbuffer then i flip the backbuffer and the primary surface to show it on screen. I know the pixel drawing routines work b/c i tried them on the backsurface directly and they work fine. It just doesnt work when i create a surface like this. Any help is appreciated "Now go away or I shall taunt you a second time" - Monty Python and the Holy Grail themGames Productions
ChMar
ChMar
Maybe your surface must have the same format as the back surface.
Hope this help
ChMar
ChMar
Sven Vermeulen
Sven Vermeulen
(Whoops sorry... doubleposted. The above anonymous answer was mine.)

Edited by - Sven Vermeulen on November 30, 2000 7:03:10 AM
djsteffey
djsteffey
i am not trying to create the backbuffer. I have already done this. What i am trying to do is create a surface of a specified size and then load the image from my own custom image file format. My file format contains the width, height, pixel data and various other pieces of info. So i want to create the blank surface according to the w and h and then load my data onto the imgae. I know the loading is correct, b/c i can load it directly to the back buffer and flip and see it. That is why i know the loading works.
chMar---what do you mean by same format ? Same pixel format or seomthing. Doesnt the directDraw object take care of that when you create the surface. Or what do you mean ?


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Sven Vermeulen
Sven Vermeulen
OK, misunderstood you...
So say you''ve written al your pixels to the off-screen plain, what else do you do in order to actually display it on-screen ??
djsteffey
djsteffey
i then treat it the same way that i do a surface that was created out of a bmp. I use the DDutil file to create a surface from a bmp file. All that works fin and it gets displayed fine and I have been using it for a while now. So after i create the blank surface and put my pixels on it, try to display it using the same functions that display my surfaces created out of bmps from the DDUtil file.......it just doesnt show up. Could it be something with the color keying ? I always clear my screen to 0, 0, 0 when i clear the back buffer. Could it be that the color keying on my new surface is messed up where any 0, 0, 0 pixels gets written over it ?

"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Prosper/LOADED
Prosper/LOADED
To avoid color-keying problems, use the DDBLTFAST_NOCOLORKEY flag (or DDBLT_NOCOLORKEY) when you blit to the backsurface.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.