Merge
This commit is contained in:
commit
fe694895ff
@ -19,12 +19,13 @@
|
||||
|
||||
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||
|
||||
int WIDTH = 500, HEIGHT = 500;
|
||||
int WIDTH = 900, HEIGHT = 900;
|
||||
|
||||
namespace models {
|
||||
Core::RenderContext spaceshipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
|
||||
Core::RenderContext windowFrame;
|
||||
Core::RenderContext bookShelf;
|
||||
Core::RenderContext window;
|
||||
Core::RenderContext potPlant;
|
||||
@ -39,7 +40,7 @@ namespace models {
|
||||
namespace textures {
|
||||
GLuint room;
|
||||
GLuint sunTexture;
|
||||
GLuint windowUkTexture;
|
||||
GLuint windowFrameTexture;
|
||||
GLuint bookShelfTexture;
|
||||
GLuint potPlantTexture;
|
||||
GLuint officeChariTexture;
|
||||
@ -62,6 +63,21 @@ GLuint programSkybox;
|
||||
|
||||
bool flashOff = false;
|
||||
|
||||
double prevTime = 0.0;
|
||||
double currTime = 0.0;
|
||||
double timeDiff;
|
||||
unsigned int counter = 0;
|
||||
|
||||
glm::vec3 position = glm::vec3(0, 0, 5);
|
||||
float horizontalAngle = 3.14f;
|
||||
float verticalAngle = 0.0f;
|
||||
float speed = 0.1f;
|
||||
float sensitivity = 100.0f;
|
||||
double xpos, ypos;
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Orientation = glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
glm::vec3 Up = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
|
||||
Core::Shader_Loader shaderLoader;
|
||||
|
||||
Core::RenderContext shipContext;
|
||||
@ -199,12 +215,12 @@ void renderShadowapSun() {
|
||||
|
||||
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
||||
|
||||
//drawObjectDepth(sphereContext,
|
||||
// lightVP,
|
||||
// glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)));
|
||||
//drawObjectDepth(sphereContext,
|
||||
// lightVP,
|
||||
// glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)));
|
||||
drawObjectDepth(sphereContext,
|
||||
lightVP,
|
||||
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)));
|
||||
drawObjectDepth(sphereContext,
|
||||
lightVP,
|
||||
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)));
|
||||
//drawObjectDepth(models::bedContext,
|
||||
// lightVP,
|
||||
// glm::mat4());
|
||||
@ -264,11 +280,11 @@ void renderScene(GLFWwindow* window)
|
||||
glUseProgram(program);
|
||||
|
||||
drawObjectPBR(models::window, glm::mat4(),
|
||||
textures::windowUkTexture,
|
||||
textures::windowFrameTexture,
|
||||
0.2,
|
||||
0.1
|
||||
);
|
||||
drawObjectPBR(models::potPlant, glm::mat4() * glm::scale(glm::vec3(0.2f)) * glm::translate(glm::vec3(-5.0f, 3.0f, -6.0f)),
|
||||
drawObjectPBR(models::potPlant, glm::mat4() * glm::scale(glm::vec3(0.2f)) * glm::translate(glm::vec3(-5.0f, 55.0f, -6.0f)),
|
||||
textures::potPlantTexture,
|
||||
1.0f,
|
||||
0.2f
|
||||
@ -288,7 +304,7 @@ void renderScene(GLFWwindow* window)
|
||||
0.4f,
|
||||
0.0f
|
||||
);
|
||||
drawObjectPBR(models::desk, glm::mat4() * glm::translate(glm::vec3(-3.0, 0.0, -3.0f)),
|
||||
drawObjectPBR(models::desk, glm::mat4(),
|
||||
textures::deskTexture,
|
||||
0.4f,
|
||||
0.0f
|
||||
@ -303,6 +319,10 @@ void renderScene(GLFWwindow* window)
|
||||
0.3f,
|
||||
0.0f
|
||||
);
|
||||
drawObjectPBR(models::windowFrame, glm::mat4(),
|
||||
textures::windowFrameTexture,
|
||||
0.2f,
|
||||
0.0f);
|
||||
drawObjectPBR(models::bookShelf, glm::mat4() * glm::scale(glm::vec3(0.01)),
|
||||
textures::bookShelfTexture,
|
||||
0.4f,
|
||||
@ -408,6 +428,7 @@ void init(GLFWwindow* window)
|
||||
textures::room = Core::LoadTexture("./models2/room/room.png");
|
||||
textures::flashlightTexture = Core::LoadTexture("./models/FlashlightTexture.png");
|
||||
textures::sunTexture = Core::LoadTexture("./models/sun.jpeg");
|
||||
textures::windowFrameTexture = Core::LoadTexture("./models2/Frame/frame.png");
|
||||
textures::bookShelfTexture = Core::LoadTexture("./models2/bookshelf/SHELF_TEXTURE.bmp");
|
||||
textures::potPlantTexture = Core::LoadTexture("./models2/potplant/b3.bmp");
|
||||
textures::lampTexture = Core::LoadTexture("./models2/lamp/_Base_color.png");
|
||||
@ -454,6 +475,29 @@ void processInput(GLFWwindow* window)
|
||||
flashOff = false;
|
||||
if (glfwGetKey(window, GLFW_KEY_5) == GLFW_PRESS)
|
||||
flashOff = true;
|
||||
if (glfwGetKey(window, GLFW_KEY_6) == GLFW_RELEASE)
|
||||
{
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
glfwGetCursorPos(window, &xpos, &ypos);
|
||||
|
||||
float rotX = sensitivity * (float)(xpos - (WIDTH / 2)) / HEIGHT;
|
||||
float rotY = sensitivity * (float)(ypos - (HEIGHT / 2)) / WIDTH;
|
||||
|
||||
glm::vec3 newOrientation = glm::rotate(spaceshipDir, glm::radians(-rotY), glm::normalize(glm::cross(spaceshipDir, spaceshipUp)));
|
||||
|
||||
|
||||
// Decides whether or not the next vertical Orientation is legal or not
|
||||
if (abs(glm::angle(newOrientation, spaceshipUp) - glm::radians(90.0f)) <= glm::radians(85.0f))
|
||||
{
|
||||
spaceshipDir = newOrientation;
|
||||
}
|
||||
|
||||
// Rotates the Orientation left and right
|
||||
spaceshipDir = glm::rotate(spaceshipDir, glm::radians(-rotX), spaceshipUp);
|
||||
|
||||
glfwSetCursorPos(window, WIDTH/2, HEIGHT/2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
cameraPos = spaceshipPos - 0.6 * spaceshipDir + glm::vec3(0, 1, 0) * 0.26f;
|
||||
@ -477,6 +521,20 @@ void processInput(GLFWwindow* window)
|
||||
void renderLoop(GLFWwindow* window) {
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
currTime = glfwGetTime();
|
||||
timeDiff = currTime - prevTime;
|
||||
counter++;
|
||||
|
||||
if (timeDiff >= 1.0 / 30.0)
|
||||
{
|
||||
std::string FPS = std::to_string((1.0 / timeDiff) * counter);
|
||||
std::string newTitle = "Super Gra - " + FPS + " FPS";
|
||||
glfwSetWindowTitle(window, newTitle.c_str());
|
||||
|
||||
prevTime = currTime;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
processInput(window);
|
||||
|
||||
renderScene(window);
|
||||
|
@ -17,13 +17,15 @@ int main(int argc, char** argv)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
//glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
|
||||
|
||||
#ifdef __APPLE__
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
#endif
|
||||
|
||||
// tworzenie okna za pomoca glfw
|
||||
GLFWwindow* window = glfwCreateWindow(500, 500, "FirstWindow", NULL, NULL);
|
||||
GLFWwindow* window = glfwCreateWindow(900, 900, "FirstWindow", NULL, NULL);
|
||||
glfwSetWindowPos(window, 500, 30);
|
||||
if (window == NULL)
|
||||
{
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user