added a texture to the shene's sphere

This commit is contained in:
Anselme 2015-06-30 18:51:32 +02:00
parent 3ab2ba9dcd
commit 6df9037261
3 changed files with 5 additions and 2 deletions

BIN
data/noise.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

View File

@ -7,6 +7,7 @@
#include "phongmaterial.h"
#include "skybox.h"
#include "utils.h"
#include "texture.h"
#include <iostream>
#include <glm/glm.hpp>
#include <QKeyEvent>
@ -66,7 +67,9 @@ void MyGLWidget::buildScene()
QString vertSource = Utils::fileToString("../phong.vert");
QString fragSource = Utils::fileToString("../phong.frag");
Shader* shader = new Shader(&vertSource, &fragSource);
Material* mat = new PhongMaterial(shader);
PhongMaterial* mat = new PhongMaterial(shader);
Texture* tex = new Texture("../data/noise.png");
mat->setTexture(tex);
QString filenames[6] = {
"../data/skybox_lf", "../data/skybox_rt",
"../data/skybox_up", "../data/skybox_dn",

View File

@ -32,6 +32,6 @@ vec3 computeLight(in vec3 kd, in vec3 ks, in float ns, in vec3 color, in vec3 no
void main(void) {
vec3 kd = vec3(texture2D(baseTexture, varTexCoord));
outColor = vec4(1, 0, 0, 1);
outColor = vec4(kd, 1);
}