예제 #1
0
	Display::Display(int x_,int y_,DataWindow<Trio>& d):
	x(x_),y(y_),data(d)
	{
		win=new sf::Window(sf::VideoMode(x,y),"plot");
		GlewInit();
		glClearColor(1.0f,1.0f,1.0f,1.0f);
		prog = new mm::Program
		(
			{
				mm::Shader(GL_VERTEX_SHADER,"display/vert.glsl"),
				mm::Shader(GL_FRAGMENT_SHADER,"display/frag.glsl")
			}
		);
		
		glUseProgram(prog->getHandle());
		
		col_loc = glGetUniformLocation(prog->getHandle(),"col");
		
		BufferData buf(data);
		
		glGenVertexArrays(1,&vao);
		glBindVertexArray(vao);
		glGenBuffers(1,&vbo);
		
		glBindBuffer(GL_ARRAY_BUFFER,vbo);
		glBufferData(GL_ARRAY_BUFFER,data.size()*2*sizeof(float),buf.x,GL_DYNAMIC_DRAW);
		glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,0);
		glEnableVertexAttribArray(0);
		
	}
예제 #2
0
	bool Game::OnInit()
	{
		// Init the external dependencies
		//
		bool success = SDLInit() && GlewInit();
		if (!success)
		{
			m_state = GameState::INIT_FAILED;
			return false;
		}

		// Setup the viewport
		//
		SetupViewport();

		// Change game state
		//
		m_state = GameState::INIT_SUCCESSFUL;

		return true;
	}	
예제 #3
0
int main()
{
	WindowController* windowController = &WindowController::GetInstance();
	if (windowController == nullptr)
		return Terminate("Failed to create window...");
	windowController->setHeight(800);
	windowController->setWidth(1200);

	GlewInit();

	Scene scene;

	Skybox* skybox = new Skybox("skybox", "./Resources/Textures/TropicalSunnyDay", ".png");
	scene.Add(skybox);

	string plane_path = "./Resources/Models/Boeing 747/Boeing747.obj";
	Shader* shader = new Shader("./model.vs", "./model.frag");
	//Model* plane_model = new Model(plane_path);
	//GameObject* plane = new GameObject("Boeing 747", plane_model, shader);
	//plane->Transform(glm::vec3(2.0f, 0.0f, 0.0f));
	//plane->Scale(glm::vec3(2.0f, 2.0f, 2.0f));
	//scene.Add(plane);


	Plane* plane = new Plane("grass.png", "./Resources/Textures", shader, 1000);
	scene.Add(plane);

	windowController->Update(scene);

	//glEnable(GL_DEPTH_TEST);

	//if (GlewInit() != 0)
	//	return Terminate("Failed to init glew");

	//Model nanosuit("./Resources/Models/nanosuit/nanosuit.obj");
	//Shader modelShader("./model.vs", "./model.frag");

	//while (!glfwWindowShouldClose(window))
	//{
	//	// Set frame time
	//	GLfloat currentFrame = glfwGetTime();
	//	deltaTime = currentFrame - lastFrame;
	//	lastFrame = currentFrame;

	//	// Check and call events
	//	glfwPollEvents();
	//	Do_Movement();

	//	// Clear the colorbuffer
	//	glClearColor(0.15f, 0.15f, 0.15f, 1.0f);
	//	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//	modelShader.Use();   // <-- Don't forget this one!
	//					// Transformation matrices
	//	glm::mat4 projection = glm::perspective(camera.Zoom, (float)WIDTH / (float)HEIGHT, 0.1f, 100.0f);
	//	glm::mat4 view = camera.GetViewMatrix();
	//	glUniformMatrix4fv(glGetUniformLocation(modelShader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
	//	glUniformMatrix4fv(glGetUniformLocation(modelShader.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));

	//	// Draw the loaded model
	//	glm::mat4 model;
	//	model = glm::translate(model, glm::vec3(0.0f, -1.75f, 0.0f)); // Translate it down a bit so it's at the center of the scene
	//	model = glm::scale(model, glm::vec3(0.2f, 0.2f, 0.2f));	// It's a bit too big for our scene, so scale it down
	//	glUniformMatrix4fv(glGetUniformLocation(modelShader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
	//	nanosuit.Draw(modelShader);

	//	// Swap the buffers
	//	glfwSwapBuffers(window);
	//}
	glfwTerminate();
	system("pause");
	return 0;
}