Accessing a bitmap in DDRAW!

Started by
7 comments, last by arwez 23 years, 7 months ago
How do I access a bitmap and start manipulating bits or whatever?? What do pointers have to do with it and what are pointers??
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
"Your superior intellect is no match for our puny weapons!"
quote:Original post by arwez

...
what are pointers??


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

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

I know C very well, I just don''t know pointers Can someone plz post some code or something?
read the book.
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.
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 variablepointer = &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
main() {   ReadAManual();} 

This topic is closed to new replies.

Advertisement