Yup that works for me too. Sorry about the name I just wasn't paying attention when I tried to replace it as a keyword hehe. I'm trying to figure out why that is different from the actual code and I might be back with the full thing in a bit.
I get the problem once I add a move-ctor though. I'm unsure what the problem is, but even this code fails:
[code]class Class
{
public:
Class(){}
template <int = 0>
Class(const Class&){}
//template <int = 0>
Class(Class&&){}
};
int main()
{
Class a, b(a);
}[/code]
It works when you un-comment the template-parameter for the move-ctor - this also works in the more complex example with std::enable_if.
You should probably report a bug, or if you don't want to for whatever reason I'd be glad to do it on your behalf.
Yeah that's what i'm getting too. Sorry for not trying to make a reproducible example in the first place. Also thanks for a possible temporary workaround. I don't know where or how to properly report a bug so you're more than welcome to do so, but if not i'll get to it later.
I've posted it as a question [url=https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/std-discussion/pYmORGd4g78]here[/url] to determine whether the compilers are behaving correctly first.
If not, I will report a bug [url=http://gcc.gnu.org/bugzilla/]for gcc[/url] and [url=http://llvm.org/bugs/]for clang[/url].
[editline]28th May 2013[/editline]
[url=https://groups.google.com/a/isocpp.org/d/msg/std-discussion/pYmORGd4g78/wJhPW_scsMYJ]Looks like my suggestion won't work right[/url].
You should be able to use enable_if via a dummy-parameter though
[code]Class(const Class&, std::enable_if<..., int>::type = 0)[/code]
For the compiler to be able to generate implicitly generated constructors and assignment operators for classes using Class you will also have to define the normal copy constructor:
[code]Class(const Class &that):Class(that, 0) {}[/code]
I see what the problem is now, however I still think that it makes sense that a templated copy constructor with the correct function signature could be considered to be the copy constructor.
I'm now using your solution so thanks once again.
Why does openGL use floats from 0f to 1f?
example:
[code]
glClearColor(0, 0, 0, 1);
[/code]
[editline]28th May 2013[/editline]
Also, why does it use values between 0 and 1 and not, for example, 0 - 255?
My guess would be that most graphics hardware talks floating-point, so to skip a conversion step for most hardware they use floating-point as arguments.
[QUOTE=toaster_2.0;40817606]Why does openGL use floats from 0f to 1f?
example:
[code]
glClearColor(0, 0, 0, 1);
[/code]
[editline]28th May 2013[/editline]
Also, why does it use values between 0 and 1 and not, for example, 0 - 255?[/QUOTE]
Because it allows for a theoretically infinite amount of colours, rather than the 16777216 limit if you use 0-255. I know it's not really infinite because of floating point precision and suchlike, but that's the idea anyway.
[editline]28th May 2013[/editline]
[QUOTE=ZeekyHBomb;40817696]My guess would be that most graphics hardware talks floating-point, so to skip a conversion step for most hardware they use floating-point as arguments.[/QUOTE]
Also probably this. :v:
I'm pretty sure you can get more different values with a 32-bit integer (in range [0..2^32-1]) than a 32-bit float in range [0..1].
[QUOTE=ZeekyHBomb;40818419]I'm pretty sure you can get more different values with a 32-bit integer (in range [0..2^32-1]) than a 32-bit float in range [0..1].[/QUOTE]
Possibly, I'm not really sure in all honesty. I just remember reading it somewhere as a theoretical advantage. :v:
[QUOTE=ZeekyHBomb;40818419]I'm pretty sure you can get more different values with a 32-bit integer (in range [0..2^32-1]) than a 32-bit float in range [0..1].[/QUOTE]
You get a little under half the possible values when using a float, actually. Because of the way the exponent is encoded, the "decimal" (binary, actually) point moves around ("floats" around, hence "floating point"). You only miss one bit in the exponent because of the binary-offset encoding, and that's about half.
But that's irrelevant anyway because the precision of a float between 0 and 1 is the difference between 0.5 and 0.50000006, and I doubt the human eye can tell the difference. Hell, I'm not even sure if monitors can properly display the difference.
More generally, GPUs are highly specialized to work with floating points. It was just in OpenGL 3 or so that integer support was finally added to the specification.
I need help with writing compilable and well commented but meaningless function c++ program that demonstrates a working knowledge of all the items in [url="http://www.cplusplus.com/doc/tutorial/"]this tutorial[/url] from top to bottom up to and including polymorfism and some kind of very basic graphical interface.
Yes it's my homework. I'll pay €10 to the person who does this work for me. Payment will be via bank transfer or bitcoins once it has been given a passing grade. The due date is midnight 30/5 so in just under 48 hours.
Not gonna defend this ethically but if someone wants to make a quick tenner for an hour or so of work, go for it. Contact me via chipset31 at gmail dot com
[QUOTE=ECrownofFire;40819836]You get a little under half the possible values when using a float, actually. Because of the way the exponent is encoded, the "decimal" (binary, actually) point moves around ("floats" around, hence "floating point"). You only miss one bit in the exponent because of the binary-offset encoding, and that's about half.[/QUOTE]
A quarter. The sign bit and the highest exponent bit remain unused in the range 0-1.
[QUOTE=chipset;40820031]I need help with writing compilable and well commented but meaningless function c++ program that demonstrates a working knowledge of all the items in [url="http://www.cplusplus.com/doc/tutorial/"]this tutorial[/url] from top to bottom up to and including polymorfism and some kind of very basic graphical interface.
Yes it's my homework. I'll pay €10 to the person who does this work for me. Payment will be via bank transfer or bitcoins once it has been given a passing grade. The due date is midnight 30/5 so in just under 48 hours.
Not gonna defend this ethically but if someone wants to make a quick tenner for an hour or so of work, go for it. Contact me via chipset31 at gmail dot com[/QUOTE]
You know, taking this job could be really shady depending on jurisdiction.
You're not exactly anonymously posting here either :v:
[QUOTE=Tamschi;40820219]You know, taking this job could be really shady depending on jurisdiction.
You're not exactly anonymously posting here either :v:[/QUOTE]
Not like anyone at my school even knows about facepunch.
[QUOTE=ThePuska;40820061]A quarter. The sign bit and the highest exponent bit remain unused in the range 0-1.[/QUOTE]
Yeah, yeah, I assumed a signed integer because then it's not much of a fair comparison :P
[QUOTE=chipset;40820031]I need help with writing compilable and well commented but meaningless function c++ program that demonstrates a working knowledge of all the items in [url="http://www.cplusplus.com/doc/tutorial/"]this tutorial[/url] from top to bottom up to and including polymorfism and some kind of very basic graphical interface.
Yes it's my homework. I'll pay €10 to the person who does this work for me. Payment will be via bank transfer or bitcoins once it has been given a passing grade. The due date is midnight 30/5 so in just under 48 hours.
Not gonna defend this ethically but if someone wants to make a quick tenner for an hour or so of work, go for it. Contact me via chipset31 at gmail dot com[/QUOTE]
Why even do a programming course if you're not going to learn?
I have been working on some basic OpenGL lately and now I tried putting that knowledge to practice by making a small wrapper for drawing stuff. For some reason it seems that the VAO changes to a really high number before being bound, can anyone help me out with this ? it's been bugging me for days.
[url]https://dl.dropboxusercontent.com/u/28926055/OpenGL.rar[/url]
[QUOTE=dvondrake;40825175]Use 'this' for member variables and methods. It may sometimes work as intended without, but eventually it'll start to fuck up and access uninitialized objects/memory.
Changing that line to "this->m_VertexDeclaration->Bind();" got it compiling.[/QUOTE]
You only need to use the this pointer if a parameter hides a member variable/function or if you need access to the class instance that the function is being called on directly (for example, returning it to allow chain calls).
[QUOTE=Jookia;40823743]Why even do a programming course if you're not going to learn?[/QUOTE]
I did learn. As the only one in the class with any previous programming knowledge I spent my time messing around, learning about new languages, developing for other platforms and some game development. My teacher thinks I'm worthy of top grade in the class but he needs actual concrete submitted work to grade me on. Problem is I have about 6 other assignments that needs doing by the same deadline so I really don't have time. Doesn't help that for the past year or so I've not touched c++ and done little programming in general. So if someone wants to do it for me in exchange for a decent wage (considering the amount of work) they're welcome to do so.
[QUOTE=dvondrake;40825241]Still better practice to use it than to not, that way you don't even have to worry about such conditions. If you have a better suggestion though, perhaps you can take a look at his code and actually be helpful?[/QUOTE]
I am being helpful by pointing out that you were wrong.
[QUOTE=dvondrake;40825301]That doesn't help quincy18, though. At the end of the day, my suggestion got his code compiling. While I may be wrong, your "help" in no way helps quincy18. Maybe I am wrong, I'll happily admit that and be open to learning something new. However, it got his code working. In a thread where people post their problems asking for help expecting answers, that should be all that matters. While you may be completely correct, your post does not help quincy18. If you're going to say I'm wrong, that's fine, but provide an alternative solution or you're really doing no good.
Assuming you're saying I'm wrong about using 'this' being good practice (because dumb ratings tend to be rather vague), is it really such a bad practice? I see absolutely no downside.[/QUOTE]
You are wrong about not using the this pointer resulting in accessing uninitialized objects/memory. My post wasn't directed at quincy18 and thus wasn't intended to help him, I was just pointing out to you and others who may be reading that what you said is, in fact, incorrect.
[editline]29th May 2013[/editline]
We don't want people doing things that are unnecessary because of something that isn't correct.
[editline]29th May 2013[/editline]
The dumb rating was because of the "bitchy" response.
I use UpperCamelCase for member-stuff and lowerCamelCase for global and local stuff.
Usage of this-> usually bothers me, but I don't think it's bad practice since I see it in many code bases. Before I adopted that mentioned convention I used -Wshadow and not duplicate those names.
[QUOTE=dvondrake;40825301]That doesn't help quincy18, though. At the end of the day, my suggestion got his code compiling. While I may be wrong, your "help" in no way helps quincy18. Maybe I am wrong, I'll happily admit that and be open to learning something new. However, it got his code working. In a thread where people post their problems asking for help expecting answers, that should be all that matters. While you may be completely correct, your post does not help quincy18. If you're going to say I'm wrong, that's fine, but provide an alternative solution or you're really doing no good.
Assuming you're saying I'm wrong about using 'this' being good practice (because dumb ratings tend to be rather vague), is it really such a bad practice? I see absolutely no downside.[/QUOTE]
The downside is using a keyword that means something in a place where it means nothing. It's confusing and makes for unreadable code.
Using this is in no way bad practice. Using it in places where you shouldn't however is.
javax.swing / java.awt
When am I supposed to use the two together? I've heard that combining components from .awt and .swing is generally not a good idea, is this true? In terms of drawing things for games, should I draw to a Canvas or JPanel or something else?
Bleh.
[QUOTE=toaster_2.0;40817606]Why does openGL use floats from 0f to 1f?
example:
[code]
glClearColor(0, 0, 0, 1);
[/code]
[editline]28th May 2013[/editline]
Also, why does it use values between 0 and 1 and not, for example, 0 - 255?[/QUOTE]
I think it's because not all hardware now (or in the future) uses exactly 8 bits for a channel. Normalizing the channel value makes it uniform across all hardware. Think about it: if we would use 16-bit color channels in the future, this would mean that there would be 65536 color values. Then they would need to change the range from 0 - 255 to 0 - 65535, or else it would look stupid. But with floats, it can stay like that.
[QUOTE=Shotgunz;40825648]javax.swing / java.awt
When am I supposed to use the two together? I've heard that combining components from .awt and .swing is generally not a good idea, is this true? In terms of drawing things for games, should I draw to a Canvas or JPanel or something else?
Bleh.[/QUOTE]
You'll generally use both awt as well as swing. I have no idea why it would be a bad idea to combine components, you pretty much have to as things like Graphic, Image, Dimension are awt and JPanels etc are swing.
I have to do a project next term. It can be anything really, so why not do a programming project? I thought of it for a bit, and I think I either want to make something having to do with sound processing, or a 3D game. If I do decide to make a game, I want it in a really "clean" style, and with simple, yet fun game rules. I've thought of the idea of the player controlling a sphere and perhaps chasing other spheres. Any other ideas for this or something with sound processing?
Is this where I can ask where an inexperienced wannabe programmer should start? Which language and which guides/books/tips to get me started off?
[QUOTE=PredGD;40831261]Is this where I can ask where an inexperienced wannabe programmer should start? Which language and which guides/books/tips to get me started off?[/QUOTE]
Have a look at [url=http://facepunch.com/showthread.php?t=1273159]this thread[/url], use version control (I recommend Mercurial with TortoiseHg.), start very very small and be patient.
Don't give up! Programs are usually more complicated to make than it seems but you will start to get faster eventually.
Sorry, you need to Log In to post a reply to this thread.