|
Tusen Takk posted:Good catch on that I thought I had used the carot not the asterisk for some reason. For future reference, there is a pow() function in math.h. But for something this simple there is no reason to include it and you should just stick with r * r.
|
# ? Feb 4, 2013 15:04 |
|
|
# ? Jun 8, 2024 06:34 |
|
That Turkey Story posted:It all still stinks. Sorry, I don't actually have a recommendation, I just felt the need to say that. I dunno, CreateWindow() works fine for me
|
# ? Feb 4, 2013 15:29 |
|
tractor fanatic posted:How do people do GUI Windows programming in C++ nowadays? Is there a favored framework, or is it a mix of MFC, ATL, QT, etc? if it's for windows just use .net wpf instead. even if you've literally never used .net before you'd still come out ahead on time and effort.
|
# ? Feb 4, 2013 16:21 |
|
I am relatively new to C programming and I am having a small issue. I am programming an embedded application on a microcontroller. The program is reading a line off of a SD card and storing it in memory as a string. This "string" is an ascii repesentation of a hex number. For example, the file on the sd card has just "12345678". I am trying to convert this string from its current form into a long int which the computer will read as a 32 bit hexadecimal number (as 0x12345678). I feel as though I am missing something really basic. I have tried using atol (which just converts it as if it is an int in base 10, as opposed to base 16). The certain microcontroller I am using is lacking in library support, so I think I will have to do this manually. Any ideas?
|
# ? Feb 4, 2013 16:56 |
|
Do you have strtol() available? It works the same way as atoi and takes a base argument. edit: If you have atol I would think that you also have strtol, since on a lot of platforms atol just calls strtol with base 10.
|
# ? Feb 4, 2013 17:08 |
|
Gul Banana posted:if it's for windows just use .net wpf instead. even if you've literally never used .net before you'd still come out ahead on time and effort. This is the best option. Even if you have existing c++ that you need to use you can just p/invoke it easily enough. If youre dead set on c++ or you have to be cross platform, Qt is the best option.
|
# ? Feb 4, 2013 17:08 |
|
It turns out that I do! And it worked brilliantly. Thanks.
|
# ? Feb 4, 2013 17:12 |
|
Also, you may want to czech out the embedded thread
|
# ? Feb 4, 2013 17:17 |
|
tractor fanatic posted:How do people do GUI Windows programming in C++ nowadays? Is there a favored framework, or is it a mix of MFC, ATL, QT, etc? Contrary to what others have said I would not recommend using WPF with .NET. WPF is a great idea but I've found its execution to be extremely bad and I hope you like writing XML. Granted I haven't used it extensively in about five years but the problems were fairly deeply rooted in the overall design. XAML is incredibly verbose, and lacks the ability to inline code (you can embed code literally but it's not useful or recommended) so you end up with a lot of indirection in your interface design, like having to define Converters and Commands all over the place to do the two most fundamental tasks in WPF, bind data and react to events. The time you save in having a declarative interface definition language might well be lost in the development overhead introduced by that language being god awful in almost every respect. I've never used QML and don't know if it's actually good but take a look at this example (from Wikipedia) and think about how much it would take to do it in WPF: code:
|
# ? Feb 4, 2013 17:49 |
|
I'm supposed to use SIMD and SSE to to optimize runtime of a raytrace renderer. I can't seem to find much info on how to use this in Visual Studio. Does anyone have any good resources for this?
|
# ? Feb 5, 2013 23:27 |
|
Boz0r posted:I'm supposed to use SIMD and SSE to to optimize runtime of a raytrace renderer. I can't seem to find much info on how to use this in Visual Studio. Does anyone have any good resources for this? Are you referring to this http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions ? Because these are just ... instructions. You can write them by hand or use a library. Maybe this would be helpful: http://stackoverflow.com/questions/61341/is-there-a-way-to-insert-assembly-code-into-c
|
# ? Feb 5, 2013 23:40 |
|
Boz0r posted:I'm supposed to use SIMD and SSE to to optimize runtime of a raytrace renderer. I can't seem to find much info on how to use this in Visual Studio. Does anyone have any good resources for this? http://msdn.microsoft.com/en-us/library/y0dh78ez(v=vs.80).aspx Volte posted:You pretty much have to embrace the entire Qt ecosystem, including their STL replacement classes. Is this a big deal in practice? Can I just use Boost and STL classes and convert only when I need to for Qt or is it a hassle? tractor fanatic fucked around with this message at 00:12 on Feb 6, 2013 |
# ? Feb 6, 2013 00:08 |
|
Boz0r posted:I'm supposed to use SIMD and SSE to to optimize runtime of a raytrace renderer. I can't seem to find much info on how to use this in Visual Studio. Does anyone have any good resources for this? On a more abstract level than the syntax of it all, Ingo Wald's phd thesis spends quite a lot of time on ways to adapt ray/path tracer operations for SIMD. Admittedly it's a few years old now but the thing is surprisingly general for thesis work and should be a good place to start if you're not sure exactly what to do with the instructions when you have them.
|
# ? Feb 6, 2013 00:11 |
|
tractor fanatic posted:Is this a big deal in practice? Can I just use Boost and STL classes and convert only when I need to for Qt or is it a hassle? we're still on qt 3.3 though
|
# ? Feb 6, 2013 00:24 |
|
Boz0r posted:I'm supposed to use SIMD and SSE to to optimize runtime of a raytrace renderer. I can't seem to find much info on how to use this in Visual Studio. Does anyone have any good resources for this? The MSDN documentation for SSE intrinsics was pretty good last time I did anything with them, which was about a year and a half ago.
|
# ? Feb 6, 2013 00:40 |
|
If this is for an assignment you may not be able to use it, but ISPC allows you to write SPMD stuff without needing to deal with intrinsics manually.
|
# ? Feb 6, 2013 01:04 |
|
tractor fanatic posted:Is this a big deal in practice? Can I just use Boost and STL classes and convert only when I need to for Qt or is it a hassle?
|
# ? Feb 6, 2013 01:28 |
|
I'll have a look at that SIMD, thanks. In the meantime, I've made the renderer both with signed volumes and cramer's rule ray-triangle interception. On my Windows machine, a specific scene takes 96s to render with volumes and 110s with cramer's rule(I haven't optimized much yet). My friend's implementation runs on Linux, looks almost identical to mine, but his takes less than 20s to render the same scene. How can this be?
|
# ? Feb 6, 2013 22:44 |
|
Boz0r posted:I'll have a look at that SIMD, thanks. In the meantime, I've made the renderer both with signed volumes and cramer's rule ray-triangle interception. On my Windows machine, a specific scene takes 96s to render with volumes and 110s with cramer's rule(I haven't optimized much yet). My friend's implementation runs on Linux, looks almost identical to mine, but his takes less than 20s to render the same scene. How can this be? Are the specs on your computer and your friend's significantly different, are you using the same compiler and settings, etc? Notably, gcc will aggressively try to vectorize loops at high optimization levels edit: cf. http://www.linux-kongress.org/2009/slides/compiler_survey_felix_von_leitner.pdf
|
# ? Feb 6, 2013 22:48 |
|
I think he's using GCC and I'm using Visual Studio 2010. My CPU is significantly faster than his, though I don't know exactly what he has. I've got an i5-3570K.
|
# ? Feb 6, 2013 22:53 |
|
Assuming single-precision arithmetic, your ideal speedup from vectorization via SSE is 4x, with ~3.5x achievable in practice on problems where vectorization is a good fit. Given his code runs >5x faster than yours on slower hardware, that can't be the only thing. Without reading your code, there's not much I can say besides see what the profiler says. Nb. that an easy way to slow this sort of code down, vectorized or not, without even trying is by accessing memory in a way that sabotages your cache.
|
# ? Feb 6, 2013 23:05 |
|
He tried using my code, and achieved a rendering time of 8.54 seconds on a i5 M520. I don't understand this. Mine is 109 seconds.
|
# ? Feb 6, 2013 23:30 |
Boz0r posted:He tried using my code, and achieved a rendering time of 8.54 seconds on a i5 M520. I don't understand this. Mine is 109 seconds. What are your compiler settings? If you're building using "debug" settings it's common to get factor 5 slowdowns or worse.
|
|
# ? Feb 6, 2013 23:36 |
|
Boz0r posted:I'll have a look at that SIMD, thanks. In the meantime, I've made the renderer both with signed volumes and cramer's rule ray-triangle interception. As noted, you're probably compiling in debug and/or attaching the VS debugger. Also, make sure your project is set to compile using fp:fast so it does floating point transforms for you. Setting in Project Properties > Configuration Properties > C/C++ > Code Generation. It can make a very large difference for this sort of stuff. Also, intersection tests is one of those things where you almost definitely do not want to roll your own. There's a lot of previous work around. For ray-triangle and SIMD-optimization specifically, look at this one. Comes with code full of delectable SSE4 intrinsics and all that jazz.
|
# ? Feb 6, 2013 23:50 |
|
Boz0r posted:I think he's using GCC and I'm using Visual Studio 2010. My CPU is significantly faster than his, though I don't know exactly what he has. I've got an i5-3570K. My mate used VS10 on his code and I used GCC on mine and mine was a shitload faster/had less issues than his, too. I tried running my code in VS10 and I had a few issues, he used GCC and had less problems. I honestly hate VS10 and prefer GCC but don't take my word as law since I'm very with coding still.
|
# ? Feb 7, 2013 08:35 |
|
My problem was the debug mode. Compiling in release mode nets me a render time of 5 seconds. I'm not that used to C++ yet, so every time I have to write something, I have to dick around in VS to make it not do all sorts of crazy poo poo.
|
# ? Feb 7, 2013 11:18 |
|
If a class member function either explicitly calls a function override from one of its children, or even instantiates one of its child classes, is that the total faux pas I think it is? I've got some code from a project I'm trying to reuse for another project, but it does like the following code (where the child object references other modules that I really don't want to have to port over oh my god):C++ code:
Ciaphas fucked around with this message at 21:42 on Feb 7, 2013 |
# ? Feb 7, 2013 21:39 |
|
Ciaphas posted:If a class member function either explicitly calls a function override from one of its children, or even instantiates one of its child classes, is that the total faux pas I think it is? No. Having a virtual method with children that exist just to override that virtual method is a common trick. As for constructing the child temporarily in the parent goes, your code example won't actually compile (you'll have to put the doStuff implementation out-of-line, underneath the class Bar definition, and then it'll work), but as for the question of whether it's good software design, that depends on the situation. There do exist situations where strongly-coupled base classes and subclasses are needed. The "visitor pattern" is another situation in which you get equally strong coupling (the base class, with its visit method taking a particular visitor type, is directly tied to its set of subclasses).
|
# ? Feb 7, 2013 21:47 |
|
Ciaphas posted:If a class member function either explicitly calls a function override from one of its children, or even instantiates one of its child classes, is that the total faux pas I think it is?
|
# ? Feb 7, 2013 21:48 |
|
By the way, I'm never sure what words to use. What is a "definition," "declaration," and "implementation" (and "prototype"?) when it comes to things like class foo;, class foo { };, /* inside class foo */ int method() const;, /* inside class foo */ int method() const { return 5; }, and int foo::method() const { return 5; }?
|
# ? Feb 7, 2013 21:49 |
|
Okay, thanks for the info. Not sure how I'm gonna port this thing over now, though--I didn't write the thing so I've got to spend a few hours/days looking it over more closely. Wish I could just post the real code here and seek advice shrughes posted:As for constructing the child temporarily in the parent goes, your code example won't actually compile (you'll have to put the doStuff implementation out-of-line, underneath the class Bar definition, and then it'll work) derp
|
# ? Feb 7, 2013 21:52 |
|
My general experience over the past week or so of near non-stop computational coding across gcc and VS on different studios says that gcc is vastly more cooperative with respect to computational stuff.
|
# ? Feb 7, 2013 21:52 |
|
shrughes posted:By the way, I'm never sure what words to use. What is a "definition," "declaration," and "implementation" (and "prototype"?) when it comes to things like
|
# ? Feb 7, 2013 22:51 |
|
And I just looked up "prototype", it's basically the same thing as a function declaration, only explicitly "it contains all the parameters". Since nobody declares functions without all the parameters these days, there is no practical difference, other than people are more likely to know what you're talking about if you say declaration. Edit: possibly a prototype might also refer to the thing you would use with a typedef, that resembles a declaration but isn't one because there's no actual function? roomforthetuna fucked around with this message at 00:55 on Feb 8, 2013 |
# ? Feb 7, 2013 23:15 |
|
shrughes posted:By the way, I'm never sure what words to use. What is a "definition," "declaration," and "implementation" (and "prototype"?) when it comes to things like class foo;, class foo { };, /* inside class foo */ int method() const;, /* inside class foo */ int method() const { return 5; }, and int foo::method() const { return 5; }? Definitions are declarations but not all declarations are definitions. I believe the standard always refers to class foo { /**/ }; as a class declaration, but most people always call that a class definition just to disambiguate it from a forward declaration of a class, myself included. The other thing that's sort of ambiguous is a template instantiation -- in the standard they are just called specializations, I believe, but people usually just say instantiation to differentiate it from explicit specializations and partial specializations. This is from memory and I don't feel like checking the standard, so I might be incorrect on how exactly it refers to things.
|
# ? Feb 7, 2013 23:26 |
|
You've got it down cold. In the standard, "instantiation" is the process of deriving a definition for a template specialization by substituting into the definition of a template, of a partial specialization, or of a member thereof (possibly recursively). Outside of the standard, "specialization" generally means an explicit specialization or partial specialization, and people use "instantiation" for basically anything that's either got template arguments itself or is nested inside something that does.
|
# ? Feb 8, 2013 00:01 |
|
Okay this is bugging the poo poo out of me. I've been playing with the Video 4 Linux API. So I query the devices capabilities and I look at this value "__u32 capabilities" That's an unsigned int, right? I get the value 67108865 back. Which is 4000001 in hex. Okay. That makes sense according to the documentation. So I figure I can look at those properties and simply go code:
|
# ? Feb 9, 2013 16:25 |
|
Tres Burritos posted:I'm doing something wrong here because every hex value I try like that is returning true. I feel stupid as poo poo that I'm somehow loving this up. The == takes precedence over the bitwise and. So what that is really checking is code:
code:
Also, you don't actually need the == 0x80000, since it's only checking 1 bit. You could just do code:
|
# ? Feb 9, 2013 16:53 |
|
astr0man posted:The == takes precedence over the bitwise and. So what that is really checking is Oh goddamnit, thanks.
|
# ? Feb 9, 2013 16:58 |
|
|
# ? Jun 8, 2024 06:34 |
|
My VS2012 project always wants to build some stuff even if the files haven't changed. Online, I found this often has to do with files that have become missing, and I can find them if I turn on some debug logging. I did that and got a good look at 762 missing files in one of the projects. The big thing is that it's pointing to old crap off of a D:\ path that I used to use. I moved everything over to a C:\ path a few months back. The project itself builds fine; the project configuration inside Visual Studio looks right. I can't find any references to D:\ under the source tree. What the hell could it be? Is this some stupid precompiled header shenanigans?
|
# ? Feb 9, 2013 18:42 |