Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Bender: "... and I thought I saw a two!"
Fry: "It was just a dream, Bender! There's no such thing as two."

Adbot
ADBOT LOVES YOU

Moetic Justice
Feb 14, 2004

by Fistgrrl

TheSleeper posted:

When I tried to something like that back when I was in college, I wound up having to search MSDN forever and as I can recall I had to either use something like __getc() and/or some kind of voodoo to force stdin not to wait.

Edit: I think I've found it. Either getch() or getche() in conio.h. You may or may not need to preface the function names with underscores. These functions read characters directly from the console without buffering at all. The first will read without echoing(when you press "y" the program will see it but it won't show on the screen) while the second does echo.

I'll try that; I've been working with stdio.h this whole time. We haven't really gotten past the Standard Library.

Harokey
Jun 12, 2003

Memory is RAM! Oh dear!
I'm trying to integrate some UNIXy (cygwin) code over to a visual studio project. I've never really dealt with visual studio, or windows programming in general, so I'm having a lot of problems.

I'm trying to change a lot of the pthreads calls into windows threads.

I've created the thread using AFXBeginThread. But I'm having trouble with the mutex's... It looks like I should be using the "CMutex" object. So I've included avxmt.h which its defined in. But I get these errors:


1>c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxmt.h(81) : error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'

1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(559) : see declaration of 'CObject::operator ='

1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(529) : see declaration of 'CObject'

1> This diagnostic occurred in the compiler generated function 'CSyncObject &CSyncObject::operator =(const CSyncObject &)'


What gives?

Zombywuf
Mar 29, 2008

Jungle Bus posted:

I'll try that; I've been working with stdio.h this whole time. We haven't really gotten past the Standard Library.

Can you just cheat and say "Press enter to continue"?

Zombywuf
Mar 29, 2008

Harokey posted:

<some compiler output>
What gives?

For some reason it seems CObject is not EqualityComparable, except privately. This is possibly a deliberate override of the compiler generated equality operator to prevent it being misused. A quick check of the docs suggests you're going to have to rework any logic that requires checking the equivalence of CSyncObject.

Plastic Jesus
Aug 26, 2006

I'm cranky most of the time.

Harokey posted:

I'm trying to integrate some UNIXy (cygwin) code over to a visual studio project. I've never really dealt with visual studio, or windows programming in general, so I'm having a lot of problems.

I'm trying to change a lot of the pthreads calls into windows threads.

I've created the thread using AFXBeginThread. But I'm having trouble with the mutex's... It looks like I should be using the "CMutex" object.

Unless it's absolutely critical that you use MFC for thread management I recommend using the core Win32 thread management API calls. They're very straight-forward and in my opinion kick the tits off of pthreads. The SDK docs for threads and fibers are particularly good, so an afternoon of reading will more than cover what you need to know to get started.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Zombywuf posted:

For some reason it seems CObject is not EqualityComparable, except privately.

That's the assignment operator, but the rest of your post still stands.

Citizen Erased
Mar 20, 2004

Wash Me Away
Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector and since, a friend has told me how slow vectors are. I'd like to re-work some of the old code and replace the vectors with something similar but more efficient if it means I can eek a few more frames per second out of it. Is there anything faster and more suited for real time 3D applications?

Harokey
Jun 12, 2003

Memory is RAM! Oh dear!

Zombywuf posted:

For some reason it seems CObject is not EqualityComparable, except privately. This is possibly a deliberate override of the compiler generated equality operator to prevent it being misused. A quick check of the docs suggests you're going to have to rework any logic that requires checking the equivalence of CSyncObject.

I only do assignment when I first create the CMutex object. Maybe I'm doing it wrong?

code:
In The header: 
CMutex commandMutex;

In the Object's Constructor: 
vrCommData.commandMutex = CMutex();
Is this not what I want to be doing?

Steampunk Mario
Aug 12, 2004

DIAGNOSIS ACQUIRED

Citizen Erased posted:

Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector and since, a friend has told me how slow vectors are. I'd like to re-work some of the old code and replace the vectors with something similar but more efficient if it means I can eek a few more frames per second out of it. Is there anything faster and more suited for real time 3D applications?

http://code.google.com/p/rdestl/

This is a library developed by a guy who worked on The Witcher (and has a pretty decent development blog). I would imagine there's something in here you can cannibalize if optimization's important.

TSDK
Nov 24, 2003

I got a wooden uploading this one

Citizen Erased posted:

Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector and since, a friend has told me how slow vectors are. I'd like to re-work some of the old code and replace the vectors with something similar but more efficient if it means I can eek a few more frames per second out of it. Is there anything faster and more suited for real time 3D applications?
There's nothing intrinsically wrong with using a vector for real-time applications, provided you're not doing something silly with them like re-creating them with push_backs on a per frame basis, or copying them wholesale. In fact, if the vector doesn't resize, then they should be pretty much as fast as a plain array.

It's more likely that any performance problems are down to your use of allocations rather than choice of an STL container.

Also, I'd avoid listening to your friend on matters of performance in future.

EDIT: Check out Meyers' Effective STL if they've got a copy in a library near you.

6174
Dec 4, 2004

Citizen Erased posted:

Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector and since, a friend has told me how slow vectors are. I'd like to re-work some of the old code and replace the vectors with something similar but more efficient if it means I can eek a few more frames per second out of it. Is there anything faster and more suited for real time 3D applications?

While you really should listen to TSDK first as he knows plenty more about C++ than me, but Boost.Array may be of interest. However before you go nuts are start replacing things, have you profiled your code to determine that the vectors are really a problem?

Scaevolus
Apr 16, 2007

Citizen Erased posted:

Does anyone know of a faster alternative to the standard library vector container? A year or so ago I made a 3D application which relied very heavily on the stl vector...
This is a dumb question, but were most of these vectors representing triples? (<x,y,z>)

If so, it's trivial to implement your own vector class that has three elements. Liberal use of "const" in function prototypes for it will help your compiler optimize it.

That Turkey Story
Mar 30, 2003

Scaevolus posted:

This is a dumb question, but were most of these vectors representing triples? (<x,y,z>)

Oh my lord... I hope that isn't what he was using std::vector for!

Steampunk Mario
Aug 12, 2004

DIAGNOSIS ACQUIRED

That Turkey Story posted:

Oh my lord... I hope that isn't what he was using std::vector for!

How else would you implement a 3-Vector? :raise: It's called std::vector for a reason, you know!

If you really needed .x, .y, and .z syntax you could instead inherit from std::vector, I guess.

If you weren't supposed to use it like that, then why would the STL provide an inner_product function? :rolleyes:

haveblue
Aug 15, 2005



Toilet Rascal

Drx Capio posted:

How else would you implement a 3-Vector? :raise: It's called std::vector for a reason, you know!

Probably with something that doesn't have a ton of baggage related to dynamic resizing.

Steampunk Mario
Aug 12, 2004

DIAGNOSIS ACQUIRED

HB posted:

Probably with something that doesn't have a ton of baggage related to dynamic resizing.

Well it wouldn't be doing any resizing after init since it's a 3-vector, not an n-vector!

Citizen Erased
Mar 20, 2004

Wash Me Away

TSDK posted:

There's nothing intrinsically wrong with using a vector for real-time applications, provided you're not doing something silly with them like re-creating them with push_backs on a per frame basis, or copying them wholesale. In fact, if the vector doesn't resize, then they should be pretty much as fast as a plain array.

It's more likely that any performance problems are down to your use of allocations rather than choice of an STL container.

Also, I'd avoid listening to your friend on matters of performance in future.

EDIT: Check out Meyers' Effective STL if they've got a copy in a library near you.

Nothing like that, from memory I don't think there are any (or many) instances of vector resizing. I'll definately pick up the meyers book though, his 55 ways to improve your C++ was excellent.

6174 posted:

While you really should listen to TSDK first as he knows plenty more about C++ than me, but Boost.Array may be of interest. However before you go nuts are start replacing things, have you profiled your code to determine that the vectors are really a problem?

I don't have a profiler, I'd be open to any recommendations for a good free profiler though. I was simply going on the advice of someone I thought knew a lot more than I do about C++

Scaevolus posted:

This is a dumb question, but were most of these vectors representing triples? (<x,y,z>)

Nope, I'm using DirectX and so using the built in D3DVector3 class for that. There are however a few instances of stl::vectors of d3dvector3s just to confuse me when I'm trying to re-read my old code.


Thanks for the advice, I'll leave the vectors as they are unless I see some sound reasoning to the contrary then. Saves me a lot of hassle.

more falafel please
Feb 26, 2005

forums poster

That Turkey Story posted:

Oh my lord... I hope that isn't what he was using std::vector for!

To be fair std::vector is a really dumbass name, WTG Bjarne.

Steampunk Mario
Aug 12, 2004

DIAGNOSIS ACQUIRED

more falafel please posted:

To be fair std::vector is a really dumbass name, WTG Bjarne.

It's mathematically sound, in the linear algebra sense, but pretty dumb in the everyday sense. At least 'set' and 'map' are logical on both levels. :shobon:

limip
Oct 24, 2003

Harokey posted:

I only do assignment when I first create the CMutex object. Maybe I'm doing it wrong?

code:
In The header: 
CMutex commandMutex;

In the Object's Constructor: 
vrCommData.commandMutex = CMutex();
Is this not what I want to be doing?

All member objects are constructed during the "initializer list phase" (totally made up and incorrect phrase) of the containing object's constructor using their default constructor unless you specify a different constructor in the initializer list for the containing object.

So, the commandMutex member of vrCommData has already been constructed; there's no need to construct it again (unless you want to make your code slower, provided the object provides an assignment operator).

Mr VacBob
Aug 27, 2003
Was yea ra chs hymmnos mea
There's nothing slow about std::vector; accessing it is exactly as fast as it's possible to be. DId he give any details on why it's slow? Does he just want to insert stuff into the middle of all his data structures?

Zombywuf
Mar 29, 2008

Harokey posted:

I only do assignment when I first create the CMutex object. Maybe I'm doing it wrong?

code:
In The header: 
CMutex commandMutex;

In the Object's Constructor: 
vrCommData.commandMutex = CMutex();
Is this not what I want to be doing?

As avenging dentist pointed out, I'm a numpty. It was the assignment operator that was declared private. It looks like you can simply remove the line with the assignment as the commandMutex member will have already been constructed with the default constructor.

ColdPie
Jun 9, 2006

Zombywuf posted:

As avenging dentist pointed out, I'm a numpty. It was the assignment operator that was declared private. It looks like you can simply remove the line with the assignment as the commandMutex member will have already been constructed with the default constructor.

And it doesn't look like you need to, but if you have to pass constructor arguments to your CMutex, you can do it in the class's initializer list:
code:
YourClass::YourClass():
  commandMutex(some, constructor, arguments)
{
    //...body of constructor...
This of course applies for any classes you have in YourClass.

I always ignored initializer lists because they look ugly and are hard to read and maintain, but they provide some really critical features like the above and arguments to inherited classes' constructors.

Harokey
Jun 12, 2003

Memory is RAM! Oh dear!
Okay thanks guys. My problem is that I'm not really experienced with C++ yet, and I don't know much about windows programing either, so when you put the two together I've got a whole lot I'm not comfortable with.

Thanks!

ruden
Dec 2, 2006
I'm working on a fractal image for a professor. The image is huge, on the order of 360k px by 36k px. I'm using C++, and due to the image size, I can't simply write to a bitmap canvas. I was wondering if there was a workaround for this. I can get the image drawn on a graphics canvas, and it displays, but I cannot save this. Due to the algorithm being used, it would be a pain to remake it to do it in sections. Is there another program that this would be best implemented (and an image of it saved!) in? The program just draws straight 2d lines, so nothing super complex. Any help?

csammis
Aug 26, 2003

Mental Institution
What toolkit are you using for the graphics? How are you trying to save it?

ruden
Dec 2, 2006
Nothing special, just the graphics libraries that come with visual studio. As for how I'm trying to save it, file type doesn't matter, however, the size is very specific for a reason, the fractal is very detailed and needs to be printed on a 20ft x 2ft banner, at 1400dpi, hence the enormous dimensions. After that, jpeg, bmp, gif, xxx doesn't matter, just as long as I can save it. I was looking at using the MFC package to work on it, as I think it has built in save features, although I'm not sure if that will even handle the size all things considered.

TLDR: doesn't matter the file type, as long as size/quality is relatively maintained.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.
If you're trying to save it to a file to print, I don't understand why you're even trying to display it on the screen. Use an imaging library, not a GUI one. (I don't know enough about them to know which can handle really large images well, though.)

