Newby questions

Started by
5 comments, last by Kiroke 22 years, 4 months ago
Hi all. ive read Tutorial 1 to 8 and i just tried to really go line by line on the code of tutorial 7. I dont wanna copy code and i like to really understand the things im doing so i got a couple of questions for u guys out there:-) 1-first of, i really dont know whats a rendring context and a device context. Id appreciate if u could extend the information given by the tutorial 2-Second, theres a line i REALLY dont understand here memset (TextureImage, 0, sizeof(void *)*1); i know what sizeof do but the * i cant understand thats all for now thx for u help Kiroke
Kirokewww.geocities.com/kiroke2
Advertisement
quote:Original post by Kiroke
1-First, I really don't know what a rendering context or a device context area is. I'd appreciate it if you could extend the information given by the tutorial.

They're part of the Win32 API (not OpenGL). Just think of them as the way OpenGL is attached to a window in Windows.

quote:Original post by Kiroke
memset(TextureImage, 0, sizeof(void *)*1);

That says to fill the memory at TextureImage that is "size(void *) times 1" bytes with zeros. If it actually said "*i" and you made a typo in that code, it means to fill the memory at TextureImage that is "size(void *) times i" bytes with zeros.

Edit: I made a typo in the word typo, how fitting .

[Resist Windows XP's Invasive Production Activation Technology!]

Edited by - Null and Void on December 14, 2001 12:23:18 AM
well thx alot
Kirokewww.geocities.com/kiroke2
Null And Void, my friend, here is the exact line of code from the tut:

memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL

I think what it's basicly saying is that it's filling TextureImage from 1 to the size of a void pointer with 0. Hmmm... I guess the size of a void pointer is probably one. here's the part of the code that I base myself upon...

    AUX_RGBImageRec *TextureImage[1];					// Create Storage Space For The Texturememset(TextureImage,0,sizeof(void *)*1);				// Set The Pointer To NULL    


He's actually creating space for 2 pointers to AUX_RGBImageRec. And then voiding them with the memset....

Null And Void: think you could try and clear this up for me also, I seem to be a little confused. Although I'm able to follow the code and get the basic idea, I have to agree with Kiroke, that part of the code leads to confusion. why didn't he simply do

TextureImage[0] = NULL;
TextureImage[1] = NULL;

wouldn't that be as simple as doing a memset like he did or do you need to initialise these AUX_RGBImageRec to 0s???


"And that's the bottom line cause I said so!"

** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM **

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP's Invasive Production Activation Technology!

"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com

Edited by - cyberdrek on December 14, 2001 12:57:39 AM
[Cyberdrek | ]
There is a small but important difference between the memset and = NULL.
If you memset, you make the memory that the pointer is pointing to equal 0(Or NULL if you''d like), but if you use = NULL, you point the pointer to NULL, or 0. The first way, you clear the contents of the pointer, the second way, you point it to another space-area(which you can''t edit btw)...
Also, you only create a single member of this array, not 2 - you only create TextureImage[0], a TextureImage[1] doesn''t exist.

ERJO
wow!

Thx alot for ur help ill get back with other questions when i will have the time

Kiroke
Kirokewww.geocities.com/kiroke2
quote:Original post by Cyberdrek
...I guess the size of a void pointer is probably one.

All pointers are the same size - the size of a memory address. Under Windows and most OSes today, that''s 32-bits (4 bytes). Since sizeof returns size in bytes, sizeof(void *) returns 4. the "* 1" is redundant.

quote:Original post by erjo
There is a small but important difference between the memset and = NULL.
If you memset, you make the memory that the pointer is pointing to equal 0(Or NULL if you''d like), but if you use = NULL, you point the pointer to NULL, or 0. The first way, you clear the contents of the pointer, the second way, you point it to another space-area(which you can''t edit btw)...

I disagree. While your description of memset itself is accurate, the object being operated on is the pointer. We memset the pointer to zero, which is the same as setting to NULL. However, if we were to dereference the pointer then we''d have the difference you speak of.

quote:Also, you only create a single member of this array, not 2 - you only create TextureImage[0], a TextureImage[1] doesn''t exist.

Definitely agree with this. Always remember, people, C/C++ use zero-based subscripts when accessing, but 1-based notation when declaring.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement