Fix bug with flicker
This commit is contained in:
parent
3f62438460
commit
dea910ca2c
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
PlanetCreator/PlanetCreator.vcxproj.filters
|
||||
PlanetCreator/PlanetCreator.vcxproj.user
|
||||
PlanetCreator/PlanetCreator/.vs/
|
||||
PlanetCreator/cw 6/PlanetCreator.vcxproj.filters
|
||||
PlanetCreator/cw 6/PlanetCreator.vcxproj.user
|
||||
PlanetCreator/.vs/
|
||||
.vs/
|
||||
PlanetCreator/Debug/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,8 +2,8 @@
|
||||
main.cpp
|
||||
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
|
||||
j:\Desktop\grk\Grafika2023\PlanetCreator\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
|
||||
j:\Desktop\grk\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(76,16): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
j:\Desktop\grk\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(135,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
j:\Desktop\grk\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(109,16): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
j:\Desktop\grk\Grafika2023\PlanetCreator\cw 6\src\ex_6_1.hpp(168,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
|
||||
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
|
||||
grk-cw6.vcxproj -> j:\Desktop\grk\Grafika2023\PlanetCreator\Debug\grk-cw6.exe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,3 +6,11 @@ Size=400,400
|
||||
Pos=270,87
|
||||
Size=205,58
|
||||
|
||||
[Window][Control Panel]
|
||||
Pos=4,3
|
||||
Size=218,129
|
||||
|
||||
[Window][Dodawanie nowej planety]
|
||||
Pos=9,13
|
||||
Size=260,108
|
||||
|
||||
|
@ -69,6 +69,39 @@ glm::mat4 createCameraMatrix()
|
||||
return cameraMatrix;
|
||||
}
|
||||
|
||||
void renderImGui() {
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Начало нового кадра ImGui
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Создание окон и элементов ImGui
|
||||
ImGui::Begin("Dodawanie nowej planety");
|
||||
|
||||
// Добавление слайдеров для "Влажности" и "Осадков"
|
||||
static float humidity = 0.0f; // Начальное значение для влажности
|
||||
static float precipitation = 0.0f; // Начальное значение для осадков
|
||||
ImGui::SliderFloat("Wilgotnosc", &humidity, 0.0f, 100.0f); // Слайдер для влажности
|
||||
ImGui::SliderFloat("Opady", &precipitation, 0.0f, 100.0f); // Слайдер для осадков
|
||||
|
||||
// Добавление кнопок "Очистить" и "Добавить"
|
||||
if (ImGui::Button("Wyczyscic")) {
|
||||
// Логика обработки кнопки "Очистить"
|
||||
}
|
||||
ImGui::SameLine(); // Расположить следующую кнопку на той же линии
|
||||
if (ImGui::Button("Dodac")) {
|
||||
// Логика обработки кнопки "Добавить"
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// Рендеринг ImGui
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
glm::mat4 createPerspectiveMatrix()
|
||||
{
|
||||
|
||||
@ -130,7 +163,7 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
|
||||
void renderScene(GLFWwindow* window)
|
||||
{
|
||||
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glm::mat4 transformation;
|
||||
float time = glfwGetTime();
|
||||
|
||||
@ -146,8 +179,8 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
drawObjectColor(plant2Context, plantModelMatrix, glm::vec3(1,1,1), program);
|
||||
drawObjectColor(plant3Context,glm::translate(glm::vec3(1.0f, 0.5f, 3.0f)) *glm::scale(glm::vec3(0.03f)) *glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)),glm::vec3(1, 1, 1), program);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
//glfwSwapBuffers(window);
|
||||
}
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
@ -202,7 +235,7 @@ void shutdown(GLFWwindow* window)
|
||||
//obsluga wejscia
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
float cameraSpeed = 0.001f;
|
||||
float cameraSpeed = 0.1f;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
@ -239,29 +272,25 @@ void processInput(GLFWwindow* window)
|
||||
//}
|
||||
////}
|
||||
|
||||
|
||||
|
||||
|
||||
void renderLoop(GLFWwindow* window) {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
|
||||
// ImGui кадр
|
||||
//ImGui_ImplOpenGL3_NewFrame();
|
||||
//ImGui_ImplGlfw_NewFrame();
|
||||
//ImGui::NewFrame();
|
||||
|
||||
//// Создание ImGui окон и элементов
|
||||
//ImGui::Begin("Demo window");
|
||||
//ImGui::Text("Hello, ImGui!");
|
||||
//// Добавьте другие элементы управления здесь
|
||||
//ImGui::End();
|
||||
processInput(window);
|
||||
renderScene(window);
|
||||
glfwPollEvents();
|
||||
//ImGui::Render();
|
||||
processInput(window); // Обработка ввода
|
||||
|
||||
//glClear(GL_COLOR_BUFFER_BIT); // Очистка экрана
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
//glfwSwapInterval(1);
|
||||
//glfwSwapBuffers(window);
|
||||
// Рендеринг сцены
|
||||
renderScene(window);
|
||||
|
||||
// Рендеринг ImGui
|
||||
renderImGui();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ int main(int argc, char** argv)
|
||||
return -1;
|
||||
}
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
// ladowanie OpenGL za pomoca glew
|
||||
glewInit();
|
||||
|
Loading…
Reference in New Issue
Block a user