ruden
Dec 2, 2006
It's true, I don't need to draw it to the monitor at all. However, I was just looking at 2D graphics drawing programs and that was the quickest to get into. I don't need to display it at all, but I still need to know how to save it to some sort of image file.

ZorbaTHut
May 5, 2005

wake me when the world is saved

ruden posted:

It's true, I don't need to draw it to the monitor at all. However, I was just looking at 2D graphics drawing programs and that was the quickest to get into. I don't need to display it at all, but I still need to know how to save it to some sort of image file.

libpng is quite easy to use, and I recommend it. If you're even lazier you can simply save it as a raw image file with interlaced channels - i.e. dump out the color values in a giant blob - and open it with an image editor of your choice as a raw image file.

On the other hand, how are you generating it? That's 13 billion pixels - if it's one byte per pixel, that's 13 gigs of RAM. Are you actually getting an image at any point, or are you just drawing lines on a graphics canvas that isn't necessarily represented as a bitmap?

If you're doing the latter, this could become quite difficult :v:

The_Carp
Dec 13, 2007
I have a question about makefiles (this is the closest existing thread to my question that I know of)

So, I'm asked to edit my makefile such that it can accept an input file from the command line like so:

make input1.txt

would compile things normally, using input1.txt however way I like.

So, this is most likely because I am make-stupid, but is this even possible? If so, how would I go about doing it?

ruden
Dec 2, 2006
As to how I'm drawing it, basically it's nested for loops with graphics.DrawLine() functions. I'm not sure how C++ interprets that exactly, but I'm not drawing pixel for pixel. I'm only using black and white, so color is a minimum too.

crazypenguin
Mar 9, 2005
nothing witty here, move along
If you're just drawing lines, one possibility is to just write out an SVG file, and then try to open it up in gimp to convert it to whatever.

I *think* gimp handles large files pretty well...

Scaevolus
Apr 16, 2007

ruden posted:

As to how I'm drawing it, basically it's nested for loops with graphics.DrawLine() functions. I'm not sure how C++ interprets that exactly, but I'm not drawing pixel for pixel. I'm only using black and white, so color is a minimum too.
You mean grayscale?

And is it impossible for this to be done in sections because parts of the image reference other parts? (Which fractal are you drawing?)

crazypenguin posted:

I *think* gimp handles large files pretty well...

No, it doesn't. Try creating a 20,000x20,000 image if you don't believe me.

Scaevolus fucked around with this message at 18:21 on Apr 28, 2008

ruden
Dec 2, 2006
Well, I use the word fractal loosely, basically it's imitating reflecting lines in a tube. I could try the SVG, I never thought about using that, and I know it's fairly easy to get into. Is there a limit on image sizes in SVG?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

ruden posted:

Well, I use the word fractal loosely, basically it's imitating reflecting lines in a tube. I could try the SVG, I never thought about using that, and I know it's fairly easy to get into. Is there a limit on image sizes in SVG?

How will you be printing this once you have the image file? It might be simpler to work directly in PostScript.

crazypenguin
Mar 9, 2005
nothing witty here, move along

Scaevolus posted:

You mean grayscale?

And is it impossible for this to be done in sections because parts of the image reference other parts? (Which fractal are you drawing?)


No, it doesn't. Try creating a 20,000x20,000 image if you don't believe me.
Touche. Does photoshop? I guess this is somewhat deviating from C/C++

ruden
Dec 2, 2006
I'll be taking it to a special printer that prints 1400dpi banners, basically. Very expensive, can't afford to mess it up. The file type doesn't matter, as long as the quality is maintained. I am free to use (almost) any program out there. I have tried Java (couldn't keep that big of an image in memory), and C++ (can't find an easy way to save it). I was thinking about MATLAB, but I don't know too much about it.

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Have you looked at Boost.GIL (Generic Image Library for C++)?

http://www.boost.org/doc/libs/1_35_0/libs/gil/doc/index.html

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply