I have a problem with my code, and I don't understand why it is not working.
I'm learing to use OpenGL to draw stuff on the screen, and I have gotten pretty far honestly, but I was just messing with a struct to group light properties and I don't know how to proceed.
The struct code is the following:
//outside of main()
struct lightProperties {
glm::vec3 dirDirection = glm::vec3(-0.2f, -0.3f, -0.5f);
glm::vec3 dirAmbient = glm::vec3(1.0f);
glm::vec3 dirDiffuse = glm::vec3(1.0f);
glm::vec3 dirSpecular = glm::vec3(1.0f);
float matShininess = 20.0f;
}
//inside the main()
lightProperties light;
I am in the process of including ImGui in my project, so I was setting up all the functions that modified the uniforms. I have this function in particular, written in a header file:
//ImGui_functions.h
void imguiDrawmenu(struct lightProperties* light) {
ImGui::Begin("OpenGl", NULL ,ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoResize);
if (ImGui::CollapsingHeader("Directional Light")) {
ImGui::SliderFloat3("Direction", glm::value_ptr(light->dirDirection), -1.0f, 1.0f);
}
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
And then I call the functions inside the main while
loop of the program as such:
imguiDrawmenu(&light);
At first, I thought that I just needed to pass the struct as a reference, but it just didn't work for some reason. But then, I realized that the function just recieves a pointer, so when I use the .
operator, the program doesn't know that my pointer has member variables, for obvious reasons. I then read about the arrow operator, ->
, that supposedly is used to reference member variables of a pointed class/struct, but I don't understand why it is not working.
The error is the following:
C2027 use of undefined type 'lightProperties'