Jump to content
  • Advertisement

Archived

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

djsteffey

create surface

This topic is 6412 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

  
//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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
It seems that you are not creating a back-buffer (I assume that''s what you want) but actually an off-screen plain.

ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;

This is simply a surface that''s not meant for displaying.
The only way to display such a surface would be copying its contents (blitting) to the front or preferrably back buffer.

The fact that you can draw pixels to the surface is normal; remember, off-screen surfaces are for manipulating and preparing display and after that you copy them to one of your (back)buffers.

You should create a back-buffer by simply setting the appropriate flag when you create your main surface; see the SDK.

Good luck!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!