implementacja_obrotu_monety

This commit is contained in:
s473595 2024-02-28 10:14:39 +01:00
parent c1ab946f11
commit a865001f9f
26 changed files with 624 additions and 622 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,91 +1,109 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\maksg\\Documents\\Grafika_2024\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "shader_coin.frag",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.frag",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.frag",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAaAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-26T19:01:49.259Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "shader_coin.vert",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.vert",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.vert",
"ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAiAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-26T19:01:39.656Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "ex_7_1.hpp",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\ex_7_1.hpp",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeToolTip": "projekt_grk\\src\\ex_7_1.hpp",
"ViewState": "AQIAAPwAAAAAAAAAAAAYwP8AAAAaAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-02-25T17:55:58.673Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "main.cpp",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\main.cpp",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp",
"RelativeToolTip": "projekt_grk\\src\\main.cpp",
"ViewState": "AQIAABcAAAAAAAAAAAAtwCYAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-02-26T20:07:44.538Z"
}
]
}
]
}
]
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\maksg\\Documents\\Grafika_2024\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_5_1_tex_copy.frag||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 4,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "shader_5_1_tex_copy.frag",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"RelativeToolTip": "projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-28T08:58:43.519Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "shader_coin.frag",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.frag",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.frag",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAbAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-26T19:01:49.259Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "shader_coin.vert",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.vert",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.vert",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAoAAAA9AAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-26T19:01:39.656Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "ex_7_1.hpp",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\ex_7_1.hpp",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeToolTip": "projekt_grk\\src\\ex_7_1.hpp",
"ViewState": "AQIAAIEAAAAAAAAAAAAowJkAAAAYAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-02-25T17:55:58.673Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "main.cpp",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\main.cpp",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\main.cpp",
"RelativeToolTip": "projekt_grk\\src\\main.cpp",
"ViewState": "AQIAABcAAAAAAAAAAAAtwCYAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2024-02-26T20:07:44.538Z",
"EditorCaption": ""
}
]
}
]
}
]
}

Binary file not shown.

Binary file not shown.

View File

@ -1,19 +1,22 @@
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj, grk-cw6.vcxproj, grk-cw7.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
zobacz poprzednią definicję „APIENTRY”
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(93,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(205,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(223,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw7.vcxproj -> C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj, grk-cw6.vcxproj, grk-cw7.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
zobacz poprzednią definicję „APIENTRY”
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(93,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(139,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(210,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(228,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw7.vcxproj -> C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe

Binary file not shown.

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

View File

@ -1,10 +1,10 @@
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Box.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Box.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Camera.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Camera.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\main.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\main.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Render_Utils.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Render_Utils.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Shader_Loader.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Shader_Loader.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\image_DXT.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\image_DXT.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\image_helper.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\image_helper.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\SOIL.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\SOIL.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\stb_image_aug.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\stb_image_aug.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Texture.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Texture.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Box.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Box.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Camera.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Camera.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\main.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\main.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Render_Utils.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Render_Utils.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Shader_Loader.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Shader_Loader.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\image_DXT.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\image_DXT.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\image_helper.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\image_helper.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\SOIL.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\SOIL.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\SOIL\stb_image_aug.c;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\stb_image_aug.obj
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\Texture.cpp;C:\Users\maksg\Documents\Grafika_2024\projekt_grk\Debug\Texture.obj

View File

@ -1 +1 @@
^C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\BOX.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\CAMERA.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_DXT.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_HELPER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\MAIN.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\RENDER_UTILS.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SHADER_LOADER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SOIL.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\STB_IMAGE_AUG.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\TEXTURE.OBJ
^C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\BOX.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\CAMERA.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_DXT.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_HELPER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\MAIN.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\RENDER_UTILS.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SHADER_LOADER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SOIL.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\STB_IMAGE_AUG.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\TEXTURE.OBJ

View File

@ -1,2 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
Debug|Win32|C:\Users\maksg\Documents\Grafika_2024\|
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
Debug|Win32|C:\Users\maksg\Documents\Grafika_2024\|

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>false</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@ -1,20 +1,12 @@
#version 430 core
in vec3 FragPos;
in vec3 Normal;
out vec4 FragColor;
uniform vec3 color;
void main()
{
vec3 lightColor = vec3(1.0, 1.0, 1.0);
vec3 lightDir = normalize(vec3(1.0, 1.0, 1.0));
float diff = max(dot(normalize(Normal), lightDir), 0.0);
vec3 diffuse = diff * lightColor;
FragColor = vec4(color * diffuse, 1.0);
}
#version 430 core
uniform vec3 color;
out vec4 FinalColor;
void main()
{
FinalColor = vec4(color, 1.0);
}

View File

@ -1,20 +1,13 @@
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
uniform mat4 transformation;
uniform mat4 modelMatrix;
out vec3 FragPos;
out vec3 Normal;
void main()
{
vec4 rotatedPosition = modelMatrix * vec4(vertexPosition, 1.0);
gl_Position = transformation * rotatedPosition;
Normal = mat3(transpose(inverse(transformation))) * vertexNormal;
FragPos = rotatedPosition.xyz;
}
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec3 vertexNormal;
uniform mat4 transformation;
uniform mat4 modelMatrix;
void main()
{
gl_Position = transformation * vec4(vertexPosition, 1.0);
}

View File

@ -1,447 +1,441 @@
#include "glew.h"
#include <GLFW/glfw3.h>
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Texture.h"
#include "Box.cpp"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <string>
#include "SOIL/SOIL.h"
namespace texture {
GLuint mercury;
GLuint venus;
GLuint earth;
GLuint moon;
GLuint ship;
GLuint sun;
GLuint mars;
GLuint jupiter;
GLuint saturn;
GLuint uranus;
GLuint neptune;
GLuint mercuryNormal;
GLuint venusNormal;
GLuint earthNormal;
GLuint asteroidNormal;
GLuint shipNormal;
GLuint marsNormal;
GLuint jupiterNormal;
GLuint saturnNormal;
GLuint uranusNormal;
GLuint neptuneNormal;
GLuint grid;
}
GLuint program;
GLuint programSun;
GLuint programTex;
GLuint programEarth;
GLuint programProcTex;
GLuint programSkyBox;
GLuint programCoin;
Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext;
Core::RenderContext sphereContext;
Core::RenderContext cubeContext;
Core::RenderContext cylinderContext;
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
GLuint VAO,VBO;
float aspectRatio = 1.f;
unsigned int textureID;
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide,cameraDir));
glm::mat4 cameraRotrationMatrix = glm::mat4({
cameraSide.x,cameraSide.y,cameraSide.z,0,
cameraUp.x,cameraUp.y,cameraUp.z ,0,
-cameraDir.x,-cameraDir.y,-cameraDir.z,0,
0.,0.,0.,1.,
});
cameraRotrationMatrix = glm::transpose(cameraRotrationMatrix);
glm::mat4 cameraMatrix = cameraRotrationMatrix * glm::translate(-cameraPos);
return cameraMatrix;
}
glm::mat4 createPerspectiveMatrix()
{
glm::mat4 perspectiveMatrix;
float n = 0.05;
float f = 20.;
float a1 = glm::min(aspectRatio, 1.f);
float a2 = glm::min(1 / aspectRatio, 1.f);
perspectiveMatrix = glm::mat4({
1,0.,0.,0.,
0.,aspectRatio,0.,0.,
0.,0.,(f+n) / (n - f),2*f * n / (n - f),
0.,0.,-1.,0.,
});
perspectiveMatrix=glm::transpose(perspectiveMatrix);
return perspectiveMatrix;
}
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
GLuint prog = program;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(prog, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0,0,0);
Core::DrawContext(context);
}
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint normalMapId) {
GLuint prog = programTex;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0, 0, 0);
Core::SetActiveTexture(textureID, "colorTexture", prog, 0);
Core::SetActiveTexture(normalMapId, "normalSampler", prog, 1);
Core::DrawContext(context);
}
void drawCylinder(Core::RenderContext& context, glm::mat4 modelMatrix, float height, float radius, glm::vec3 color) {
GLuint prog = programCoin;
glUseProgram(prog);
// Rotate the modelMatrix to make the cylinder vertically oriented
modelMatrix = glm::rotate(modelMatrix, glm::radians(-90.0f), glm::vec3(1, 0, 0)); // Rotate around x-axis
modelMatrix = glm::scale(modelMatrix, glm::vec3(radius, height, radius)); // Scale
// Calculate model-view-projection matrix
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
// Set transformation matrices in the shader
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
// Set color and light position in the shader
glUniform3f(glGetUniformLocation(prog, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0, 0, 0);
// Draw the cylinder
Core::DrawContext(context);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID)
{
GLuint prog = programSun;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniform1f(glGetUniformLocation(prog, "exposition"), 1.f);
Core::SetActiveTexture(textureID, "sunTexture", prog, 0);
Core::DrawContext(context);
}
void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glDisable(GL_DEPTH_TEST);
glUseProgram(programSkyBox);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
GLint transformLoc = glGetUniformLocation(programSkyBox, "transformation");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(transformation));
GLint modelLoc = glGetUniformLocation(programSkyBox, "modelMatrix");
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glUniform3f(glGetUniformLocation(programSkyBox, "lightPos"), 0, 0, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
Core::DrawContext(context);
glEnable(GL_DEPTH_TEST);
}
void renderPlanet(float time, float orbitRadius, float orbitRotationSpeed, float selfRotationSpeed, float scale, GLuint planetTexture, GLuint normalTexture) {
glm::mat4 planetTransform = glm::rotate(glm::mat4(1.0f), time * orbitRotationSpeed, glm::vec3(0, 1, 0)) // orbitowanie dooko³a s³oñca
* glm::translate(glm::vec3(orbitRadius, 0, 0)) // translacja na odp. odleg³oœæ
* glm::rotate(glm::mat4(1.0f), time * selfRotationSpeed, glm::vec3(0, 1, 0)) //obrót planety wokó³ w³asnej osi
* glm::scale(glm::vec3(scale)); //skalowanie planety
drawObjectTexture(sphereContext, planetTransform, planetTexture, normalTexture);
}
void renderPlanets() {
float time = glfwGetTime();
float mercuryOrbitRadius = 1.3f;
float venusOrbitRadius = 2.0f;
float earthOrbitRadius = 5.0f;
float moonOrbitRadius = 0.8f;
float marsOrbitRadius = 8.0f;
float jupiterOrbitRadius = 10.0f;
float saturnOrbitRadius = 11.0f;
float uranusOrbitRadius = 12.5f;
float neptuneOrbitRadius = 13.0f;
// im mniejsze tym szybciej
float mercuryRotationSpeed = 1.0f / 10;
float venusRotationSpeed = 1.0f / 7;
float earthRotationSpeed = 1.0f / 6;
float moonRotationSpeed = 1.0f / 2;
float marsRotationSpeed = 1.0f / 5;
float jupiterRotationSpeed = 1.0f / 8.5;
float saturnRotationSpeed = 1.0f / 5;
float uranusRotationSpeed = 1.0f / 9;
float neptuneRotationSpeed = 1.0f / 10;
float mercurySelfRotationSpeed = 1.0f;
float venusSelfRotationSpeed = 1.0f;
float earthSelfRotationSpeed = 1.0f;
float moonSelfRotationSpeed = 1.0f / 2;
float marsSelfRotationSpeed = 1.0f;
float jupiterSelfRotationSpeed = 1.0f;
float saturnSelfRotationSpeed = 1.0f;
float uranusSelfRotationSpeed = 1.0f / 2;
float neptuneSelfRotationSpeed = 1.0f;
float mercuryScale = 0.11f;
float venusScale = 0.14f;
float earthScale = 0.3f;
float moonScale = 0.055f;
float marsScale = 0.2f;
float jupiterScale = 0.7f;
float saturnScale = 0.5f;
float uranusScale = 0.3f;
float neptuneScale = 0.32f;
renderPlanet(time, mercuryOrbitRadius, mercuryRotationSpeed, mercurySelfRotationSpeed, mercuryScale, texture::mercury, texture::mercuryNormal);
renderPlanet(time, venusOrbitRadius, venusRotationSpeed, venusSelfRotationSpeed, venusScale, texture::venus, texture::venusNormal);
renderPlanet(time, earthOrbitRadius, earthRotationSpeed, earthSelfRotationSpeed, earthScale, texture::earth, texture::earthNormal);
//earths moon, musi byæ inaczej renderowany bo on nie orbituje wokó³ s³oñca tylko ziemi. PóŸniej to mo¿na jakoœ lepiej rozwi¹zaæ.
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::eulerAngleY(time * moonRotationSpeed) * glm::translate(glm::vec3(moonOrbitRadius, 0, 0)) * glm::scale(glm::vec3(moonScale)),
texture::moon,
texture::asteroidNormal);
renderPlanet(time, marsOrbitRadius, marsRotationSpeed, marsSelfRotationSpeed, marsScale, texture::mars, texture::marsNormal);
renderPlanet(time, jupiterOrbitRadius, jupiterRotationSpeed, jupiterSelfRotationSpeed, jupiterScale, texture::jupiter, texture::jupiterNormal);
renderPlanet(time, saturnOrbitRadius, saturnRotationSpeed, saturnSelfRotationSpeed, saturnScale, texture::saturn, texture::saturnNormal);
renderPlanet(time, uranusOrbitRadius, uranusRotationSpeed, uranusSelfRotationSpeed, uranusScale, texture::uranus, texture::uranusNormal);
renderPlanet(time, neptuneOrbitRadius, neptuneRotationSpeed, neptuneSelfRotationSpeed, neptuneScale, texture::neptune, texture::neptuneNormal);
}
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//skybox
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
//sun
drawSun(sphereContext, glm::mat4(), texture::sun);
float cylinderHeight = 1.0f;
float cylinderRadius = 1.0f;
drawCylinder(cylinderContext, glm::translate(glm::vec3(5.0f, 0.0f, 0.0f)), cylinderHeight, cylinderRadius, glm::vec3(1.0f, 1.0f, 0.0f));
renderPlanets();
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
-spaceshipDir.x,-spaceshipDir.y,-spaceshipDir.z,0,
0.,0.,0.,1.,
});
//spaceship drawing
drawObjectTexture(shipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
texture::ship, texture::shipNormal
);
glUseProgram(0);
glfwSwapBuffers(window);
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
aspectRatio = width / float(height);
glViewport(0, 0, width, height);
}
void loadModelToContext(std::string path, Core::RenderContext& context)
{
Assimp::Importer import;
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
return;
}
context.initFromAssimpMesh(scene->mMeshes[0]);
}
void init(GLFWwindow* window)
{
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
//programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex_copy.vert", "shaders/shader_5_1_tex_copy.frag");
programEarth = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programProcTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
programCoin = shaderLoader.CreateProgram("shaders/shader_coin.vert", "shaders/shader_coin.frag");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext);
loadModelToContext("./models/cube.obj", cubeContext);
loadModelToContext("./models/cylinder.obj", cylinderContext);
texture::mercury = Core::LoadTexture("textures/mercury/mercury.jpg");
texture::venus = Core::LoadTexture("textures/venus/venus.jpg");
texture::earth = Core::LoadTexture("textures/earth/earth.png");
texture::ship = Core::LoadTexture("textures/spaceship/spaceship.jpg");
texture::moon = Core::LoadTexture("textures/earths_moon/moon.jpg");
texture::sun = Core::LoadTexture("textures/sun/sun.jpg");
texture::mars = Core::LoadTexture("textures/mars/mars.jpg");
texture::jupiter = Core::LoadTexture("textures/jupiter/jupiter.jpg");
texture::saturn = Core::LoadTexture("textures/saturn/saturn.jpg");
texture::uranus = Core::LoadTexture("textures/uranus/uranus.jpg");
texture::neptune = Core::LoadTexture("textures/neptune/neptune.jpg");
texture::mercuryNormal = Core::LoadTexture("textures/mercury/mercury_normal.png");
texture::venusNormal = Core::LoadTexture("textures/venus/venus_normal.png");
texture::earthNormal = Core::LoadTexture("textures/earth/earth_normal.png");
texture::shipNormal = Core::LoadTexture("textures/spaceship/spaceship_normal.jpg");
texture::asteroidNormal = Core::LoadTexture("textures/earths_moon/moon_normal.jpg");
texture::marsNormal = Core::LoadTexture("textures/mars/mars_normal.jpg");
texture::jupiterNormal = Core::LoadTexture("textures/jupiter/jupiter_normal.png");
texture::saturnNormal = Core::LoadTexture("textures/saturn/saturn_normal.png");
texture::uranusNormal = Core::LoadTexture("textures/uranus/uranus_normal.png");
texture::neptuneNormal = Core::LoadTexture("textures/neptune/neptune_normal.png");
//tutaj skybox start
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
std::vector<std::string> filepaths = {
"textures/skybox/right.png",
"textures/skybox/left.png",
"textures/skybox/top.png",
"textures/skybox/bottaom.png",
"textures/skybox/back.png",
"textures/skybox/front.png"
};
int w, h;
unsigned char* data;
for (unsigned int i = 0; i < 6; i++)
{
data = SOIL_load_image(filepaths[i].c_str(), &w, &h, 0, SOIL_LOAD_RGBA);
glTexImage2D(
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data
);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
//skybox end
}
void shutdown(GLFWwindow* window)
{
shaderLoader.DeleteProgram(program);
}
//obsluga wejscia
void processInput(GLFWwindow* window)
{
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
float angleSpeed = 0.005f;
float moveSpeed = 0.0025f;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
spaceshipPos += spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
spaceshipPos -= spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
spaceshipPos += spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
spaceshipPos -= spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
spaceshipPos += spaceshipUp * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
spaceshipPos -= spaceshipUp * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
cameraPos = spaceshipPos - 1.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.5f;
cameraDir = spaceshipDir;
//cameraDir = glm::normalize(-cameraPos);
}
// funkcja jest glowna petla
void renderLoop(GLFWwindow* window) {
while (!glfwWindowShouldClose(window))
{
processInput(window);
renderScene(window);
glfwPollEvents();
}
}
#include "glew.h"
#include <GLFW/glfw3.h>
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include "Shader_Loader.h"
#include "Render_Utils.h"
#include "Texture.h"
#include "Box.cpp"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <string>
#include "SOIL/SOIL.h"
namespace texture {
GLuint mercury;
GLuint venus;
GLuint earth;
GLuint moon;
GLuint ship;
GLuint sun;
GLuint mars;
GLuint jupiter;
GLuint saturn;
GLuint uranus;
GLuint neptune;
GLuint mercuryNormal;
GLuint venusNormal;
GLuint earthNormal;
GLuint asteroidNormal;
GLuint shipNormal;
GLuint marsNormal;
GLuint jupiterNormal;
GLuint saturnNormal;
GLuint uranusNormal;
GLuint neptuneNormal;
GLuint grid;
}
GLuint program;
GLuint programSun;
GLuint programTex;
GLuint programEarth;
GLuint programProcTex;
GLuint programSkyBox;
GLuint programCoin;
Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext;
Core::RenderContext sphereContext;
Core::RenderContext cubeContext;
Core::RenderContext cylinderContext;
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
GLuint VAO,VBO;
float aspectRatio = 1.f;
unsigned int textureID;
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide,cameraDir));
glm::mat4 cameraRotrationMatrix = glm::mat4({
cameraSide.x,cameraSide.y,cameraSide.z,0,
cameraUp.x,cameraUp.y,cameraUp.z ,0,
-cameraDir.x,-cameraDir.y,-cameraDir.z,0,
0.,0.,0.,1.,
});
cameraRotrationMatrix = glm::transpose(cameraRotrationMatrix);
glm::mat4 cameraMatrix = cameraRotrationMatrix * glm::translate(-cameraPos);
return cameraMatrix;
}
glm::mat4 createPerspectiveMatrix()
{
glm::mat4 perspectiveMatrix;
float n = 0.05;
float f = 20.;
float a1 = glm::min(aspectRatio, 1.f);
float a2 = glm::min(1 / aspectRatio, 1.f);
perspectiveMatrix = glm::mat4({
1,0.,0.,0.,
0.,aspectRatio,0.,0.,
0.,0.,(f+n) / (n - f),2*f * n / (n - f),
0.,0.,-1.,0.,
});
perspectiveMatrix=glm::transpose(perspectiveMatrix);
return perspectiveMatrix;
}
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
GLuint prog = program;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(prog, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0,0,0);
Core::DrawContext(context);
}
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint normalMapId) {
GLuint prog = programTex;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0, 0, 0);
Core::SetActiveTexture(textureID, "colorTexture", prog, 0);
Core::SetActiveTexture(normalMapId, "normalSampler", prog, 1);
Core::DrawContext(context);
}
void drawCylinder(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
GLuint prog = programCoin;
glUseProgram(prog);
float time = glfwGetTime();
glm::mat4 modelMatrixForMultiplications = modelMatrix * glm::rotate(glm::mat4(1.0f), time * 1.0f, glm::vec3(0, 1, 0))
* glm::scale(glm::vec3(0.5f));
modelMatrix = modelMatrixForMultiplications;
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(prog, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(prog, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(prog, "lightPos"), 0, 0, 0);
Core::DrawContext(context);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID)
{
GLuint prog = programSun;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniform1f(glGetUniformLocation(prog, "exposition"), 1.f);
Core::SetActiveTexture(textureID, "sunTexture", prog, 0);
Core::DrawContext(context);
}
void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glDisable(GL_DEPTH_TEST);
glUseProgram(programSkyBox);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
GLint transformLoc = glGetUniformLocation(programSkyBox, "transformation");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(transformation));
GLint modelLoc = glGetUniformLocation(programSkyBox, "modelMatrix");
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glUniform3f(glGetUniformLocation(programSkyBox, "lightPos"), 0, 0, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
Core::DrawContext(context);
glEnable(GL_DEPTH_TEST);
}
void renderPlanet(float time, float orbitRadius, float orbitRotationSpeed, float selfRotationSpeed, float scale, GLuint planetTexture, GLuint normalTexture) {
glm::mat4 planetTransform = glm::rotate(glm::mat4(1.0f), time * orbitRotationSpeed, glm::vec3(0, 1, 0)) // orbitowanie dooko³a s³oñca
* glm::translate(glm::vec3(orbitRadius, 0, 0)) // translacja na odp. odleg³oœæ
* glm::rotate(glm::mat4(1.0f), time * selfRotationSpeed, glm::vec3(0, 1, 0)) //obrót planety wokó³ w³asnej osi
* glm::scale(glm::vec3(scale)); //skalowanie planety
drawObjectTexture(sphereContext, planetTransform, planetTexture, normalTexture);
}
void renderPlanets() {
float time = glfwGetTime();
float mercuryOrbitRadius = 1.3f;
float venusOrbitRadius = 2.0f;
float earthOrbitRadius = 5.0f;
float moonOrbitRadius = 0.8f;
float marsOrbitRadius = 8.0f;
float jupiterOrbitRadius = 10.0f;
float saturnOrbitRadius = 11.0f;
float uranusOrbitRadius = 12.5f;
float neptuneOrbitRadius = 13.0f;
// im mniejsze tym szybciej
float mercuryRotationSpeed = 1.0f / 10;
float venusRotationSpeed = 1.0f / 7;
float earthRotationSpeed = 1.0f / 6;
float moonRotationSpeed = 1.0f / 2;
float marsRotationSpeed = 1.0f / 5;
float jupiterRotationSpeed = 1.0f / 8.5;
float saturnRotationSpeed = 1.0f / 5;
float uranusRotationSpeed = 1.0f / 9;
float neptuneRotationSpeed = 1.0f / 10;
float mercurySelfRotationSpeed = 1.0f;
float venusSelfRotationSpeed = 1.0f;
float earthSelfRotationSpeed = 1.0f;
float moonSelfRotationSpeed = 1.0f / 2;
float marsSelfRotationSpeed = 1.0f;
float jupiterSelfRotationSpeed = 1.0f;
float saturnSelfRotationSpeed = 1.0f;
float uranusSelfRotationSpeed = 1.0f / 2;
float neptuneSelfRotationSpeed = 1.0f;
float mercuryScale = 0.11f;
float venusScale = 0.14f;
float earthScale = 0.3f;
float moonScale = 0.055f;
float marsScale = 0.2f;
float jupiterScale = 0.7f;
float saturnScale = 0.5f;
float uranusScale = 0.3f;
float neptuneScale = 0.32f;
renderPlanet(time, mercuryOrbitRadius, mercuryRotationSpeed, mercurySelfRotationSpeed, mercuryScale, texture::mercury, texture::mercuryNormal);
renderPlanet(time, venusOrbitRadius, venusRotationSpeed, venusSelfRotationSpeed, venusScale, texture::venus, texture::venusNormal);
renderPlanet(time, earthOrbitRadius, earthRotationSpeed, earthSelfRotationSpeed, earthScale, texture::earth, texture::earthNormal);
//earths moon, musi byæ inaczej renderowany bo on nie orbituje wokó³ s³oñca tylko ziemi. PóŸniej to mo¿na jakoœ lepiej rozwi¹zaæ.
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::eulerAngleY(time * moonRotationSpeed) * glm::translate(glm::vec3(moonOrbitRadius, 0, 0)) * glm::scale(glm::vec3(moonScale)),
texture::moon,
texture::asteroidNormal);
renderPlanet(time, marsOrbitRadius, marsRotationSpeed, marsSelfRotationSpeed, marsScale, texture::mars, texture::marsNormal);
renderPlanet(time, jupiterOrbitRadius, jupiterRotationSpeed, jupiterSelfRotationSpeed, jupiterScale, texture::jupiter, texture::jupiterNormal);
renderPlanet(time, saturnOrbitRadius, saturnRotationSpeed, saturnSelfRotationSpeed, saturnScale, texture::saturn, texture::saturnNormal);
renderPlanet(time, uranusOrbitRadius, uranusRotationSpeed, uranusSelfRotationSpeed, uranusScale, texture::uranus, texture::uranusNormal);
renderPlanet(time, neptuneOrbitRadius, neptuneRotationSpeed, neptuneSelfRotationSpeed, neptuneScale, texture::neptune, texture::neptuneNormal);
}
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//skybox
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
//sun
drawSun(sphereContext, glm::mat4(), texture::sun);
renderPlanets();
drawCylinder(cylinderContext, glm::translate(glm::vec3(5.0f, 0.0f, 0.0f)), glm::vec3(1.0f, 1.0f, 0.0f));
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
-spaceshipDir.x,-spaceshipDir.y,-spaceshipDir.z,0,
0.,0.,0.,1.,
});
//spaceship drawing
drawObjectTexture(shipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
texture::ship, texture::shipNormal
);
glUseProgram(0);
glfwSwapBuffers(window);
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
aspectRatio = width / float(height);
glViewport(0, 0, width, height);
}
void loadModelToContext(std::string path, Core::RenderContext& context)
{
Assimp::Importer import;
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
return;
}
context.initFromAssimpMesh(scene->mMeshes[0]);
}
void init(GLFWwindow* window)
{
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
//programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex_copy.vert", "shaders/shader_5_1_tex_copy.frag");
programEarth = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programProcTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
programCoin = shaderLoader.CreateProgram("shaders/shader_coin.vert", "shaders/shader_coin.frag");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext);
loadModelToContext("./models/cube.obj", cubeContext);
loadModelToContext("./models/cylinder.obj", cylinderContext);
texture::mercury = Core::LoadTexture("textures/mercury/mercury.jpg");
texture::venus = Core::LoadTexture("textures/venus/venus.jpg");
texture::earth = Core::LoadTexture("textures/earth/earth.png");
texture::ship = Core::LoadTexture("textures/spaceship/spaceship.jpg");
texture::moon = Core::LoadTexture("textures/earths_moon/moon.jpg");
texture::sun = Core::LoadTexture("textures/sun/sun.jpg");
texture::mars = Core::LoadTexture("textures/mars/mars.jpg");
texture::jupiter = Core::LoadTexture("textures/jupiter/jupiter.jpg");
texture::saturn = Core::LoadTexture("textures/saturn/saturn.jpg");
texture::uranus = Core::LoadTexture("textures/uranus/uranus.jpg");
texture::neptune = Core::LoadTexture("textures/neptune/neptune.jpg");
texture::mercuryNormal = Core::LoadTexture("textures/mercury/mercury_normal.png");
texture::venusNormal = Core::LoadTexture("textures/venus/venus_normal.png");
texture::earthNormal = Core::LoadTexture("textures/earth/earth_normal.png");
texture::shipNormal = Core::LoadTexture("textures/spaceship/spaceship_normal.jpg");
texture::asteroidNormal = Core::LoadTexture("textures/earths_moon/moon_normal.jpg");
texture::marsNormal = Core::LoadTexture("textures/mars/mars_normal.jpg");
texture::jupiterNormal = Core::LoadTexture("textures/jupiter/jupiter_normal.png");
texture::saturnNormal = Core::LoadTexture("textures/saturn/saturn_normal.png");
texture::uranusNormal = Core::LoadTexture("textures/uranus/uranus_normal.png");
texture::neptuneNormal = Core::LoadTexture("textures/neptune/neptune_normal.png");
//tutaj skybox start
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
std::vector<std::string> filepaths = {
"textures/skybox/right.png",
"textures/skybox/left.png",
"textures/skybox/top.png",
"textures/skybox/bottaom.png",
"textures/skybox/back.png",
"textures/skybox/front.png"
};
int w, h;
unsigned char* data;
for (unsigned int i = 0; i < 6; i++)
{
data = SOIL_load_image(filepaths[i].c_str(), &w, &h, 0, SOIL_LOAD_RGBA);
glTexImage2D(
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data
);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
//skybox end
}
void shutdown(GLFWwindow* window)
{
shaderLoader.DeleteProgram(program);
}
//obsluga wejscia
void processInput(GLFWwindow* window)
{
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
float angleSpeed = 0.005f;
float moveSpeed = 0.0025f;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
spaceshipPos += spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
spaceshipPos -= spaceshipDir * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
spaceshipPos += spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
spaceshipPos -= spaceshipSide * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
spaceshipPos += spaceshipUp * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
spaceshipPos -= spaceshipUp * moveSpeed;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
cameraPos = spaceshipPos - 1.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.5f;
cameraDir = spaceshipDir;
//cameraDir = glm::normalize(-cameraPos);
}
// funkcja jest glowna petla
void renderLoop(GLFWwindow* window) {
while (!glfwWindowShouldClose(window))
{
processInput(window);
renderScene(window);
glfwPollEvents();
}
}