Jump to content
  • Advertisement

Archived

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

arwez

Accessing a bitmap in DDRAW!

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

How do I access a bitmap and start manipulating bits or whatever?? What do pointers have to do with it and what are pointers??

Share this post


Link to post
Share on other sites
Advertisement
Do you mean that you need to know how to manipulate a bitmap that''s already on a DirectDraw surface, or do you need to know how to get that bitmap onto the surface in the first place?

A pointer is simply a variable that holds an address in memory. There are all sorts of uses for pointers, but now that I think about it, I''m not sure I could explain the notation and such too well. I think I''ll just leave that one for someone else.

-Ironblayde
 Aeon Software

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by baskuenen


No disrespect, but it may be better to learn C and C++ first...



I''d have to second this. An explanation of the way to do it, without knowing HOW to do it, would only confuse you further.

Read thisTeach Yourself C++ in 21 days. It''s a good start. Then read the help file that came with the Directx SDK(If that''s the SDK that you''re using). I''ve learned alot by fiddling around with the tutorial code that accompanied it. But there''s still ALOT I have to learn...And I do mean ALOT

Share this post


Link to post
Share on other sites
I know C very well, I just don''t know pointers Can someone plz post some code or something?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
OH and btw, that link up there is to the actual book. The whole book is on the website(No need to purchase it). It has a chapter on pointers and another chapter on references...That''s basically how I learned about pointers.

Share this post


Link to post
Share on other sites
Read the book. But here is a quick explanation of pointers. In 32 bit flat memory model, pointers are basically unsigned long variables. You use them to get indirect access to variables. Pointers to primitive built-in types are as follows:
    
int *pointer; // THis is how you declare a pointer.

int value = 6; // Normal variable


pointer = &value; // The & operator gets the memory address

//value for a variable. Because I have done this, the pointer
//now points at value.

printf("The value is %d, the address of the value is %p, the value of the pointer is %p, and what the pointer points to is %d", value, &value, pointer, *pointer);

[/source]

The * operator in the printf function ''dereferences'' the pointer. This means it gets the value at the address in the variable.
So basically the output of this pseudocode would be:
The value is 6, the address of the value is 0x7AB56, the value o the pointer is 0x7AB56 and what the pointer points to is 6.

THe address may not be 0x7AB56, but the important thing is that the two addresses printed are the same.
That is some basic pointer stuff.
An array is actually a pointer to the base of the array. The [] operator adds the number between the []''s multiplied by the size of the type to the pointers address, accessing that part of the array. Adding numbers to pointers adds to the address in the pointer the size of the type multiplied by the number. So:
[source]
int array[4] = {1,2,3,4};
int *pointer;

pointer = array;

// so pointer+3 = 3, and array[3] both equal 3, and pointer[3]
// and array+3 both equal 3.

[/source]

You can also have a pointer to a struct, or other derived data type:
[source]
typedef struct foo_tag
{
int badz1;
long batty;
float for_real;
}foo;
foo *pointer;
foo demz;
demz.badz1 = 2;
demz.batty = 5;
demz.for_real = 5.3;
pointer = &demz;

// You now have two ways to dereference this, but one way is
// easier to follow when things get more complex:

(*pointer).for_real = 5.1;
pointer->badz1 = 9;

Pointers can also be used for dynamic memory allocation, and you can have function pointers, which enable you to pass a function as a parameter to another function which then calls the function you passed. Cool.


------------------------------
#pragma twice

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!