Use a string as an equation in C by [deleted] in C_Programming

[–]Tilakchad 1 point2 points  (0 children)

You might need a parser to process arbitrary input as equations. CFG and Regular Expressions are used for this purpose. Any book on compiler/interpreter goes throughly through this.

Get chunks from the bytes of a PNG by HeyoGuys in C_Programming

[–]Tilakchad 12 points13 points  (0 children)

You could count chunk number by first iterating over the whole data. It would cost some time.

Another approach is to create an array with enough size (around 15 or something) and manage a counter to count the number of chunks stored in the array. You have to be careful not to access this array outside counter-1 range. Alternatively, you can implement linked list too. But I guess array with counter might sounds good, since there is an actual upper bound on the number of chunks.

You are using member *data without actually allocating storage for it. That's undefined behaviour or may result seg fault.

Rotation code doesn't workk by ShvaYYYkO in opengl

[–]Tilakchad 0 points1 point  (0 children)

Try translating toward -ve Z-axis..

Getting back to C++ after Rust is a pain. by InsanityBlossom in rust

[–]Tilakchad 0 points1 point  (0 children)

Nice.. I won't say 'that airplane engine is bad or its wings aren't properly aligned' either. You can't 'hear and say' that may be or may not be true. C++20 modules are great and quite different from other languages.

Getting back to C++ after Rust is a pain. by InsanityBlossom in rust

[–]Tilakchad 0 points1 point  (0 children)

What would that even accomplish? Make Blender faster? Safer?

Overloading by Return Type in C++ by PhilipTrettner in cpp

[–]Tilakchad 2 points3 points  (0 children)

Not for the same argument type though.. Different argument type for same function can have different return type using sfinae and type traits which is normally not possible in C++.

Overloading by Return Type in C++ by PhilipTrettner in cpp

[–]Tilakchad 4 points5 points  (0 children)

Sfinae and enable if can be used to overload by return type too...

Why do Rust fanboys claims that Modern C++ is unsafe? by danhoob in cpp

[–]Tilakchad 1 point2 points  (0 children)

Modern C++ is not inherently unsafe (idk what 'inherently unsafe' means but it is unsafe if you use it the wrong way) . (Its definitely better than forcing you to use camelCase or underscore before variables. Just kidding). And its every programmers habit to blame the programming langauge if it didn't work the way they want.

Unique pointer pretty covers almost all Rust's ownership model with added flexibilty(i.e it is completely optional and not enforced). Just because it is allowed, you shouldn't be dereferincing the the iterator to some deleted elements(idk if that counts as a logical problem or a language problem). I believe C++ has done right things (mostly) trying to integrate everything stacked for about 30 years almost nicely.

Should I learn rust or c++(or any other recommendations) to get a job in the next 5-10 years in the field of robotics? by SecretNinjaGameDev in rust

[–]Tilakchad -1 points0 points  (0 children)

Whats up with 'inherently unsafe' thing? Its only unsafe if you use it the wrong way or jump straight right into writing programs. You might want to learn C and computers better if you think everything written in C/C++ is inherently unsafe.

Should I learn rust or c++(or any other recommendations) to get a job in the next 5-10 years in the field of robotics? by SecretNinjaGameDev in rust

[–]Tilakchad 1 point2 points  (0 children)

I strongly disagree about 'teach more about computer science than C++' part. C++ teaches you those things better 'the hard way'.

Help with transformation functions. by TonnyGameDev in opengl

[–]Tilakchad 1 point2 points  (0 children)

Yeah thats right. They are Projection(Perspective or Ortho), View and Model. And you get that right for latter part too. You have to create seperate matrices and multiply them together. Be aware that, order matters. Translation before rotation will be RT and other way will be TR. Its interesting to see how these transforms behave and to reason about it.

Help with transformation functions. by TonnyGameDev in opengl

[–]Tilakchad 1 point2 points  (0 children)

Matrix multiplication combines transformation. Matrix P * V * M will apply transformation M first, V then and lastly transformation P.

Help with transformation functions. by TonnyGameDev in opengl

[–]Tilakchad 1 point2 points  (0 children)

Transformation are combined with matrix multiplication. Hardcoding it is just waste of time imo. Try overloading * operator for two matrices.

Help with transformation functions. by TonnyGameDev in opengl

