|
Alright, I'm about to go batshit-insane here. I'm trying to build a very, very easy example application using FLTK and OpenGL. I start by making my own subclass of FLTK's "Fl_Gl_Window" class, basically just specifying a draw() method and a constructor (which calls the baseclass's constructor). Below is what's in MyGlWindow.h (minus includes and such): code:
Now, I'm getting two errors when I try to compile this: C2512 - 'Fl_Gl_Window' - no appropriate default constructor available C2614 - 'MyGlWindow' - illegal member initialization - 'Fl_Gl_Window' is not a base or member. So wtf. The default constructor error shouldn't be happening because in my main function, the ONLY time any window is constructed, it's with those parameters (I never try to make a MyGlWindow without specifying constructor parameters). As for the second error, IT SAYS RIGHT THERE IN THE CLASS DEF that Fl_Gl_Window is a base class of MyGlWindow. I've been looking up and down and backwards and forwards and even delved into FLTK's source to see if there was anything I could do, but alas I've been beaten. Hell, just for sanity's sake, here's the code from my main() function: code:
Thanks for your time, everyone.
|
# ¿ Sep 9, 2010 04:25 |
|
|
# ¿ May 21, 2024 00:53 |
|
OddObserver posted:wisdom
|
# ¿ Sep 9, 2010 04:41 |
|
I've got a object-oriented design question for y'all. Let's say I'm building a robot collision detection system like so:code:
What would be the best way to do this? My best guess so far would be to define (in a separate module) some classes like: code:
code:
|
# ¿ Apr 10, 2012 03:21 |
|
Sup robotics buddy There's some weirdness in RRT's performance sometimes due to its randomness, so it can be hard to pin down issues. If you post your full source code I can try to help you out. RRTs and related algorithms are my primary research area.
|
# ¿ Mar 28, 2014 17:28 |
|
Praseodymi posted:This is my code: One thing I did notice was that, the way you've implemented the point sampling, you're actually sampling from a fixed, discrete grid of points in space. The coarseness of your grid depends entirely on the size of the space; therefore, the larger the width and height, the finer the grid will be relative to the space. This might explain why the method's performance seems to improve with larger maps. You should change the sampling to actually sample from RAND_MAX possible values. This way the performance will be less sensitive to the size of your map. code:
About VS hanging at the sqrLength() line: how did you test for "hanging"? Did you just break execution randomly and find it was always in that spot? On typical problems RRT spends the most time deciding whether a point is in collision or not, but in some cases the most expensive part is that distance comparison, which would explain how often the program happens to be there when you cut execution.
|
# ¿ Mar 28, 2014 22:17 |
|
The Gay Bean posted:I have a custom data class that is formed for and used by a specific algorithm. The data backing it is just a collection of 1D and 2D STL vectors and a cv::Mat (which can be stored using a 2D STL vector). I coded up serialization using boost::serialization because it's easy to read and fairly standard, but it turned out to be slow as poo poo in debug mode - taking several minutes to write / read a 1 GB archive. This is reduced to like 10 seconds in release mode, but for the time being I need to run the code in debug mode a lot, and I can't put up with those kinds of wait times. Boost::serialization is weird. On the one hand you do get nice DRY ways of saving and loading stuff and it even supports STL; on the other hand, its binary mode is platform dependent, it's slow as poo poo, and they still can't seem to make floating point numbers roundtrip. If your code is already entrenched in boost::serialization and you just want more speed, look into setting the flag that stops boost from doing extra bookkeeping to serialize pointers. Unfortunately I'm on my phone now and can't find the flag in the docs, but basically as long as you aren't serializing pointers you can get more speed this way. Another choice is to just use a different library. I haven't tried it out yet, but I've heard that protocol buffers are very fast. This would however require you to do some rewriting.
|
# ¿ May 19, 2014 12:32 |
|
The Gay Bean posted:math This is actually a super interesting question but might be out of the scope of this thread. For what it's worth - I'm certain that fitting an affine transform to a dataset has been done before, but without doing any research, you might try a hybrid approach? I.e., use least squares to get an initial solution, then toss that initial solution into a local nonlinear optimizer like Levenberg-Marquardt (Ceres has this actually) where you use your constraint as your objective function. This is fun to think about but my idea's probably horrible and this is definitely a derail so I'll stop here.
|
# ¿ Aug 5, 2014 05:51 |
|
hooah posted:Does anyone here have any experience using OpenCV with Visual Studio? I'm having a variety of problems I'd like to have help fixing and the OpenCV answers section isn't being helpful. Email's in the profile if you'd be so kind. I can probably help, but I couldn't find your email address in your profile.
|
# ¿ Nov 13, 2014 19:30 |
|
hooah posted:I need to be able to grab a word from an input sentence and look up counts and probabilities from these two tables. I can set up 2-d arrays for the tables, that's no problem, but getting the indices into those tables is proving problematic. I thought of making enums for the words and tags, but that would leave me making a bunch of if/then statements to figure out which word is being looked at. Is there a standard/normal way to do something like this? You can use a hash table (unordered_map, C++11 only) or a map for this. For the map, your keys could be strings representing each of the possible words or tags.
|
# ¿ Nov 26, 2014 15:06 |
|
Blotto Skorzany posted:Sed contra, code:
|
# ¿ Apr 15, 2015 19:12 |
|
I seem to recall some random trivia that, if you want to represent a 3D Vector as a struct, it can be advantageous to actually store 4 values:code:
What do y'all think?
|
# ¿ Mar 10, 2021 02:19 |
|
cheetah7071 posted:Are you sure this isn't because of quaternion math? Rotating vectors is really easy when the number of dimensions is a power of two, so the usual way it's handled is to pretend your vector is four-dimensional, rotate it, and then go back to ignoring the fourth dimension. It's used all the time in computer graphics. I’m not sure - I always thought the fastest way to rotate a 3d vector is just to multiply with a 3x3 rotation matrix. Like, you can directly rotate a vector with a quaternion but it’s about as fast as converting the quat into a rotation matrix and just rotating that way. But I might be wrong!
|
# ¿ Mar 10, 2021 02:30 |
|
Absurd Alhazred posted:Well, depending on the compiler, it might be able to automagically compile a lot of vector code into SSE intrinsics. If you use a library dedicated to 3d-graphics-adjacent vector math, like GLM, you can enforce this through template parameters, even. more falafel please posted:Yeah, it's for vector intrinsics, which usually need their arguments to be aligned on 4-word/16-byte boundaries. Thanks! I'm trying to experiment to make sure I understand the concept correctly. It turns out that just putting 4 values in the struct does not guarantee 16-byte alignment of the struct. Here's an example that shows this: code:
|
# ¿ Mar 10, 2021 04:29 |
|
Yeah, that was super helpful. Much appreciated!
|
# ¿ Mar 11, 2021 05:02 |
|
Ruzihm posted:splay with treez nuts
|
# ¿ Jul 29, 2021 13:02 |
|
Not to mention lldb is a huge buggy piece of poo poo. I use an old macbook for game dev and I’m thinking of switching to gcc just so I can maybe have better luck with gdb
|
# ¿ Jul 20, 2022 02:49 |
|
Plorkyeran posted:You can use gdb with clang and lldb with gcc. Oh really? For some reason I’ve had a lot of trouble getting gdb to work on my clang builds on mac
|
# ¿ Jul 20, 2022 03:32 |
|
Seconding imgui. I no longer dread doing UI stuff for tools.
|
# ¿ Jul 27, 2022 23:10 |
|
I do dev on an old laptop and my compilation times in c++ are just excruciating. The worst cases of course are if I change a declaration in a header file that a lot of translation units refer to, which causes all those files to recompile. Just thinking aloud: the alternative to using a common header file would be to define those util functions as free functions with external linkage and then let the linker handle it instead. I realize there are issues with this approach, but it would probably mean way fewer recompiles when those util functions change, right? Or does the time saved in compilation get eaten up at link time or something?
|
# ¿ Sep 2, 2022 19:01 |
|
Sorry, by “changing declarations” I meant harmless stuff like adding new symbols or deleting unused ones. Even changing an existing declaration would only require changing the files that use that declaration, which would already be a huge win (theoretically) for recompile times
|
# ¿ Sep 2, 2022 19:12 |
|
Sorry, I think I was being unclear. This is what I'm suggesting:code:
code:
|
# ¿ Sep 2, 2022 19:28 |
|
Hmmmm modules indeed look like what I really want. I’ve heard people complain about them so I haven’t looked at them yet, but it might be worth at least experimenting with them a bit
|
# ¿ Sep 2, 2022 19:39 |
|
You’re 100% right that the simplest answer is to just get a faster machine, but in my naive heart it just feels wasteful to get a new computer when this 9 year old MacBook Pro is super fast still! Just compile times suck when making a change to a commonly included header. Overall I tend to hold onto hardware until it’s actually unusable, and part of my reason for developing on this old thing is to ensure that other folks on old hardware will be able to run and enjoy my game e: just to be even more annoying: I wonder all the time whether compilers, applications, games, etc would be better if dev shops just didn’t exclusively use the fastest machines available giogadi fucked around with this message at 21:18 on Sep 2, 2022 |
# ¿ Sep 2, 2022 21:11 |
|
All the talk earlier about pointers and inheritance earlier makes me think: it’s interesting how polymorphism and pointers are so fundamentally linked. I.e., if you want a vector of polymorphic objects you’re just expected to do it as a vector of pointers (usually to dynamically allocated memory). Since this pattern is bad for cache usage, it would be nice if it were easier to do polymorphic stuff without each individual object being a dynamic allocation. I know it’s possible: I’ve written for instance a container that exposes a “vector<Base*>” interface, but internally stores each derived type’s instances continuously in its own separate vector. But this was pretty ugly and difficult. it makes me wonder if there’s a way for a language to encode polymorphism to make something like the above way easier to do, or maybe even the default way to use polymorphism.
|
# ¿ Nov 16, 2022 13:33 |
|
Here’s a great treatment on the subject of polymorphic vectors: https://johnysswlab.com/process-polymorphic-classes-in-lightning-speed/ But my main point is to wonder whether there are language features that could make this kind of thing easier - all of these solutions, while clever and effective, take a lot of work to implement giogadi fucked around with this message at 14:40 on Nov 16, 2022 |
# ¿ Nov 16, 2022 14:37 |
|
New print in c++23? What was wrong with printf?
|
# ¿ Nov 23, 2022 17:50 |
|
In fact, C++ only started requiring two’s complement for signed numbers in C++20
|
# ¿ Jan 2, 2023 16:04 |
|
Sigh, kinda wish they had just made vector sizes a signed int. Who actually needs that last bit of storage afforded by 2^64 vs 2^63? Unsigned arithmetic is important but I feel like it should be totally opt-in, not mandated by the most basic vector api
|
# ¿ Jan 4, 2023 17:58 |
|
It’s not like they’d actually allow negative sizes: the sizes are all controlled by the vector api. But then it would allow completely sane and sensible comparison with signed ints which is what people should be using all the time anyway. “Unsigned int tells people it can’t be negative” is not actually useful when the failure mode ends up being a silent overflow. E: or underflow, loving whatever. giogadi fucked around with this message at 18:13 on Jan 4, 2023 |
# ¿ Jan 4, 2023 18:11 |
|
Volte posted:Unsigned int should usually mean "raw bit pattern" not "integer value that logically can't be negative". Sometimes even values that can't be negative can be subtracted from and you end up with really stupid bugs when the difference would be negative. Subtracting two vector sizes to get the difference between them? Better make drat sure to check which one's bigger first. Absolutely correct. Better than I could phrase it
|
# ¿ Jan 4, 2023 19:39 |
|
roomforthetuna posted:Non-serious counterpoint to signed sizes are good - Microsoft loving things up by using 32-bit size_t for posix file operations unless you go out of your way to #define some poo poo would be *even worse* if the accidental maximum size was ~2GB instead of ~4GB. Hahaha what the gently caress
|
# ¿ Jan 5, 2023 02:19 |
|
Ihmemies posted:I just wanted to drop by and state that bit operators in C are pure hell. Like I have to swap signed char pointer's bits around. 01001001 to 10010010 etc. Is this for a class? It’s sweaty because you’re doing sweaty stuff. If you wanted to work with bits in any other language it would also be sweaty
|
# ¿ Feb 2, 2023 17:39 |
|
Ihmemies posted:Yes. Thanks. Why would anyone want to work with bits though... Now this is an excellent question. It’s your terrible class’s fault for failing to motivate this stuff. Of course you hate it if you don’t even know why you’re mucking around in it. There are a million uses for bitwise operations. One of the fun uses is that sometimes, you can store data in bits way more efficiently than anything else. For example, if you have a long array of data, where some items are occupied/valid and other items are empty/invalid, you can store the occupied/empty status of each element in a big ol’ bitstring. This is more efficient than storing a bool for each item because a bool is usually at least 8 bits. Then you can do clever stuff like iterating over only the occupied items way faster than if you were iterating one-by-one over each item and checking “is this occupied or not?” This is all fancy stuff to squeeze out performance/space. Probably most fancy bit operations are for this kind of thing. You also need to do bitwise operations when working in embedded systems or communicating with hardware without a fancy high-level api.
|
# ¿ Feb 2, 2023 18:12 |
|
rjmccall posted:I keep having to reimplement bit vectors despite having access to the STL ones. The STL bitvectors are perfectly fine implementations, but they’re missing a lot of key operations. The only bitset-specific operation on std::vector<bool> is flip, and std::bitset only adds a handful of operations: any, all, &, |, and ^. Both are missing operations like “popcount”, “iterate all of the set bits”, and “find the lowest/highest set bit”, all of which can be done significantly more efficiently on bit vectors than a generic algorithm would reasonably get optimized to. 100%. Such a missed opportunity to not at least provide an iterator on set bits
|
# ¿ Feb 2, 2023 21:15 |
|
Ihmemies posted:I have asked the question in every course - why does the tester use some old version of the language? Know that I’m very angry for you
|
# ¿ Feb 6, 2023 17:35 |
|
It’s fine but don’t force your students to use it
|
# ¿ Feb 6, 2023 18:55 |
|
I'm being an idiot and overthinking a simple 4x4 matrix class. I'd like to do the following trick to enable getting Vector3's to each of the matrix rows without making copies; can the following cause problems on any platforms?code:
|
# ¿ Feb 18, 2023 06:11 |
|
Thanks for the feedback! I didn’t know about the weirdness around union aliasing - does this mean that all unions are suspect, or just the case where you’ve defined an object with one union element, then turn around and refer to it the object under a different union element? I ask because I use tagged unions quite a bit as well. e: so is it also sketchy to alias between a float* of the matrix data and the element-wise accesses like _m00? Man that’s super useful though. giogadi fucked around with this message at 14:46 on Feb 18, 2023 |
# ¿ Feb 18, 2023 14:36 |
|
roomforthetuna posted:Have you considered just using inlineable getter functions and helper classes/templates for this? You can also inline functions like _m00() or (as a template for less definition) _m<0><0>(). Absolutely - this is what I plan to do now. I went the union route initially due to laziness around implementing the online accessors, and partially curiosity. I’m glad I learned something new today about the weirdness around union aliasing. The game studio I work at does type punning all the time with unions so I had assumed it was perfectly safe.
|
# ¿ Feb 18, 2023 15:19 |
|
|
# ¿ May 21, 2024 00:53 |
|
Xerophyte posted:I'm not sure I strictly recommend rolling your own linear algebra library either. If you have very strict requirements around 3rd party code or if this is something you want to do for its own sake then, sure, go for it. Otherwise, chances are Eigen will do as well as anything you can write for any non-sparse use case. This is absolutely a terrible idea, I know. I’m doing it for fun, but also for this compulsion to avoid libraries with hella templates and call depth. I’m working on a game on a super old laptop and I highly value fast compiles and fast performance in debug builds; so I don’t need 95% of what most generic linear algebra libs provide, and I couldn’t find any libs without heavy dependence on templates and inlining, which is not great for compiles/debug performance.
|
# ¿ Feb 19, 2023 16:26 |