~ubuntu-branches/ubuntu/raring/glmark2/raring

« back to all changes in this revision

Viewing changes to src/libmatrix/program.cc

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2012-08-21 15:38:09 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120821153809-bwux72bat8qp2n5v
Tags: 2012.08-0ubuntu1
* New upstream release 2012.08 (LP: #1039736)
  - Avoid crashing if gl used is not >= 2.0 (LP: #842279)
* Bumping dh compatibility level to v9
* debian/control:
  - Update Standards-Version to 3.9.3.
  - Add libjpeg-dev build dependency.
  - Use libegl1-x11-dev as an build-dep alternative instead of libegl1-dev.
  - Update description of glmark2-data binary package.
* debian/copyright:
  - Refresh copyright based on the current upstrem version
* debian/rules:
  - Clean compiled python code from unpacked waflib/ directory, as
    described in http://wiki.debian.org/UnpackWaf

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// Copyright (c) 2011 Linaro Limited
 
2
// Copyright (c) 2011-2012 Linaro Limited
3
3
//
4
4
// All rights reserved. This program and the accompanying materials
5
5
// are made available under the terms of the MIT License which accompanies
14
14
#include <sstream>
15
15
#include <fstream>
16
16
#include <iostream>
17
 
 
18
 
#include "gl-headers.h"
 
17
#include "gl-if.h"
19
18
#include "program.h"
20
19
 
21
20
using std::string;
22
21
using LibMatrix::mat4;
 
22
using LibMatrix::mat3;
23
23
using LibMatrix::vec2;
24
24
using LibMatrix::vec3;
25
25
using LibMatrix::vec4;
26
26
 
27
 
bool
28
 
gotSource(const string& filename, string& source)
29
 
{
30
 
    using std::ifstream;
31
 
    ifstream inputFile(filename.c_str());
32
 
    if (!inputFile)
33
 
    {
34
 
        std::cerr << "Failed to open \"" << filename << "\"" << std::endl;
35
 
        return false;
36
 
    }
37
 
 
38
 
    string curLine;
39
 
    while (getline(inputFile, curLine))
40
 
    {
41
 
        source += curLine;
42
 
        source += '\n';
43
 
    }
44
 
 
45
 
    return true;
46
 
}
47
 
 
48
27
Shader::Shader(unsigned int type, const string& source) :
49
28
    handle_(0),
50
29
    type_(type),
59
38
        message_ = string("Failed to create the new shader.");
60
39
        return;
61
40
    }
62
 
    const char* shaderSource = source_.c_str();
 
41
    const GLchar* shaderSource = source_.c_str();
63
42
    glShaderSource(handle_, 1, &shaderSource, NULL);
64
43
    GLint param = 0;
65
44
    glGetShaderiv(handle_, GL_SHADER_SOURCE_LENGTH, &param);
95
74
    if (param == GL_FALSE)
96
75
    {
97
76
        glGetShaderiv(handle_, GL_INFO_LOG_LENGTH, &param);
98
 
        char* infoLog = new char[param + 1];
 
77
        GLchar* infoLog = new GLchar[param + 1];
99
78
        glGetShaderInfoLog(handle_, param + 1, NULL, infoLog);
100
79
        message_ = infoLog;
101
80
        delete [] infoLog;
235
214
    if (param == GL_FALSE)
236
215
    {
237
216
        glGetProgramiv(handle_, GL_INFO_LOG_LENGTH, &param);
238
 
        char* infoLog = new char[param + 1];
 
217
        GLchar* infoLog = new GLchar[param + 1];
239
218
        glGetProgramInfoLog(handle_, param + 1, NULL, infoLog);
240
219
        message_ = infoLog;
241
220
        delete [] infoLog;
297
276
}
298
277
 
299
278
Program::Symbol&
 
279
Program::Symbol::operator=(const mat3& m)
 
280
{
 
281
    if (type_ == Uniform)
 
282
    {
 
283
        // Our matrix representation is column-major, so transpose is false here.
 
284
        glUniformMatrix3fv(location_, 1, GL_FALSE, m);
 
285
    }
 
286
    return *this;
 
287
}
 
288
 
 
289
Program::Symbol&
300
290
Program::Symbol::operator=(const vec2& v)
301
291
{
302
292
    if (type_ == Uniform)