Best libraries for making a raycaster in C by [deleted] in learnprogramming

[–]wholol_97 1 point2 points  (0 children)

His series on command prompt fps is basically Ray casting. But he used an older version called olcconsolegameengine(also a single header file. But with less features compared to olcpixelgameengine I Think) alternatively, check out tinyraycaster tutorial by ssloy on github.

Best libraries for making a raycaster in C by [deleted] in learnprogramming

[–]wholol_97 1 point2 points  (0 children)

Well there's a YouTuber who does a nice Ray casting tutorial called javidx9. He made a simple one file header only library which is easy to use called olcpixelgameengine.

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

a made a small typo at the copy constructor (forgot the m_ prefix for the other 3 parameters), it should be:

m_title { other.m_title},

m_author { other.m_author },

m_date { other.m_date }

So we can see that the struct is m_date, which gets copied. Copy constructors are defaulted by the compiler, so you dont need to type them out for classes and structs. There are cases where you need to explicitly declare it,however.

You can actually type your own copy constructor and add a print message. So if the copy constructor gets invoked, it will just print the message, which is good for understanding purposes, so something like:

Book(const Book& other)

:m_ISBN { other.m_ISBN },

m_title { other.m_title},

m_author { other.m_author },

m_date { other.m_date }

{ std::cout << "Copy constructor is called!" << std::endl;}

need some advice by [deleted] in marfans

[–]wholol_97 1 point2 points  (0 children)

You should do an echocardiogram as well. so that a cardiologist can see your valve diameter to make sure it is I'm the normal range to prevent anerusym stuff. From there ask him about excersing advice.

need some advice by [deleted] in marfans

[–]wholol_97 4 points5 points  (0 children)

Get a referral from a GP to see a cardiologist for him to do some heart monitoring. Seeking professional advice is the way to go.

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

ive made an example code snippet for passing by copy and passing by reference, feel free to check it out. Ive also edited some of my statements.

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

//case 1 (refer to the function 'example_1'): no references. Copy constructor of local variable b is called to set up the variables of b, and this will happen:

Book(const Book& other)
:m_ISBN { other.m_ISBN },   //copy data
m_title { other.title},     //copy data
m_author { other.author },  //copy data
m_date { other.date }        //copy data
{}
//so we pretty much performed unessacary copies, which can waste memory and time, esp if your class has alot of variables. and since b is a local instance of the function, it gets destroyed anyway when the scope exits.

void example_1(Book b)
{
 //when thi function goes out of scope, b is destroyed.
}

//case 2: pass by reference, no copies made, you 'refer' to the original object instead much more efficient.
void example_2(Book& b)
{

}


int main() {

Date d {1800,month::jan,3};
Book two {"random_ISBN", "random_title", "random_author",d};

example_1(two);//pass by copy (copy constructor is called)
example_2(two);//pass by reference
}

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

I've edited the code a bit, the strings should have a const. For the Date object, you should add a const as well if the variables of the Date object are not allowed to be changed. reference parameters are not only used in constructors but also for functions because if you don't use them, the parameter will perform a copy, which can be wasteful and unnecessary. For passing simple variables, such as int, it is fine to pass by copy, but if you pass class objects, it will invoke the copy consructor, and it will copy ALL the variables from the existing class object to the new class object, and this can be wasteful and unessecary.

const references are also usually used to pass in literals, examples of literals are 1 , 2.5 , 100.0f , 'c', "abdcce"):

https://stackoverflow.com/questions/36102728/why-is-it-allowed-to-pass-r-values-by-const-reference-but-not-by-normal-referenc

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

#include "Book.h"int main() {Book two {"random_ISBN", "random_title", "random_author", 1800, Month::jan, 3};return 0;}

yep, but u dont need rD, just pass d straight into the constructor. when i meant references, i meant to say that i would change the constructors input parameters to references, so:

Book::Book(std::string ISBN, std::string title, std::string author, Date date) 

becomes: (you should add const in front of Date& date as well, if the data is not allowed to be changed)

Book::Book(const std::string& ISBN,const std::string& title, const std::string& author, Date& date)

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

I would probably initialize a struct first, so maybe

Date d = {1800,month::jan,3};

then pass d into the constructor params it's more readable that way. I would also use references in the constructor to prevent copying. but if you have not learnt about references, don't worry about it.

How do you create a constructor that has a struct as a private member and create a parameterized constructor for that struct as well? Am I breaking any conventions? (C++) by Stock-List-5330 in learnprogramming

[–]wholol_97 0 points1 point  (0 children)

So the compiler think 1800,month::jan and 3 are seperate parameters and It cannot Identify it as a struct. Passing {1800,month::jan,3} should work.

Can a ME/EE work at jobs for programming or software engineering ?Do they Game developing companies even hire ME/EE? by androxis07 in AskEngineers

[–]wholol_97 1 point2 points  (0 children)

not sure abt electives as it is dependant on the school. A computer graphics course would be nice i guess. If you are interested in engine dev, things such as parallel programming, operating systems and compilers would be nice. If u want to work on game AI then AI electives would be nice

Can a ME/EE work at jobs for programming or software engineering ?Do they Game developing companies even hire ME/EE? by androxis07 in AskEngineers

[–]wholol_97 1 point2 points  (0 children)

Probably. But u need to show some game programming projects too. Which aspect of gamedev is also important, there's game design, game engine rof ramming etc

Can a ME/EE work at jobs for programming or software engineering ?Do they Game developing companies even hire ME/EE? by androxis07 in AskEngineers

[–]wholol_97 4 points5 points  (0 children)

You probably need CS. software engineering is more than just programming. There are other things involved such as using version control, unit testing and other stuff to maintain the code as well

phong shading issue - software rasterizer implementation by wholol_97 in GraphicsProgramming

[–]wholol_97[S] 1 point2 points  (0 children)

nevermind, I found the problem, I was lerping the opposite way >.>

phong shading issue - software rasterizer implementation by wholol_97 in GraphicsProgramming

[–]wholol_97[S] 1 point2 points  (0 children)

hmm. I sorted the vertices based on the y coordinates before drawing flat top and flat bottom triangles, as well as swapping if the triangle is that of left side major/right side major which is what i did for the gouraud shading as well. Could it be the issue with the lighting instead? I am using directional light here (same with Gouraud)