working on texturing

This commit is contained in:
Dmitri K 2016-11-09 19:29:05 -05:00
parent 104038d7f6
commit a883722d25
4 changed files with 21 additions and 15 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 431 KiB

BIN
src/data/uvLayoutGrid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 KiB

View File

@ -7,5 +7,5 @@ uniform sampler2D skybox;
void main()
{
//fColor = texture(skybox, texCoords);
fColor = vec4(1.0, 0, 1.0, 1.0);// * texture(skybox, texCoords);
fColor = texture(skybox, texCoords);
}

View File

@ -228,6 +228,8 @@ void Viewer::init()
void Viewer::initShaders()
{
// Load vertex and fragment shaders
m_program = new QOpenGLShaderProgram;
colorPickerShaderProgram = m_program;
@ -313,7 +315,8 @@ void Viewer::initShaders()
if ((s_vUvLocation = skyboxRenderShaderProgram->attributeLocation("vUv")) < 0)
qDebug() << "Unable to find shader location for " << "vUv";
s_texture = new QOpenGLTexture(QImage("src/data/skybox.jpg").mirrored());
s_texture = new QOpenGLTexture(QImage("src/data/skybox.jpg"));
//s_texture = new QOpenGLTexture(QImage("src/data/uvLayoutGrid.png"));
s_texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
s_texture->setMagnificationFilter(QOpenGLTexture::Linear);
}
@ -355,25 +358,28 @@ void Viewer::initGeometries()
{ 0.5, -0.5, -0.5 }, { -0.5, -0.5, 0.5 }, { -0.5, -0.5, -0.5 }
};
float ux = 0;
float vy = 0;
GLfloat uvs[numVerticesCube][2] = {
GLfloat uvs[numVerticesCube][2] = {
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
{ .25 + ux, .25 + vy }, { .50 + ux, .25 + vy }, { .50 + ux, .50 + vy },
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0 }, { 1, 0 }, { 0, 1 },
{ 1, 1 }, { 0, 0 }, { 1, 0 },
};