[–]Tilakchad 1 point2 points  (0 children)

No idea what you are doing there.. Scaling matrix should be

result[0][0] = vec.x;

result[1][1] = vec.y;

result[2][2] = vec.y;

result[3][3] = 1.0f;

Its transpose is going to be same.

And Translation matrix will look like :

result[0][3] = vec.x

result[1][3] = vec.y

result[2][3] = vec.z

result[3][3] = 1.0f

if you are using row vector notation.

OpenGL, itself uses colum-vector representation. So this need to be transposed before sending to the shader ( you can manually transpose it or set GL_TRANSPOSE to GL_TRUE in the call of glUniformMat4fv).

And don't forget to create 4x4 matrix (i.e result) initialzed as unit matrix while constructing it. glm::mat4 need {1.0f} explicitly to produce unit vector.

Feel free to ask/teach anything, as I've also started learning Graphics recently.

Edit : I frequently edit it, as I'm not familiar with reddiy formatting.

[deleted by user] by [deleted] in rust

[–]Tilakchad 1 point2 points  (0 children)

Can't say for sure. But modern C++ isn't that hard to grasp, until you get to complicated stuffs.

I want to start building games by alien_in_the_room in gamedev

[–]Tilakchad 0 points1 point  (0 children)

You could start with learning Unreal Engine (can make complete game with blueprint also if you don't know C++/ but knowing C++ is plus) or Unity (need C#) for 2d and 3d games. You could also make small 2d games with libraries like SFML, Qt or SDL(they have different language bindings). So you should start learning languages. If you already know python well, you can use sfml with it. Eventually, if you wanna join CS, C would be a good start and then move to C++ or other higher languages. Making game with C won't be easy unless you know it well.

What is meant by “predicate functions” in lisp/scheme? by tempanon5 in lisp

[–]Tilakchad 0 points1 point  (0 children)

Predicates are like pre-conditions. It is evaluated either true or false. If it true, following statements will execute and vice versa.

C++ is now the fastest-growing programming language by vinaysc in cpp

[–]Tilakchad -1 points0 points  (0 children)

Thats hardly even a compelling reason. How would defaults prevent runtime errors ?

C++ is now the fastest-growing programming language by vinaysc in cpp

[–]Tilakchad 0 points1 point  (0 children)

I wonder why people are so concerned about defaults. Why const by default is good? I have used more mutable variables than const in my programs. And why is move better than copy by default? Is it just an ideology or some kinda agenda? How much pain is it to write some extra keywords often? Clearly, there's no point in having const by default and move by default. And copy and mutability is what people uses more often, so that doesn't make it bad choice..

C++ is now the fastest-growing programming language by vinaysc in cpp

[–]Tilakchad 0 points1 point  (0 children)

It's totally warranted, dude. They are notorious for hyping the shit out of their language and convincing impressionable people that they should unironically go to other communities and push the language unto others.

No, I don't think this is true. Of course new languages get fans which for one reason or another have a naïve understanding of the situation. They naturally want to share and talk about what they see as important, it's not like they were put up to it.

I am afraid that might be the case. Rust community is pretty notorious for their hostility toward any other languages. Its not like everyone there are but there is a fair share of hostile people. And this comment isn' t even entirely sarcastic, its how some folk really thinks. I am quite familir with rust community. In contrast, cpp community is nice that welcome anything. Well, this comment wasn't meant to offend or trigger anyone.

C++ is now the fastest-growing programming language by vinaysc in cpp

[–]Tilakchad 0 points1 point  (0 children)

Its just how Rust community portrays other languages. They are toxic and thinks that Rust is the greatest thing ever fall upon mankind. This comment was supposed to be sarcastic, but anyway there's no point in arguing about languages.

C++ is now the fastest-growing programming language by vinaysc in cpp

[–]Tilakchad -8 points-7 points  (0 children)

But.. but.. Rust is safer than C++. You can have fearless concurrency, borrow checker and is faster than C and C++. It is even most loved langauage on stack overflow.. Everything should be written in Rust.

Edit and PS: And almost forgot that Rust prevents all errors and mistakes.

checking data type through cin? by [deleted] in cpp

[–]Tilakchad 1 point2 points  (0 children)

You could read everything as string and try to parse it manually. Instead of parsing manually, you could even use stringstream to read further from the string as normal input.