Jump to content
  • Advertisement
Sign in to follow this  
mike74

Dev-C++ ridiculousness

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

Okay, I have a class that represents a quadrilateral. Here it is: class Quad { double vert0[3]; double vert1[3]; double vert2[3]; double vert3[3]; public: Quad(double v0[3], double v1[3], double v2[3], double v3[3]) { memcpy(vert0, v0, sizeof(double)*3); memcpy(vert1, v1, sizeof(double)*3); memcpy(vert2, v2, sizeof(double)*3); memcpy(vert3, v3, sizeof(double)*3); } int intersect(double orig[3], double dir[3], double *goodt) { double t,t2,u,v; int isect1, isect2; isect1=intersect_triangle(orig,dir,vert0,vert1,vert2,&t,&u,&v); if (isect1 == 1) *goodt = t; isect2=intersect_triangle(orig,dir,vert2,vert3,vert0,&t2,&u,&v); if (isect2 == 1) *goodt = t2; return isect1|isect2; } void draw(void) { glBegin(GL_QUADS); glVertex3f(vert0[0], vert0[1], vert0[2]); glVertex3f(vert1[0], vert1[1], vert1[2]); glVertex3f(vert2[0], vert2[1], vert2[2]); glVertex3f(vert3[0], vert3[1], vert3[2]); glEnd(); } void drawandtexture(void) { glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(vert0[0], vert0[1], vert0[2]); glTexCoord2f(1.0f, 0.0f); glVertex3f(vert1[0], vert1[1], vert1[2]); glTexCoord2f(1.0f, 1.0f); glVertex3f(vert2[0], vert2[1], vert2[2]); glTexCoord2f(0.0f, 1.0f); glVertex3f(vert3[0], vert3[1], vert3[2]); glEnd(); } }; Anyway, I decided that it would be nice if the quads could have color. So, I decide to add some double r, g, and b members to the class like so: double r, g, b; Now, for some inexplicable reason, just adding these members (as private or public) causes the program to crash! Actually, just adding any member to the class causes the program to crash! And, get this... if I comment out the code in the drawing functions, it doesn't crash! Am I missing something obvious? I really suspect Dev-Cpp is on crack. Also, when Dev-cpp crashes, it says it generates an error log. I can't seem to find this log anywhere. Anyone know where it is? I'm probably going to try to compile it Microsoft's command-line compiler. By the way, is there a free IDE for Microsoft's command-line compiler? Mike C. http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by mike74
By the way, is there a free IDE for Microsoft's command-line compiler?


You could use Dev-C++. Some people seem quite fond of Code::Blocks as well. Yes, you can use any compiler with any (decent) IDE.

Share this post


Link to post
Share on other sites
Try to force Dev-c++ to recompile the whole project: what you describe sometimes happens because it does not recompile some modified files and on run-time it crashes.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by cignox1
Try to force Dev-c++ to recompile the whole project: what you describe sometimes happens because it does not recompile some modified files and on run-time it crashes.


there's a checkbox in the options somewhere labeled something like "use fast but imperfect depency checking". this is usually a bad idea and i believe it's checked by default.

Share this post


Link to post
Share on other sites
AP above is me. i tried to post and got this...

Microsoft OLE DB Provider for SQL Server error '80004005'

Transaction (Process ID 60) was deadlocked on lock resources with another process
and has been chosen as the deadlock victim. Rerun the transaction.

/community/forums/login.asp, line 207

then it posted as AP...

Share this post


Link to post
Share on other sites
Well, I figured out a workaround. I just use floats for the vertices instead of doubles. It seems like whenever the class size exceeds 96 bytes, it crashes. It may have something to do with the fact that I am using the STL vector like so:

vector<Quad> v;

Is there some limit on the size of objects you can stuff into a vector? I could use pointers, but I wasn't aware of any size limit.

Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
There is no size limit at all. I believe you must do something very bad outside of the class (the code of the class itself seems to be good).

However from a design point of view it is rather weird. You'll find it easier if your quad reference vertex (and a vertex holds its position, color, and so on).

Regards,

Share this post


Link to post
Share on other sites
Why's it weird if the quad only has one color?

Mike C.
http://www.coolgroups.com/zoomer/

Share this post


Link to post
Share on other sites
I don't know but is something like this ...
int main()
{
const int array_size = 1;
double a[array_size];
double b[array_size];

memcpy(a, b, sizeof(double)*array_size);
}
... considered bad code?

[Edited by - Jonus on June 16, 2005 10:52:28 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Jonus
I don't know but is something like this ...
int main()
{
const int array_size = 1;
double a[array_size];
double b[array_size];

memcpy(a, b, sizeof(double)*array_size);
}
... considered bad code?


I don't see the interest at all :)

Anyway, I was refering to "potential bugs" when I said "very bad code". This is has nothing to do with the style and the purpose of the code.

Quote:
Original post by Mike74
Why's it weird if the quad only has one color?


This is very inflexible, but I didn't refer to this. I refered to these vert0 to vert3 arrays. In the 3D realm, it is usually better to store a list of vertex somewhere and to use a reference to the vertice rather than a copy of it to describe either a triangle or a quad. If a vertex is shared bewteen 2 entities, your solution needs 2 instances of this particular vertex - they take twice the needed memory size, you need to transform them both, which is twice as slow as transforming one vertex, and so on.

Moreover, you are in the glorious day of OOP. Until you are creating adapater to existing code, "double v0[3]" is not a good definition for a vertex - no semantic value, and no encapsulation at all. A vertex is an instance of the Vertex class. Later, if you want to add two texture coord, you waon't have any problem if these cood belongs to the Vertex class, but you'll be in big trouble if you need to add 2 double to your v0 variable.

I hope you get the point.

Regards,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!