|
I'm sorry...
thanks !
|
|
|
|
|
No problem.
|
|
|
|
|
Hi guys, i try to write my data into a binary file, but j have some problem in it . I dont know what happening inside..
class Person{
char Name[50];
char Address[10;
bool sex;
short age;
public:
Person();
Person(char* name, char *address, bool sex, short age);
const char* GetName() const;
const char* GetAddress() const;
};
ostream& operator<<(ostream& out, const Person&p)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(p));
return out;
}
istream& operator>>(istream& in, Person &p)
{
in.read(reinterpret_cast<char*>(&p), sizeof(p));
return in;
}
class Account_Property{
int account_number;
double amount;
bool account_type;
Person p;
public:
Account_Property();
Account_Property(Person p, int ac_num, bool ac_type, double amt);
int GetAccountNumber()const;
double GetAmount()const;
};
ostream &operator<<(ostream &out, const Account_Property &ap)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(ap));
return out;
}
istream& operator>>(istream &in, Account_Property &ap)
{
in.read(reinterpret_cast<char*>(&ap), sizeof(ap));
return in;
}
Thanks in Advance
|
|
|
|
|
Your problem is with
sizeof const Person& which should give the size of the reference and not the object.
Change
sizeof(p) to
sizeof(Person) etc.
|
|
|
|
|
Can you edit your article text to show symbols rather than XML entities?
I think Niklas is correct but it's rather hard to read!
|
|
|
|
|
I wrote a program that renders up to 200 characters that move across the screen at an 8 o'clock heading, isometric game style. I randomize each character's x and y coordinates and speed prior to rendering, which are rendered onto transparent quads. Since every object's z coordinate value is the same, the object rendered last is considered to have the least depth (e.g. it is rendered on top of everything else).
Now for my question: How should I go about ordering each object so that the ones with a greater y value are rendered after objects with a lesser y value? My rendering code currently runs through an array of the characters from 0-199 and resets, which causes some visually obvious depth problems.
To illustrate:
<br />
character[0].y = 1000;<br />
character[1].y = 1200;<br />
character[2].y = 200;<br />
They should be rendered in this order: character 2 -> character 0 -> character 1. I'm not sure how I can order them this way though.
Thanks for any help and ideas
Edit: Added example
modified on Saturday, September 4, 2010 2:15 AM
|
|
|
|
|
why not just use the GL depth buffer?
|
|
|
|
|
I thought you could only do that if objects had differing z coordinates. How do you use the depth buffer without it?
|
|
|
|
|
that's right, depth buffering is based on the z coordinate of each pixel (after the transforms are applied and things are in screen-space). I mentioned it thinking perhaps you could use that to your advantage and assign depths to the various characters and then let depth buffering handle overlapping cases.
|
|
|
|
|
I would like to do it this way but I'm not sure how I can while maintaining the isometric perspective I have set up. Currently every object in my program has a z value of -6.0f. If I change it the characters will appear to the program user as if some are bigger than others, which is not something I want to happen. Should I scale the size of my quads to compensate for the different depth values? Or am I making things more difficult than they really are?
Thank you for the replies
|
|
|
|
|
I'm not sure -- I'm finding it hard to visualize what you're doing. A couple notes though.
You could use an orthographic projection instead of perspective so that near and distant objects appear the same size.
On the other hand, if sorting them is the only way that will work, then the question is, how often are the chars generated? If only periodically, perhaps you could, after generating them, sort them by the y value. Then you'd have a sorted list you could walk through to render.
|
|
|
|
|
Using glOrtho instead of gluProjection worked for me. In order to make transparency work in conjunction with depth testing I used glAlphaFunc(GL_GREATER, 0.1); Luckily my textures only have a single color that needed to be transparent (white background). I appreciate your help in getting this working
|
|
|
|
|
awesome! glad to hear its working
|
|
|
|
|
I made something similar some years ago. There is indeed two options: either go with the depth buffer as suggested by the other poster, but you'll need to find an algorithm to modify it depending on the y position of the node. The easiest would be that when you modify the y value of your character, you assign the same value to the z value.
Another option as already mentioned is sorting your nodes before rendering. This could be done quite easily by storing all your nodes in a list, and before you draw all the nodes you first sort the list based on the y value of the nodes.
|
|
|
|
|
DeviceIoControl with IOCTL_DISK_GET_DRIVE_LAYOUT does not give correct values on windows7. While it works fine on windows xp.
|
|
|
|
|
Ok, and?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
DeviceIoControl can be used with IOCTL_DISK_GET_DRIVE_LAYOUT parameter to get drives details. When i use this on windows xp it gives correct values for drive start address, drive size, hidden sectors etc. But when i run same code on windows7 the values are not correct.
How to get the correct information on windows 7. It gives me wrong information like drive start address, size etc
|
|
|
|
|
MKC002 wrote: It gives me wrong information like drive start address, size etc
Are the values just outright garbage, or maybe just some other power of 2 (e.g., 512 instead of 1024)?
What does DeviceIoControl() return?
What are you using to compare these "wrong" values against?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Has the disk got one or more mounted partitions sitting on top of it? If it has try unmounting those first and see if the IOCTL you want to use starts working. Vista added the restriction that you couldn't read and write to a disk when it has mounted file systems and this might be more of the same.
Cheers,
Ash
|
|
|
|
|
In List control, while using the Scroll bar, how we can know how much rows has went upside if scroling.
Thanks
|
|
|
|
|
guessing that the list control is in report view,
try handling LVN_ENDSCROLL notification from List control. Use GetTopIndex() to get the index of top visible item. That much rows will be on top.
|
|
|
|
|
You may use the CListCtrl::GetTopIndex, I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi!
Should I delete the pointers that are not allocated using new ? While running my application, it crashes, displays the following exception:
Unhandled exception at 0x00509260 in SlogOut3D.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
and exception pointer moves to this line:
gui::IGUISkin* skin = device->getGUIEnvironment()->createSkin(EGUI_SKIN_TYPE::EGST_WINDOWS_METALLIC);
The above line is inside the constructor. Should I delete gui::IGUISkin* skin ?
modified on Friday, September 3, 2010 4:36 AM
|
|
|
|
|
That looks like you're trying to use an uninitialised object of some sort.
And you only ever use delete when:
- you've newed an object
- the API you're using says you delete objects it supplies
In both cases use a pointer class to manage your memory though to reduce the complexity of your code.
Cheers,
Ash
|
|
|
|