Initial commit.
This commit is contained in:
commit
579e3bb5df
145 changed files with 49994 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
libraries/
|
1
A1/.gitignore
vendored
Normal file
1
A1/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
BIN
A1/A1.zip
Normal file
BIN
A1/A1.zip
Normal file
Binary file not shown.
34
A1/CMakeLists.txt
Normal file
34
A1/CMakeLists.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(A1)
|
||||
|
||||
# Is this the solution?
|
||||
# Override with `cmake -DSOL=ON ..`
|
||||
OPTION(SOL "Solution" OFF)
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them also show up in IDEs.
|
||||
IF(${SOL})
|
||||
FILE(GLOB_RECURSE SOURCES "src0/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src0/*.h")
|
||||
ELSE()
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
ENDIF()
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
ENDIF()
|
7
A1/README.txt
Normal file
7
A1/README.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
1) Alexander Huddleston
|
||||
|
||||
2) The last coloring mode goes from blue to green, top to bottom respectively.
|
||||
|
||||
3) http://www.mathopenref.com/coordtrianglearea.html
|
||||
|
||||
4) This was written and compiled on Arch Linux on a 64-bit machine. There should not be any errors when run on another machine, but I am making note here just in case.
|
7474
A1/resources/bunny.obj
Normal file
7474
A1/resources/bunny.obj
Normal file
File diff suppressed because it is too large
Load diff
204
A1/resources/sphere.obj
Normal file
204
A1/resources/sphere.obj
Normal file
|
@ -0,0 +1,204 @@
|
|||
####
|
||||
#
|
||||
# OBJ File Generated by LightWave3D
|
||||
# LightWave3D OBJ Export v2.2
|
||||
#
|
||||
####
|
||||
#
|
||||
# Vertices: 62
|
||||
# Points: 0
|
||||
# Lines: 0
|
||||
# Faces: 120
|
||||
# Materials: 1
|
||||
#
|
||||
####
|
||||
|
||||
# Vertex list
|
||||
|
||||
v 0 -0.5 -0
|
||||
v 0.25 -0.433013 -0
|
||||
v 0.216506 -0.433013 -0.125
|
||||
v 0.125 -0.433013 -0.216506
|
||||
v 0 -0.433013 -0.25
|
||||
v -0.125 -0.433013 -0.216506
|
||||
v -0.216506 -0.433013 -0.125
|
||||
v -0.25 -0.433013 -0
|
||||
v -0.216506 -0.433013 0.125
|
||||
v -0.125 -0.433013 0.216506
|
||||
v 0 -0.433013 0.25
|
||||
v 0.125 -0.433013 0.216506
|
||||
v 0.216506 -0.433013 0.125
|
||||
v 0.433013 -0.25 -0
|
||||
v 0.375 -0.25 -0.216506
|
||||
v 0.216506 -0.25 -0.375
|
||||
v 0 -0.25 -0.433013
|
||||
v -0.216506 -0.25 -0.375
|
||||
v -0.375 -0.25 -0.216506
|
||||
v -0.433013 -0.25 -0
|
||||
v -0.375 -0.25 0.216506
|
||||
v -0.216506 -0.25 0.375
|
||||
v 0 -0.25 0.433013
|
||||
v 0.216506 -0.25 0.375
|
||||
v 0.375 -0.25 0.216506
|
||||
v 0.5 2.55171e-12 -0
|
||||
v 0.433013 2.55171e-12 -0.25
|
||||
v 0.25 2.55171e-12 -0.433013
|
||||
v 0 2.55171e-12 -0.5
|
||||
v -0.25 2.55171e-12 -0.433013
|
||||
v -0.433013 2.55171e-12 -0.25
|
||||
v -0.5 2.55171e-12 -0
|
||||
v -0.433013 2.55171e-12 0.25
|
||||
v -0.25 2.55171e-12 0.433013
|
||||
v 0 2.55171e-12 0.5
|
||||
v 0.25 2.55171e-12 0.433013
|
||||
v 0.433013 2.55171e-12 0.25
|
||||
v 0.433013 0.25 -0
|
||||
v 0.375 0.25 -0.216506
|
||||
v 0.216506 0.25 -0.375
|
||||
v 0 0.25 -0.433013
|
||||
v -0.216506 0.25 -0.375
|
||||
v -0.375 0.25 -0.216506
|
||||
v -0.433013 0.25 -0
|
||||
v -0.375 0.25 0.216506
|
||||
v -0.216506 0.25 0.375
|
||||
v 0 0.25 0.433013
|
||||
v 0.216506 0.25 0.375
|
||||
v 0.375 0.25 0.216506
|
||||
v 0.25 0.433013 -0
|
||||
v 0.216506 0.433013 -0.125
|
||||
v 0.125 0.433013 -0.216506
|
||||
v 0 0.433013 -0.25
|
||||
v -0.125 0.433013 -0.216506
|
||||
v -0.216506 0.433013 -0.125
|
||||
v -0.25 0.433013 -0
|
||||
v -0.216506 0.433013 0.125
|
||||
v -0.125 0.433013 0.216506
|
||||
v 0 0.433013 0.25
|
||||
v 0.125 0.433013 0.216506
|
||||
v 0.216506 0.433013 0.125
|
||||
v 5.10341e-12 0.5 -0
|
||||
|
||||
# Face list
|
||||
|
||||
f 3 2 1
|
||||
f 4 3 1
|
||||
f 5 4 1
|
||||
f 6 5 1
|
||||
f 7 6 1
|
||||
f 8 7 1
|
||||
f 9 8 1
|
||||
f 10 9 1
|
||||
f 11 10 1
|
||||
f 12 11 1
|
||||
f 13 12 1
|
||||
f 2 13 1
|
||||
f 3 14 2
|
||||
f 15 14 3
|
||||
f 4 15 3
|
||||
f 16 15 4
|
||||
f 17 16 4
|
||||
f 5 17 4
|
||||
f 17 5 6
|
||||
f 18 17 6
|
||||
f 18 6 7
|
||||
f 19 18 7
|
||||
f 20 7 8
|
||||
f 20 19 7
|
||||
f 20 8 9
|
||||
f 21 20 9
|
||||
f 21 9 10
|
||||
f 22 21 10
|
||||
f 23 10 11
|
||||
f 23 22 10
|
||||
f 12 23 11
|
||||
f 24 23 12
|
||||
f 13 24 12
|
||||
f 25 24 13
|
||||
f 14 25 13
|
||||
f 2 14 13
|
||||
f 15 26 14
|
||||
f 27 26 15
|
||||
f 28 27 15
|
||||
f 16 28 15
|
||||
f 29 28 16
|
||||
f 17 29 16
|
||||
f 29 17 18
|
||||
f 30 29 18
|
||||
f 31 18 19
|
||||
f 31 30 18
|
||||
f 32 19 20
|
||||
f 32 31 19
|
||||
f 32 20 21
|
||||
f 33 32 21
|
||||
f 34 21 22
|
||||
f 34 33 21
|
||||
f 35 22 23
|
||||
f 35 34 22
|
||||
f 24 35 23
|
||||
f 36 35 24
|
||||
f 37 36 24
|
||||
f 25 37 24
|
||||
f 26 37 25
|
||||
f 14 26 25
|
||||
f 39 38 26
|
||||
f 27 39 26
|
||||
f 28 39 27
|
||||
f 40 39 28
|
||||
f 29 40 28
|
||||
f 41 40 29
|
||||
f 42 29 30
|
||||
f 42 41 29
|
||||
f 43 30 31
|
||||
f 43 42 30
|
||||
f 43 31 32
|
||||
f 44 43 32
|
||||
f 45 32 33
|
||||
f 45 44 32
|
||||
f 45 33 34
|
||||
f 46 45 34
|
||||
f 46 34 35
|
||||
f 47 46 35
|
||||
f 48 47 35
|
||||
f 36 48 35
|
||||
f 49 48 36
|
||||
f 37 49 36
|
||||
f 26 49 37
|
||||
f 38 49 26
|
||||
f 39 50 38
|
||||
f 51 50 39
|
||||
f 40 51 39
|
||||
f 52 51 40
|
||||
f 53 52 40
|
||||
f 41 53 40
|
||||
f 53 41 42
|
||||
f 54 53 42
|
||||
f 55 42 43
|
||||
f 55 54 42
|
||||
f 56 43 44
|
||||
f 56 55 43
|
||||
f 56 44 45
|
||||
f 57 56 45
|
||||
f 58 45 46
|
||||
f 58 57 45
|
||||
f 58 46 47
|
||||
f 59 58 47
|
||||
f 60 59 47
|
||||
f 48 60 47
|
||||
f 49 60 48
|
||||
f 61 60 49
|
||||
f 50 61 49
|
||||
f 38 50 49
|
||||
f 51 62 50
|
||||
f 52 62 51
|
||||
f 53 62 52
|
||||
f 62 53 54
|
||||
f 62 54 55
|
||||
f 62 55 56
|
||||
f 62 56 57
|
||||
f 62 57 58
|
||||
f 62 58 59
|
||||
f 60 62 59
|
||||
f 61 62 60
|
||||
f 50 62 61
|
||||
|
||||
# End of file
|
5049
A1/resources/teapot.obj
Normal file
5049
A1/resources/teapot.obj
Normal file
File diff suppressed because it is too large
Load diff
4
A1/resources/tri.obj
Normal file
4
A1/resources/tri.obj
Normal file
|
@ -0,0 +1,4 @@
|
|||
v 0 0 0
|
||||
v 10 0 0
|
||||
v 5 5 5
|
||||
f 1 2 3
|
8
A1/resources/tri2.obj
Normal file
8
A1/resources/tri2.obj
Normal file
|
@ -0,0 +1,8 @@
|
|||
v 0 0 0
|
||||
v 10 0 0
|
||||
v 5 5 5
|
||||
v 0 5 0
|
||||
v 5 0 5
|
||||
v 10 5 0
|
||||
f 1 2 3
|
||||
f 4 5 6
|
BIN
A1/shadow8t4.zip
Normal file
BIN
A1/shadow8t4.zip
Normal file
Binary file not shown.
34
A1/shadow8t4/shadow8t4/CMakeLists.txt
Normal file
34
A1/shadow8t4/shadow8t4/CMakeLists.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(A1)
|
||||
|
||||
# Is this the solution?
|
||||
# Override with `cmake -DSOL=ON ..`
|
||||
OPTION(SOL "Solution" OFF)
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them also show up in IDEs.
|
||||
IF(${SOL})
|
||||
FILE(GLOB_RECURSE SOURCES "src0/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src0/*.h")
|
||||
ELSE()
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
ENDIF()
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
ENDIF()
|
7
A1/shadow8t4/shadow8t4/README.txt
Normal file
7
A1/shadow8t4/shadow8t4/README.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
1) Alexander Huddleston
|
||||
|
||||
2) The last coloring mode goes from blue to green, top to bottom respectively.
|
||||
|
||||
3) http://www.mathopenref.com/coordtrianglearea.html
|
||||
|
||||
4) This was written and compiled on Arch Linux on a 64-bit machine. There should not be any errors when run on another machine, but I am making note here just in case.
|
61
A1/shadow8t4/shadow8t4/src/Image.cpp
Normal file
61
A1/shadow8t4/shadow8t4/src/Image.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "Image.h"
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Image::Image(int w, int h) :
|
||||
width(w),
|
||||
height(h),
|
||||
comp(3),
|
||||
pixels(width*height*comp, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
void Image::setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
// The pixel data is laid out row by row. Each row consists of 'width'
|
||||
// columns, and each column consists of 3 unsigned chars.
|
||||
|
||||
// First check for bounds
|
||||
if(y < 0 || y >= height) {
|
||||
cout << "Row " << y << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
if(x < 0 || x >= width) {
|
||||
cout << "Col " << x << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Since the origin (0, 0) of the image is the upper left corner, we need
|
||||
// to flip the row to make the origin be the lower left corner.
|
||||
y = height - y - 1;
|
||||
// index corresponding to row and col, (assuming single component image)
|
||||
int index = y*width + x;
|
||||
// Multiply by 3 to get the index for the rgb components.
|
||||
assert(index >= 0);
|
||||
assert(3*index + 2 < (int)pixels.size());
|
||||
pixels[3*index + 0] = r;
|
||||
pixels[3*index + 1] = g;
|
||||
pixels[3*index + 2] = b;
|
||||
}
|
||||
|
||||
void Image::writeToFile(const string &filename)
|
||||
{
|
||||
// The distance in bytes from the first byte of a row of pixels to the
|
||||
// first byte of the next row of pixels
|
||||
int stride_in_bytes = width*comp*sizeof(unsigned char);
|
||||
int rc = stbi_write_png(filename.c_str(), width, height, comp, &pixels[0], stride_in_bytes);
|
||||
if(rc) {
|
||||
cout << "Wrote to " << filename << endl;
|
||||
} else {
|
||||
cout << "Couldn't write to " << filename << endl;
|
||||
}
|
||||
}
|
25
A1/shadow8t4/shadow8t4/src/Image.h
Normal file
25
A1/shadow8t4/shadow8t4/src/Image.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#ifndef _IMAGE_H_
|
||||
#define _IMAGE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
Image(int width, int height);
|
||||
virtual ~Image();
|
||||
void setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b);
|
||||
void writeToFile(const std::string &filename);
|
||||
int getWidth() const { return width; }
|
||||
int getHeight() const { return height; }
|
||||
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
int comp;
|
||||
std::vector<unsigned char> pixels;
|
||||
};
|
||||
|
||||
#endif
|
45
A1/shadow8t4/shadow8t4/src/Triangle.cpp
Normal file
45
A1/shadow8t4/shadow8t4/src/Triangle.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "Triangle.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Tri::Tri()
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = 0.0;
|
||||
v1.y = 0.0;
|
||||
v1.z = 0.0;
|
||||
vertex v2;
|
||||
v2.x = 0.0;
|
||||
v2.y = 0.0;
|
||||
v2.z = 0.0;
|
||||
vertex v3;
|
||||
v3.x = 0.0;
|
||||
v3.y = 0.0;
|
||||
v3.z = 0.0;
|
||||
v.push_back(v1);
|
||||
v.push_back(v2);
|
||||
v.push_back(v3);
|
||||
xmin = 0;
|
||||
xmax = 0;
|
||||
ymin = 0;
|
||||
ymax = 0;
|
||||
area = 0.0;
|
||||
}
|
||||
|
||||
float findArea(vertex &one, vertex &two, vertex &three)
|
||||
{
|
||||
return abs(one.x*two.y + two.x*three.y + three.x*one.y - one.y*two.x - two.y*three.x - three.y*one.x)/2.0;
|
||||
}
|
||||
|
||||
Tri::Tri(vertex &one, vertex &two, vertex &three)
|
||||
{
|
||||
v.push_back(one);
|
||||
v.push_back(two);
|
||||
v.push_back(three);
|
||||
xmin = one.x;
|
||||
xmax = one.x;
|
||||
ymin = one.y;
|
||||
ymax = one.y;
|
||||
area = findArea(one, two, three);
|
||||
}
|
||||
|
34
A1/shadow8t4/shadow8t4/src/Triangle.h
Normal file
34
A1/shadow8t4/shadow8t4/src/Triangle.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#ifndef _TRIANGLE_H_
|
||||
#define _TRIANGLE_H_
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
struct vertex
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
float z = 0.0;
|
||||
float r = 0.0;
|
||||
float g = 0.0;
|
||||
float b = 0.0;
|
||||
};
|
||||
|
||||
class Tri
|
||||
{
|
||||
public:
|
||||
Tri();
|
||||
Tri(vertex &one, vertex &two, vertex &three);
|
||||
std::vector<vertex> v;
|
||||
float xmin;
|
||||
float xmax;
|
||||
float ymin;
|
||||
float ymax;
|
||||
float area;
|
||||
};
|
||||
|
||||
float findArea(vertex &one, vertex &two, vertex &three);
|
||||
|
||||
#endif
|
347
A1/shadow8t4/shadow8t4/src/main.cpp
Normal file
347
A1/shadow8t4/shadow8t4/src/main.cpp
Normal file
|
@ -0,0 +1,347 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
#include "Image.h"
|
||||
#include "Triangle.h"
|
||||
|
||||
// This allows you to skip the `std::` in front of C++ standard library
|
||||
// functions. You can also say `using std::cout` to be more selective.
|
||||
// You should never do this in a header file.
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 6) {
|
||||
cout << "Usage: A1 meshfile image width height colormode" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
srand(743298);
|
||||
string meshName(argv[1]);
|
||||
string filename(argv[2]);
|
||||
int width = atoi(argv[3]);
|
||||
int height = atoi(argv[4]);
|
||||
int colormode = atoi(argv[5]);
|
||||
|
||||
// Load geometry
|
||||
vector<float> posBuf; // list of vertex positions
|
||||
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
string errStr;
|
||||
|
||||
bool rc = tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, meshName.c_str());
|
||||
|
||||
if(!rc) {
|
||||
cerr << errStr << endl;
|
||||
} else {
|
||||
// Some OBJ files have different indices for vertex positions, normals,
|
||||
// and texture coordinates. For example, a cube corner vertex may have
|
||||
// three different normals. Here, we are going to duplicate all such
|
||||
// vertices.
|
||||
|
||||
// Loop over shapes
|
||||
for(size_t s = 0; s < shapes.size(); s++) {
|
||||
|
||||
// Loop over faces (polygons)
|
||||
size_t index_offset = 0;
|
||||
for(size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) {
|
||||
size_t fv = shapes[s].mesh.num_face_vertices[f];
|
||||
|
||||
// Loop over vertices in the face.
|
||||
for(size_t v = 0; v < fv; v++) {
|
||||
|
||||
// access to vertex
|
||||
tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+0]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+1]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+2]);
|
||||
|
||||
}
|
||||
index_offset += fv;
|
||||
|
||||
// per-face material (IGNORE)
|
||||
shapes[s].mesh.material_ids[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "Number of vertices: " << posBuf.size()/3 << endl;
|
||||
|
||||
vector<vector<float>> zbuf;
|
||||
|
||||
std::vector<Tri> tris;
|
||||
|
||||
// Split posBuf into triangles.
|
||||
for(int i = 0; i < (int)posBuf.size()/9; i++)
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = posBuf[i*9];
|
||||
v1.y = posBuf[i*9 + 1];
|
||||
v1.z = posBuf[i*9 + 2];
|
||||
vertex v2;
|
||||
v2.x = posBuf[i*9 + 3];
|
||||
v2.y = posBuf[i*9 + 4];
|
||||
v2.z = posBuf[i*9 + 5];
|
||||
vertex v3;
|
||||
v3.x = posBuf[i*9 + 6];
|
||||
v3.y = posBuf[i*9 + 7];
|
||||
v3.z = posBuf[i*9 + 8];
|
||||
Tri t(v1, v2, v3);
|
||||
tris.push_back(t);
|
||||
}
|
||||
|
||||
// Initialize min/max variables.
|
||||
float xmin = posBuf[0];
|
||||
float xmax = xmin;
|
||||
float ymin = posBuf[1];
|
||||
float ymax = ymin;
|
||||
float zmin = tris[0].v[0].z;
|
||||
float zmax = zmin;
|
||||
|
||||
// First time finding max and min.
|
||||
// Also, initializing r,g,b per triangle.
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
|
||||
int temp1 = rand()%255;
|
||||
int temp2 = rand()%255;
|
||||
int temp3 = rand()%255;
|
||||
tris[i].v[j].r = temp1;
|
||||
tris[i].v[j].g = temp2;
|
||||
tris[i].v[j].b = temp3;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char r = rand()%255;
|
||||
unsigned char b = rand()%255;
|
||||
unsigned char g = rand()%255;
|
||||
|
||||
|
||||
// Create the image. We're using a `shared_ptr`, a C++11 feature.
|
||||
auto image = make_shared<Image>(width, height);
|
||||
|
||||
// Find scaling ratio.
|
||||
float xratio = (1.0*width/(xmax - xmin));
|
||||
float yratio = (1.0*height/(ymax - ymin));
|
||||
float zratio = (255.0/(zmax-zmin));
|
||||
|
||||
float aratio = 1.0;
|
||||
|
||||
// Determine and assign smaller ratio.
|
||||
if(xratio < yratio)
|
||||
{
|
||||
aratio = xratio;
|
||||
}
|
||||
else
|
||||
{
|
||||
aratio = yratio;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
tris[i].v[j].x *= aratio;
|
||||
tris[i].v[j].y *= aratio;
|
||||
tris[i].v[j].z *= zratio;
|
||||
}
|
||||
}
|
||||
|
||||
xmin = tris[0].v[0].x;
|
||||
xmax = xmin;
|
||||
ymin = tris[0].v[0].y;
|
||||
ymax = ymin;
|
||||
zmin = tris[0].v[0].z;
|
||||
zmax = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
}
|
||||
}
|
||||
|
||||
float xoffset = ((width)/2 - (xmax + xmin)/2);
|
||||
float yoffset = ((height)/2 - (ymax + ymin)/2);
|
||||
float zoffset = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size();j++)
|
||||
{
|
||||
tris[i].v[j].x += xoffset;
|
||||
tris[i].v[j].y += yoffset;
|
||||
tris[i].v[j].z -= zoffset;
|
||||
}
|
||||
}
|
||||
|
||||
xmin = tris[0].v[0].x;
|
||||
xmax = xmin;
|
||||
ymin = tris[0].v[0].y;
|
||||
ymax = ymin;
|
||||
zmin = tris[0].v[0].z;
|
||||
zmax = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
tris[i].xmin = tris[i].v[0].x;
|
||||
tris[i].xmax = tris[i].v[0].x;
|
||||
tris[i].ymin = tris[i].v[0].y;
|
||||
tris[i].ymax = tris[i].v[0].y;
|
||||
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
|
||||
if(tris[i].xmin > tris[i].v[j].x)
|
||||
tris[i].xmin = tris[i].v[j].x;
|
||||
if(tris[i].xmax < tris[i].v[j].x)
|
||||
tris[i].xmax = tris[i].v[j].x;
|
||||
if(tris[i].ymin > tris[i].v[j].y)
|
||||
tris[i].ymin = tris[i].v[j].y;
|
||||
if(tris[i].ymax < tris[i].v[j].y)
|
||||
tris[i].ymax = tris[i].v[j].y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int r = 0; r < width; r++)
|
||||
{
|
||||
vector<float> temp;
|
||||
zbuf.push_back(temp);
|
||||
for(int c = 0; c < height; c++)
|
||||
{
|
||||
zbuf.at(r).push_back(zmin);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize variables for the three
|
||||
// Barycentric areas.
|
||||
float a1 = 0.0;
|
||||
float a2 = 0.0;
|
||||
float a3 = 0.0;
|
||||
|
||||
// Initialize variables for the three
|
||||
// Barycentric coordinates.
|
||||
float l1 = 0.0;
|
||||
float l2 = 0.0;
|
||||
float l3 = 0.0;
|
||||
|
||||
// Variable to hold current z coordinate.
|
||||
float z = 0.0;
|
||||
|
||||
// I had each triangle hold a variable which was its area,
|
||||
// Here, I make sure they all have their areas set correctly.
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
tris[i].area = findArea(tris[i].v[0], tris[i].v[1], tris[i].v[2]);
|
||||
}
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int x = tris[i].xmin; x < tris[i].xmax; x++)
|
||||
{
|
||||
for(int y = tris[i].ymin; y < tris[i].ymax; y++)
|
||||
{
|
||||
// Temporary vertex so we can utilize findArea.
|
||||
vertex tempv;
|
||||
tempv.x = x;
|
||||
tempv.y = y;
|
||||
|
||||
a3 = findArea(tris[i].v[0], tris[i].v[1], tempv);
|
||||
a2 = findArea(tris[i].v[0], tempv, tris[i].v[2]);
|
||||
a1 = findArea(tempv, tris[i].v[1], tris[i].v[2]);
|
||||
|
||||
l1 = a1/tris[i].area;
|
||||
l2 = a2/tris[i].area;
|
||||
l3 = a3/tris[i].area;
|
||||
|
||||
r = (a1*tris[i].v[0].r + a2*tris[i].v[1].r + a3*tris[i].v[2].r)/tris[i].area;
|
||||
g = (a1*tris[i].v[0].g + a2*tris[i].v[1].g + a3*tris[i].v[2].g)/tris[i].area;
|
||||
b = (a1*tris[i].v[0].b + a2*tris[i].v[1].b + a3*tris[i].v[2].b)/tris[i].area;
|
||||
|
||||
if(colormode == 0)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, r, g ,b);
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
|
||||
float z1 = tris[i].v[0].z;
|
||||
float z2 = tris[i].v[1].z;
|
||||
float z3 = tris[i].v[2].z;
|
||||
|
||||
z = (a1*z1 + a2*z2 + a3*z3)/tris[i].area;
|
||||
if(colormode == 1)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, z, 0, 0);
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
else if(colormode == 2)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, 0, (255/(ymax - ymin)) - (y - ymin)*(255/(ymax - ymin)), (y - ymin)*(255/(ymax - ymin)));
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write image to file
|
||||
image->writeToFile(filename);
|
||||
return 0;
|
||||
}
|
1048
A1/shadow8t4/shadow8t4/src/stb_image_write.h
Normal file
1048
A1/shadow8t4/shadow8t4/src/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load diff
1922
A1/shadow8t4/shadow8t4/src/tiny_obj_loader.h
Normal file
1922
A1/shadow8t4/shadow8t4/src/tiny_obj_loader.h
Normal file
File diff suppressed because it is too large
Load diff
61
A1/src/Image.cpp
Normal file
61
A1/src/Image.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "Image.h"
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Image::Image(int w, int h) :
|
||||
width(w),
|
||||
height(h),
|
||||
comp(3),
|
||||
pixels(width*height*comp, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
void Image::setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
// The pixel data is laid out row by row. Each row consists of 'width'
|
||||
// columns, and each column consists of 3 unsigned chars.
|
||||
|
||||
// First check for bounds
|
||||
if(y < 0 || y >= height) {
|
||||
cout << "Row " << y << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
if(x < 0 || x >= width) {
|
||||
cout << "Col " << x << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Since the origin (0, 0) of the image is the upper left corner, we need
|
||||
// to flip the row to make the origin be the lower left corner.
|
||||
y = height - y - 1;
|
||||
// index corresponding to row and col, (assuming single component image)
|
||||
int index = y*width + x;
|
||||
// Multiply by 3 to get the index for the rgb components.
|
||||
assert(index >= 0);
|
||||
assert(3*index + 2 < (int)pixels.size());
|
||||
pixels[3*index + 0] = r;
|
||||
pixels[3*index + 1] = g;
|
||||
pixels[3*index + 2] = b;
|
||||
}
|
||||
|
||||
void Image::writeToFile(const string &filename)
|
||||
{
|
||||
// The distance in bytes from the first byte of a row of pixels to the
|
||||
// first byte of the next row of pixels
|
||||
int stride_in_bytes = width*comp*sizeof(unsigned char);
|
||||
int rc = stbi_write_png(filename.c_str(), width, height, comp, &pixels[0], stride_in_bytes);
|
||||
if(rc) {
|
||||
cout << "Wrote to " << filename << endl;
|
||||
} else {
|
||||
cout << "Couldn't write to " << filename << endl;
|
||||
}
|
||||
}
|
25
A1/src/Image.h
Normal file
25
A1/src/Image.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#ifndef _IMAGE_H_
|
||||
#define _IMAGE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
Image(int width, int height);
|
||||
virtual ~Image();
|
||||
void setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b);
|
||||
void writeToFile(const std::string &filename);
|
||||
int getWidth() const { return width; }
|
||||
int getHeight() const { return height; }
|
||||
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
int comp;
|
||||
std::vector<unsigned char> pixels;
|
||||
};
|
||||
|
||||
#endif
|
45
A1/src/Triangle.cpp
Normal file
45
A1/src/Triangle.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
#include "Triangle.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Tri::Tri()
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = 0.0;
|
||||
v1.y = 0.0;
|
||||
v1.z = 0.0;
|
||||
vertex v2;
|
||||
v2.x = 0.0;
|
||||
v2.y = 0.0;
|
||||
v2.z = 0.0;
|
||||
vertex v3;
|
||||
v3.x = 0.0;
|
||||
v3.y = 0.0;
|
||||
v3.z = 0.0;
|
||||
v.push_back(v1);
|
||||
v.push_back(v2);
|
||||
v.push_back(v3);
|
||||
xmin = 0;
|
||||
xmax = 0;
|
||||
ymin = 0;
|
||||
ymax = 0;
|
||||
area = 0.0;
|
||||
}
|
||||
|
||||
float findArea(vertex &one, vertex &two, vertex &three)
|
||||
{
|
||||
return abs(one.x*two.y + two.x*three.y + three.x*one.y - one.y*two.x - two.y*three.x - three.y*one.x)/2.0;
|
||||
}
|
||||
|
||||
Tri::Tri(vertex &one, vertex &two, vertex &three)
|
||||
{
|
||||
v.push_back(one);
|
||||
v.push_back(two);
|
||||
v.push_back(three);
|
||||
xmin = one.x;
|
||||
xmax = one.x;
|
||||
ymin = one.y;
|
||||
ymax = one.y;
|
||||
area = findArea(one, two, three);
|
||||
}
|
||||
|
34
A1/src/Triangle.h
Normal file
34
A1/src/Triangle.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#ifndef _TRIANGLE_H_
|
||||
#define _TRIANGLE_H_
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
struct vertex
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
float z = 0.0;
|
||||
float r = 0.0;
|
||||
float g = 0.0;
|
||||
float b = 0.0;
|
||||
};
|
||||
|
||||
class Tri
|
||||
{
|
||||
public:
|
||||
Tri();
|
||||
Tri(vertex &one, vertex &two, vertex &three);
|
||||
std::vector<vertex> v;
|
||||
float xmin;
|
||||
float xmax;
|
||||
float ymin;
|
||||
float ymax;
|
||||
float area;
|
||||
};
|
||||
|
||||
float findArea(vertex &one, vertex &two, vertex &three);
|
||||
|
||||
#endif
|
347
A1/src/main.cpp
Normal file
347
A1/src/main.cpp
Normal file
|
@ -0,0 +1,347 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
#include "Image.h"
|
||||
#include "Triangle.h"
|
||||
|
||||
// This allows you to skip the `std::` in front of C++ standard library
|
||||
// functions. You can also say `using std::cout` to be more selective.
|
||||
// You should never do this in a header file.
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 6) {
|
||||
cout << "Usage: A1 meshfile image width height colormode" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
srand(743298);
|
||||
string meshName(argv[1]);
|
||||
string filename(argv[2]);
|
||||
int width = atoi(argv[3]);
|
||||
int height = atoi(argv[4]);
|
||||
int colormode = atoi(argv[5]);
|
||||
|
||||
// Load geometry
|
||||
vector<float> posBuf; // list of vertex positions
|
||||
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
string errStr;
|
||||
|
||||
bool rc = tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, meshName.c_str());
|
||||
|
||||
if(!rc) {
|
||||
cerr << errStr << endl;
|
||||
} else {
|
||||
// Some OBJ files have different indices for vertex positions, normals,
|
||||
// and texture coordinates. For example, a cube corner vertex may have
|
||||
// three different normals. Here, we are going to duplicate all such
|
||||
// vertices.
|
||||
|
||||
// Loop over shapes
|
||||
for(size_t s = 0; s < shapes.size(); s++) {
|
||||
|
||||
// Loop over faces (polygons)
|
||||
size_t index_offset = 0;
|
||||
for(size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) {
|
||||
size_t fv = shapes[s].mesh.num_face_vertices[f];
|
||||
|
||||
// Loop over vertices in the face.
|
||||
for(size_t v = 0; v < fv; v++) {
|
||||
|
||||
// access to vertex
|
||||
tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+0]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+1]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+2]);
|
||||
|
||||
}
|
||||
index_offset += fv;
|
||||
|
||||
// per-face material (IGNORE)
|
||||
shapes[s].mesh.material_ids[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "Number of vertices: " << posBuf.size()/3 << endl;
|
||||
|
||||
vector<vector<float>> zbuf;
|
||||
|
||||
std::vector<Tri> tris;
|
||||
|
||||
// Split posBuf into triangles.
|
||||
for(int i = 0; i < (int)posBuf.size()/9; i++)
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = posBuf[i*9];
|
||||
v1.y = posBuf[i*9 + 1];
|
||||
v1.z = posBuf[i*9 + 2];
|
||||
vertex v2;
|
||||
v2.x = posBuf[i*9 + 3];
|
||||
v2.y = posBuf[i*9 + 4];
|
||||
v2.z = posBuf[i*9 + 5];
|
||||
vertex v3;
|
||||
v3.x = posBuf[i*9 + 6];
|
||||
v3.y = posBuf[i*9 + 7];
|
||||
v3.z = posBuf[i*9 + 8];
|
||||
Tri t(v1, v2, v3);
|
||||
tris.push_back(t);
|
||||
}
|
||||
|
||||
// Initialize min/max variables.
|
||||
float xmin = posBuf[0];
|
||||
float xmax = xmin;
|
||||
float ymin = posBuf[1];
|
||||
float ymax = ymin;
|
||||
float zmin = tris[0].v[0].z;
|
||||
float zmax = zmin;
|
||||
|
||||
// First time finding max and min.
|
||||
// Also, initializing r,g,b per triangle.
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
|
||||
int temp1 = rand()%255;
|
||||
int temp2 = rand()%255;
|
||||
int temp3 = rand()%255;
|
||||
tris[i].v[j].r = temp1;
|
||||
tris[i].v[j].g = temp2;
|
||||
tris[i].v[j].b = temp3;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char r = rand()%255;
|
||||
unsigned char b = rand()%255;
|
||||
unsigned char g = rand()%255;
|
||||
|
||||
|
||||
// Create the image. We're using a `shared_ptr`, a C++11 feature.
|
||||
auto image = make_shared<Image>(width, height);
|
||||
|
||||
// Find scaling ratio.
|
||||
float xratio = (1.0*width/(xmax - xmin));
|
||||
float yratio = (1.0*height/(ymax - ymin));
|
||||
float zratio = (255.0/(zmax-zmin));
|
||||
|
||||
float aratio = 1.0;
|
||||
|
||||
// Determine and assign smaller ratio.
|
||||
if(xratio < yratio)
|
||||
{
|
||||
aratio = xratio;
|
||||
}
|
||||
else
|
||||
{
|
||||
aratio = yratio;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
tris[i].v[j].x *= aratio;
|
||||
tris[i].v[j].y *= aratio;
|
||||
tris[i].v[j].z *= zratio;
|
||||
}
|
||||
}
|
||||
|
||||
xmin = tris[0].v[0].x;
|
||||
xmax = xmin;
|
||||
ymin = tris[0].v[0].y;
|
||||
ymax = ymin;
|
||||
zmin = tris[0].v[0].z;
|
||||
zmax = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
}
|
||||
}
|
||||
|
||||
float xoffset = ((width)/2 - (xmax + xmin)/2);
|
||||
float yoffset = ((height)/2 - (ymax + ymin)/2);
|
||||
float zoffset = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int j = 0; j < (int)tris[i].v.size();j++)
|
||||
{
|
||||
tris[i].v[j].x += xoffset;
|
||||
tris[i].v[j].y += yoffset;
|
||||
tris[i].v[j].z -= zoffset;
|
||||
}
|
||||
}
|
||||
|
||||
xmin = tris[0].v[0].x;
|
||||
xmax = xmin;
|
||||
ymin = tris[0].v[0].y;
|
||||
ymax = ymin;
|
||||
zmin = tris[0].v[0].z;
|
||||
zmax = zmin;
|
||||
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
tris[i].xmin = tris[i].v[0].x;
|
||||
tris[i].xmax = tris[i].v[0].x;
|
||||
tris[i].ymin = tris[i].v[0].y;
|
||||
tris[i].ymax = tris[i].v[0].y;
|
||||
|
||||
for(int j = 0; j < (int)tris[i].v.size(); j++)
|
||||
{
|
||||
|
||||
if(xmin > tris[i].v[j].x)
|
||||
xmin = tris[i].v[j].x;
|
||||
if(xmax < tris[i].v[j].x)
|
||||
xmax = tris[i].v[j].x;
|
||||
if(ymin > tris[i].v[j].y)
|
||||
ymin = tris[i].v[j].y;
|
||||
if(ymax < tris[i].v[j].y)
|
||||
ymax = tris[i].v[j].y;
|
||||
if(zmin > tris[i].v[j].z)
|
||||
zmin = tris[i].v[j].z;
|
||||
if(zmax < tris[i].v[j].z)
|
||||
zmax = tris[i].v[j].z;
|
||||
|
||||
if(tris[i].xmin > tris[i].v[j].x)
|
||||
tris[i].xmin = tris[i].v[j].x;
|
||||
if(tris[i].xmax < tris[i].v[j].x)
|
||||
tris[i].xmax = tris[i].v[j].x;
|
||||
if(tris[i].ymin > tris[i].v[j].y)
|
||||
tris[i].ymin = tris[i].v[j].y;
|
||||
if(tris[i].ymax < tris[i].v[j].y)
|
||||
tris[i].ymax = tris[i].v[j].y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int r = 0; r < width; r++)
|
||||
{
|
||||
vector<float> temp;
|
||||
zbuf.push_back(temp);
|
||||
for(int c = 0; c < height; c++)
|
||||
{
|
||||
zbuf.at(r).push_back(zmin);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize variables for the three
|
||||
// Barycentric areas.
|
||||
float a1 = 0.0;
|
||||
float a2 = 0.0;
|
||||
float a3 = 0.0;
|
||||
|
||||
// Initialize variables for the three
|
||||
// Barycentric coordinates.
|
||||
float l1 = 0.0;
|
||||
float l2 = 0.0;
|
||||
float l3 = 0.0;
|
||||
|
||||
// Variable to hold current z coordinate.
|
||||
float z = 0.0;
|
||||
|
||||
// I had each triangle hold a variable which was its area,
|
||||
// Here, I make sure they all have their areas set correctly.
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
tris[i].area = findArea(tris[i].v[0], tris[i].v[1], tris[i].v[2]);
|
||||
}
|
||||
for(int i = 0; i < (int)tris.size(); i++)
|
||||
{
|
||||
for(int x = tris[i].xmin; x < tris[i].xmax; x++)
|
||||
{
|
||||
for(int y = tris[i].ymin; y < tris[i].ymax; y++)
|
||||
{
|
||||
// Temporary vertex so we can utilize findArea.
|
||||
vertex tempv;
|
||||
tempv.x = x;
|
||||
tempv.y = y;
|
||||
|
||||
a3 = findArea(tris[i].v[0], tris[i].v[1], tempv);
|
||||
a2 = findArea(tris[i].v[0], tempv, tris[i].v[2]);
|
||||
a1 = findArea(tempv, tris[i].v[1], tris[i].v[2]);
|
||||
|
||||
l1 = a1/tris[i].area;
|
||||
l2 = a2/tris[i].area;
|
||||
l3 = a3/tris[i].area;
|
||||
|
||||
r = (a1*tris[i].v[0].r + a2*tris[i].v[1].r + a3*tris[i].v[2].r)/tris[i].area;
|
||||
g = (a1*tris[i].v[0].g + a2*tris[i].v[1].g + a3*tris[i].v[2].g)/tris[i].area;
|
||||
b = (a1*tris[i].v[0].b + a2*tris[i].v[1].b + a3*tris[i].v[2].b)/tris[i].area;
|
||||
|
||||
if(colormode == 0)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, r, g ,b);
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
|
||||
float z1 = tris[i].v[0].z;
|
||||
float z2 = tris[i].v[1].z;
|
||||
float z3 = tris[i].v[2].z;
|
||||
|
||||
z = (a1*z1 + a2*z2 + a3*z3)/tris[i].area;
|
||||
if(colormode == 1)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, z, 0, 0);
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
else if(colormode == 2)
|
||||
{
|
||||
if(l1 + l2 + l3 <= 1.01 && zbuf.at(x).at(y) <= z)
|
||||
{
|
||||
image->setPixel(x, y, 0, (255/(ymax - ymin)) - (y - ymin)*(255/(ymax - ymin)), (y - ymin)*(255/(ymax - ymin)));
|
||||
zbuf.at(x).at(y) = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write image to file
|
||||
image->writeToFile(filename);
|
||||
return 0;
|
||||
}
|
1048
A1/src/stb_image_write.h
Normal file
1048
A1/src/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load diff
1922
A1/src/tiny_obj_loader.h
Normal file
1922
A1/src/tiny_obj_loader.h
Normal file
File diff suppressed because it is too large
Load diff
1
A2/.gitignore
vendored
Normal file
1
A2/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
126
A2/CMakeLists.txt
Normal file
126
A2/CMakeLists.txt
Normal file
|
@ -0,0 +1,126 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(A2)
|
||||
|
||||
# FOR LAB MACHINES ONLY!
|
||||
# DO NOT EDIT
|
||||
SET(DEF_DIR_GLM "C:\\c++\\glm")
|
||||
SET(DEF_DIR_GLFW "C:\\c++\\glfw-3.2.1")
|
||||
SET(DEF_DIR_GLEW "C:\\c++\\glew-2.0.0")
|
||||
|
||||
# Is this the solution?
|
||||
# Override with `cmake -DSOL=ON ..`
|
||||
OPTION(SOL "Solution" OFF)
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them also show up in IDEs.
|
||||
IF(${SOL})
|
||||
FILE(GLOB_RECURSE SOURCES "src0/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src0/*.h")
|
||||
ELSE()
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
ENDIF()
|
||||
FILE(GLOB_RECURSE GLSL "resources/*.glsl")
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS} ${GLSL})
|
||||
|
||||
# Get the GLM environment variable. Since GLM is a header-only library, we
|
||||
# just need to add it to the include directory.
|
||||
SET(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
|
||||
IF(NOT GLM_INCLUDE_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLM_INCLUDE_DIR to the root directory of your GLM installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLM in ${DEF_DIR_GLM}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLM})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLM_INCLUDE_DIR ${DEF_DIR_GLM})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLM_INCLUDE_DIR})
|
||||
|
||||
# Get the GLFW environment variable. There should be a CMakeLists.txt in the
|
||||
# specified directory.
|
||||
SET(GLFW_DIR "$ENV{GLFW_DIR}")
|
||||
IF(NOT GLFW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLFW_DIR to the root directory of your GLFW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLFW in ${DEF_DIR_GLFW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLFW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLFW_DIR ${DEF_DIR_GLFW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
OPTION(GLFW_BUILD_EXAMPLES "GLFW_BUILD_EXAMPLES" OFF)
|
||||
OPTION(GLFW_BUILD_TESTS "GLFW_BUILD_TESTS" OFF)
|
||||
OPTION(GLFW_BUILD_DOCS "GLFW_BUILD_DOCS" OFF)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES Release)
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/release)
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/debug)
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLFW_DIR}/include)
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} glfw ${GLFW_LIBRARIES})
|
||||
|
||||
# Get the GLEW environment variable.
|
||||
SET(GLEW_DIR "$ENV{GLEW_DIR}")
|
||||
IF(NOT GLEW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLEW_DIR to the root directory of your GLEW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLEW in ${DEF_DIR_GLEW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLEW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLEW_DIR ${DEF_DIR_GLEW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLEW_DIR}/include)
|
||||
IF(WIN32)
|
||||
# With prebuilt binaries
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/Release/Win32/glew32s.lib)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/libGLEW.a)
|
||||
ENDIF()
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} opengl32.lib)
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
IF(APPLE)
|
||||
# Add required frameworks for GLFW.
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo")
|
||||
ELSE()
|
||||
#Link the Linux OpenGL library
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "GL")
|
||||
ENDIF()
|
||||
ENDIF()
|
29
A2/resources/cube.obj
Normal file
29
A2/resources/cube.obj
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Blender v2.71 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
v 0.500000 0.500000 -0.500000
|
||||
v 0.500000 -0.500000 -0.500000
|
||||
v -0.500000 -0.500000 -0.500000
|
||||
v -0.500000 0.500000 -0.500000
|
||||
v 0.500000 0.500000 0.500000
|
||||
v 0.500000 -0.500000 0.500000
|
||||
v -0.500000 -0.500000 0.500000
|
||||
v -0.500000 0.500000 0.500000
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn 1.000000 -0.000000 -0.000000
|
||||
vn -0.000000 -1.000000 -0.000000
|
||||
vn -1.000000 0.000000 -0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
s off
|
||||
f 2//1 3//1 4//1
|
||||
f 8//2 7//2 6//2
|
||||
f 1//3 5//3 6//3
|
||||
f 2//4 6//4 7//4
|
||||
f 7//5 8//5 4//5
|
||||
f 1//6 4//6 8//6
|
||||
f 1//1 2//1 4//1
|
||||
f 5//2 8//2 6//2
|
||||
f 2//3 1//3 6//3
|
||||
f 3//4 2//4 7//4
|
||||
f 3//5 7//5 4//5
|
||||
f 5//6 1//6 8//6
|
8
A2/resources/frag.glsl
Normal file
8
A2/resources/frag.glsl
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 120
|
||||
|
||||
varying vec3 vCol;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(vCol.r, vCol.g, vCol.b, 1.0);
|
||||
}
|
13
A2/resources/vert.glsl
Normal file
13
A2/resources/vert.glsl
Normal file
|
@ -0,0 +1,13 @@
|
|||
#version 120
|
||||
|
||||
attribute vec4 aPos;
|
||||
attribute vec3 aNor;
|
||||
uniform mat4 P;
|
||||
uniform mat4 MV;
|
||||
varying vec3 vCol;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * MV * aPos;
|
||||
vCol = 0.5*(aNor + 1.0);
|
||||
}
|
43
A2/src/Body.h
Normal file
43
A2/src/Body.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Create Body Class
|
||||
|
||||
/*
|
||||
Class Body
|
||||
{
|
||||
Head h;
|
||||
Shoulder sl;
|
||||
Shoulder sr;
|
||||
Leg ull;
|
||||
Leg ulr;
|
||||
bool selected = true;
|
||||
|
||||
draw(MatrixStack MV);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
static void renderA(MatrixStack MV)
|
||||
{
|
||||
MV.pushMatrix();
|
||||
MV.translate(-1, 0, 0);
|
||||
MV.rotate(-(2*PI)/16, 0, 0, 1);
|
||||
MV.scale(0.5, 4, 0.5);
|
||||
glUniformMatrix4fv(unifIDs["MV"], 1, GL_FALSE, value_ptr(MV.topMatrix()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, indCount);
|
||||
MV.popMatrix(); // This line undoes the transformation applied to #1
|
||||
MV.pushMatrix();
|
||||
MV.scale(2, 0.5, 0.5);
|
||||
glUniformMatrix4fv(unifIDs["MV"], 1, GL_FALSE, value_ptr(MV.topMatrix()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, indCount);
|
||||
MV.popMatrix(); // This line undoes the transformation applied to #2
|
||||
MV.pushMatrix();
|
||||
MV.translate(1, 0, 0);
|
||||
MV.rotate((2*PI)/16, 0, 0, 1);
|
||||
MV.scale(0.5, 4, 0.5);
|
||||
glUniformMatrix4fv(unifIDs["MV"], 1, GL_FALSE, value_ptr(MV.topMatrix()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, indCount);
|
||||
MV.popMatrix(); // This line undoes the transformation applied to #3
|
||||
}
|
||||
|
||||
|
||||
*/
|
152
A2/src/GLSL.cpp
Normal file
152
A2/src/GLSL.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#include "GLSL.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
const char * errorString(GLenum err)
|
||||
{
|
||||
switch(err) {
|
||||
case GL_NO_ERROR:
|
||||
return "No error";
|
||||
case GL_INVALID_ENUM:
|
||||
return "Invalid enum";
|
||||
case GL_INVALID_VALUE:
|
||||
return "Invalid value";
|
||||
case GL_INVALID_OPERATION:
|
||||
return "Invalid operation";
|
||||
case GL_STACK_OVERFLOW:
|
||||
return "Stack overflow";
|
||||
case GL_STACK_UNDERFLOW:
|
||||
return "Stack underflow";
|
||||
case GL_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
return "No error";
|
||||
}
|
||||
}
|
||||
|
||||
void checkVersion()
|
||||
{
|
||||
int major, minor;
|
||||
major = minor = 0;
|
||||
const char *verstr = (const char *)glGetString(GL_VERSION);
|
||||
|
||||
if((verstr == NULL) || (sscanf(verstr, "%d.%d", &major, &minor) != 2)) {
|
||||
printf("Invalid GL_VERSION format %d.%d\n", major, minor);
|
||||
}
|
||||
if(major < 2) {
|
||||
printf("This shader example will not work due to the installed Opengl version, which is %d.%d.\n", major, minor);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void checkError(const char *str)
|
||||
{
|
||||
GLenum glErr = glGetError();
|
||||
if(glErr != GL_NO_ERROR) {
|
||||
if(str) {
|
||||
printf("%s: ", str);
|
||||
}
|
||||
printf("GL_ERROR = %s.\n", errorString(glErr));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void printShaderInfoLog(GLuint shader)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetShaderInfoLog(shader, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Shader InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
void printProgramInfoLog(GLuint program)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetProgramInfoLog(program, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Program InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
char *textFileRead(const char *fn)
|
||||
{
|
||||
FILE *fp;
|
||||
char *content = NULL;
|
||||
int count = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"rt");
|
||||
if(fp != NULL) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
count = (int)ftell(fp);
|
||||
rewind(fp);
|
||||
if(count > 0) {
|
||||
content = (char *)malloc(sizeof(char) * (count+1));
|
||||
count = (int)fread(content,sizeof(char),count,fp);
|
||||
content[count] = '\0';
|
||||
}
|
||||
fclose(fp);
|
||||
} else {
|
||||
printf("error loading %s\n", fn);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
int textFileWrite(const char *fn, const char *s)
|
||||
{
|
||||
FILE *fp;
|
||||
int status = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"w");
|
||||
if(fp != NULL) {
|
||||
if(fwrite(s,sizeof(char),strlen(s),fp) == strlen(s)) {
|
||||
status = 1;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
}
|
40
A2/src/GLSL.h
Normal file
40
A2/src/GLSL.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef __GLSL__
|
||||
#define __GLSL__
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For printing out the current file and line number //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <sstream>
|
||||
|
||||
template <typename T>
|
||||
std::string NumberToString(T x)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
#define GET_FILE_LINE (std::string(__FILE__) + ":" + NumberToString(__LINE__)).c_str()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
void checkVersion();
|
||||
void checkError(const char *str = 0);
|
||||
void printProgramInfoLog(GLuint program);
|
||||
void printShaderInfoLog(GLuint shader);
|
||||
int textFileWrite(const char *filename, const char *s);
|
||||
char *textFileRead(const char *filename);
|
||||
}
|
||||
|
||||
#endif
|
114
A2/src/MatrixStack.cpp
Normal file
114
A2/src/MatrixStack.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
#include "MatrixStack.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
MatrixStack::MatrixStack()
|
||||
{
|
||||
mstack = make_shared< stack<glm::mat4> >();
|
||||
mstack->push(glm::mat4(1.0));
|
||||
}
|
||||
|
||||
MatrixStack::~MatrixStack()
|
||||
{
|
||||
}
|
||||
|
||||
void MatrixStack::pushMatrix()
|
||||
{
|
||||
const glm::mat4 &top = mstack->top();
|
||||
mstack->push(top);
|
||||
assert(mstack->size() < 100);
|
||||
}
|
||||
|
||||
void MatrixStack::popMatrix()
|
||||
{
|
||||
assert(!mstack->empty());
|
||||
mstack->pop();
|
||||
// There should always be one matrix left.
|
||||
assert(!mstack->empty());
|
||||
}
|
||||
|
||||
void MatrixStack::loadIdentity()
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top = glm::mat4(1.0);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(const glm::vec3 &t)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::translate(t);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(float x, float y, float z)
|
||||
{
|
||||
translate(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(const glm::vec3 &s)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::scale(s);
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float x, float y, float z)
|
||||
{
|
||||
scale(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float s)
|
||||
{
|
||||
scale(glm::vec3(s, s, s));
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, const glm::vec3 &axis)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::rotate(angle, axis);
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, float x, float y, float z)
|
||||
{
|
||||
rotate(angle, glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::multMatrix(const glm::mat4 &matrix)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= matrix;
|
||||
}
|
||||
|
||||
const glm::mat4 &MatrixStack::topMatrix() const
|
||||
{
|
||||
return mstack->top();
|
||||
}
|
||||
|
||||
void MatrixStack::print(const glm::mat4 &mat, const char *name)
|
||||
{
|
||||
if(name) {
|
||||
printf("%s = [\n", name);
|
||||
}
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
// mat[j] returns the jth column
|
||||
printf("%- 5.2f ", mat[j][i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if(name) {
|
||||
printf("];");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void MatrixStack::print(const char *name) const
|
||||
{
|
||||
print(mstack->top(), name);
|
||||
}
|
50
A2/src/MatrixStack.h
Normal file
50
A2/src/MatrixStack.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#ifndef _MatrixStack_H_
|
||||
#define _MatrixStack_H_
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <glm/fwd.hpp>
|
||||
|
||||
class MatrixStack
|
||||
{
|
||||
public:
|
||||
MatrixStack();
|
||||
virtual ~MatrixStack();
|
||||
|
||||
// glPushMatrix(): Copies the current matrix and adds it to the top of the stack
|
||||
void pushMatrix();
|
||||
// glPopMatrix(): Removes the top of the stack and sets the current matrix to be the matrix that is now on top
|
||||
void popMatrix();
|
||||
|
||||
// glLoadIdentity(): Sets the top matrix to be the identity
|
||||
void loadIdentity();
|
||||
// glMultMatrix(): Right multiplies the top matrix
|
||||
void multMatrix(const glm::mat4 &matrix);
|
||||
|
||||
// glTranslate(): Right multiplies the top matrix by a translation matrix
|
||||
void translate(const glm::vec3 &trans);
|
||||
void translate(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(const glm::vec3 &scale);
|
||||
void scale(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(float size);
|
||||
// glRotate(): Right multiplies the top matrix by a rotation matrix (angle in radians)
|
||||
void rotate(float angle, const glm::vec3 &axis);
|
||||
void rotate(float angle, float x, float y, float z);
|
||||
|
||||
// glGet(GL_MODELVIEW_MATRIX): Gets the top matrix
|
||||
const glm::mat4 &topMatrix() const;
|
||||
|
||||
// Prints out the specified matrix
|
||||
static void print(const glm::mat4 &mat, const char *name = 0);
|
||||
// Prints out the top matrix
|
||||
void print(const char *name = 0) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr< std::stack<glm::mat4> > mstack;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
126
A2/src/Program.cpp
Normal file
126
A2/src/Program.cpp
Normal file
|
@ -0,0 +1,126 @@
|
|||
#include "Program.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "GLSL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Program::Program() :
|
||||
vShaderName(""),
|
||||
fShaderName(""),
|
||||
pid(0),
|
||||
verbose(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Program::~Program()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Program::setShaderNames(const string &v, const string &f)
|
||||
{
|
||||
vShaderName = v;
|
||||
fShaderName = f;
|
||||
}
|
||||
|
||||
bool Program::init()
|
||||
{
|
||||
GLint rc;
|
||||
|
||||
// Create shader handles
|
||||
GLuint VS = glCreateShader(GL_VERTEX_SHADER);
|
||||
GLuint FS = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
// Read shader sources
|
||||
const char *vshader = GLSL::textFileRead(vShaderName.c_str());
|
||||
const char *fshader = GLSL::textFileRead(fShaderName.c_str());
|
||||
glShaderSource(VS, 1, &vshader, NULL);
|
||||
glShaderSource(FS, 1, &fshader, NULL);
|
||||
|
||||
// Compile vertex shader
|
||||
glCompileShader(VS);
|
||||
glGetShaderiv(VS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(VS);
|
||||
cout << "Error compiling vertex shader " << vShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compile fragment shader
|
||||
glCompileShader(FS);
|
||||
glGetShaderiv(FS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(FS);
|
||||
cout << "Error compiling fragment shader " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the program and link
|
||||
pid = glCreateProgram();
|
||||
glAttachShader(pid, VS);
|
||||
glAttachShader(pid, FS);
|
||||
glLinkProgram(pid);
|
||||
glGetProgramiv(pid, GL_LINK_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printProgramInfoLog(pid);
|
||||
cout << "Error linking shaders " << vShaderName << " and " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Program::bind()
|
||||
{
|
||||
glUseProgram(pid);
|
||||
}
|
||||
|
||||
void Program::unbind()
|
||||
{
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Program::addAttribute(const string &name)
|
||||
{
|
||||
attributes[name] = glGetAttribLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
void Program::addUniform(const string &name)
|
||||
{
|
||||
uniforms[name] = glGetUniformLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
GLint Program::getAttribute(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator attribute = attributes.find(name.c_str());
|
||||
if(attribute == attributes.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not an attribute variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return attribute->second;
|
||||
}
|
||||
|
||||
GLint Program::getUniform(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator uniform = uniforms.find(name.c_str());
|
||||
if(uniform == uniforms.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not a uniform variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return uniform->second;
|
||||
}
|
44
A2/src/Program.h
Normal file
44
A2/src/Program.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#ifndef __Program__
|
||||
#define __Program__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* An OpenGL Program (vertex and fragment shaders)
|
||||
*/
|
||||
class Program
|
||||
{
|
||||
public:
|
||||
Program();
|
||||
virtual ~Program();
|
||||
|
||||
void setVerbose(bool v) { verbose = v; }
|
||||
bool isVerbose() const { return verbose; }
|
||||
|
||||
void setShaderNames(const std::string &v, const std::string &f);
|
||||
virtual bool init();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
|
||||
void addAttribute(const std::string &name);
|
||||
void addUniform(const std::string &name);
|
||||
GLint getAttribute(const std::string &name) const;
|
||||
GLint getUniform(const std::string &name) const;
|
||||
|
||||
protected:
|
||||
std::string vShaderName;
|
||||
std::string fShaderName;
|
||||
|
||||
private:
|
||||
GLuint pid;
|
||||
std::map<std::string,GLint> attributes;
|
||||
std::map<std::string,GLint> uniforms;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
#endif
|
135
A2/src/Shape.cpp
Normal file
135
A2/src/Shape.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
#include "Shape.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "Program.h"
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Shape::Shape() :
|
||||
posBufID(0),
|
||||
norBufID(0),
|
||||
texBufID(0)
|
||||
{
|
||||
}
|
||||
|
||||
Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
void Shape::loadMesh(const string &meshName)
|
||||
{
|
||||
// Load geometry
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
string errStr;
|
||||
bool rc = tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, meshName.c_str());
|
||||
if(!rc) {
|
||||
cerr << errStr << endl;
|
||||
} else {
|
||||
// Some OBJ files have different indices for vertex positions, normals,
|
||||
// and texture coordinates. For example, a cube corner vertex may have
|
||||
// three different normals. Here, we are going to duplicate all such
|
||||
// vertices.
|
||||
// Loop over shapes
|
||||
for(size_t s = 0; s < shapes.size(); s++) {
|
||||
// Loop over faces (polygons)
|
||||
size_t index_offset = 0;
|
||||
for(size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) {
|
||||
size_t fv = shapes[s].mesh.num_face_vertices[f];
|
||||
// Loop over vertices in the face.
|
||||
for(size_t v = 0; v < fv; v++) {
|
||||
// access to vertex
|
||||
tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+0]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+1]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+2]);
|
||||
if(!attrib.normals.empty()) {
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+0]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+1]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+2]);
|
||||
}
|
||||
if(!attrib.texcoords.empty()) {
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+0]);
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+1]);
|
||||
}
|
||||
}
|
||||
index_offset += fv;
|
||||
// per-face material (IGNORE)
|
||||
shapes[s].mesh.material_ids[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shape::init()
|
||||
{
|
||||
// Send the position array to the GPU
|
||||
glGenBuffers(1, &posBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, posBuf.size()*sizeof(float), &posBuf[0], GL_STATIC_DRAW);
|
||||
|
||||
// Send the normal array to the GPU
|
||||
if(!norBuf.empty()) {
|
||||
glGenBuffers(1, &norBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, norBuf.size()*sizeof(float), &norBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Send the texture array to the GPU
|
||||
if(!texBuf.empty()) {
|
||||
glGenBuffers(1, &texBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, texBuf.size()*sizeof(float), &texBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Unbind the arrays
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
void Shape::draw(const shared_ptr<Program> prog) const
|
||||
{
|
||||
// Bind position buffer
|
||||
int h_pos = prog->getAttribute("aPos");
|
||||
glEnableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glVertexAttribPointer(h_pos, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
|
||||
// Bind normal buffer
|
||||
int h_nor = prog->getAttribute("aNor");
|
||||
if(h_nor != -1 && norBufID != 0) {
|
||||
glEnableVertexAttribArray(h_nor);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glVertexAttribPointer(h_nor, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Bind texcoords buffer
|
||||
int h_tex = prog->getAttribute("aTex");
|
||||
if(h_tex != -1 && texBufID != 0) {
|
||||
glEnableVertexAttribArray(h_tex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glVertexAttribPointer(h_tex, 2, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Draw
|
||||
int count = posBuf.size()/3; // number of indices to be rendered
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
// Disable and unbind
|
||||
if(h_tex != -1) {
|
||||
glDisableVertexAttribArray(h_tex);
|
||||
}
|
||||
if(h_nor != -1) {
|
||||
glDisableVertexAttribArray(h_nor);
|
||||
}
|
||||
glDisableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
36
A2/src/Shape.h
Normal file
36
A2/src/Shape.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#ifndef _SHAPE_H_
|
||||
#define _SHAPE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class Program;
|
||||
|
||||
/**
|
||||
* A shape defined by a list of triangles
|
||||
* - posBuf should be of length 3*ntris
|
||||
* - norBuf should be of length 3*ntris (if normals are available)
|
||||
* - texBuf should be of length 2*ntris (if texture coords are available)
|
||||
* posBufID, norBufID, and texBufID are OpenGL buffer identifiers.
|
||||
*/
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
Shape();
|
||||
virtual ~Shape();
|
||||
void loadMesh(const std::string &meshName);
|
||||
void init();
|
||||
void draw(const std::shared_ptr<Program> prog) const;
|
||||
|
||||
private:
|
||||
std::vector<float> posBuf;
|
||||
std::vector<float> norBuf;
|
||||
std::vector<float> texBuf;
|
||||
unsigned posBufID;
|
||||
unsigned norBufID;
|
||||
unsigned texBufID;
|
||||
};
|
||||
|
||||
#endif
|
187
A2/src/main.cpp
Normal file
187
A2/src/main.cpp
Normal file
|
@ -0,0 +1,187 @@
|
|||
#include <cassert>
|
||||
#include <cstring>
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "MatrixStack.h"
|
||||
#include "Shape.h"
|
||||
#include "Program.h"
|
||||
|
||||
#define PI 3.14159
|
||||
|
||||
using namespace std;
|
||||
using namespace glm;
|
||||
|
||||
GLFWwindow *window; // Main application window
|
||||
string RESOURCE_DIR = "./"; // Where the resources are loaded from
|
||||
shared_ptr<Program> prog;
|
||||
shared_ptr<Shape> shape;
|
||||
|
||||
|
||||
GLuint progID;
|
||||
map<string,GLint> attrIDs;
|
||||
map<string,GLint> unifIDs;
|
||||
map<string,GLuint> bufIDs;
|
||||
int indCount;
|
||||
// This function is called when a GLFW error occurs
|
||||
static void error_callback(int error, const char *description)
|
||||
{
|
||||
cerr << description << endl;
|
||||
}
|
||||
|
||||
// This function is called when a key is pressed
|
||||
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called when the mouse is clicked
|
||||
static void mouse_callback(GLFWwindow *window, int button, int action, int mods)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// If the window is resized, capture the new size and reset the viewport
|
||||
static void resize_callback(GLFWwindow *window, int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
GLSL::checkVersion();
|
||||
|
||||
// Set background color.
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// Enable z-buffer test.
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Initialize mesh.
|
||||
shape = make_shared<Shape>();
|
||||
shape->loadMesh(RESOURCE_DIR + "teapot.obj");
|
||||
shape->init();
|
||||
|
||||
// Initialize the GLSL program.
|
||||
prog = make_shared<Program>();
|
||||
prog->setVerbose(false); // Set this to true when debugging.
|
||||
prog->setShaderNames(RESOURCE_DIR + "simple_vert.glsl", RESOURCE_DIR + "simple_frag.glsl");
|
||||
prog->init();
|
||||
prog->addUniform("P");
|
||||
prog->addUniform("MV");
|
||||
prog->addAttribute("aPos");
|
||||
prog->addAttribute("aNor");
|
||||
|
||||
// If there were any OpenGL errors, this will print something.
|
||||
// You can intersperse this line in your code to find the exact location
|
||||
// of your OpenGL error.
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
static void render()
|
||||
{
|
||||
// Get current frame buffer size.
|
||||
int width, height;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
float aspect = width/(float)height;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
// Clear framebuffer.
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Create matrix stacks.
|
||||
auto P = make_shared<MatrixStack>();
|
||||
auto MV = make_shared<MatrixStack>();
|
||||
// Apply projection.
|
||||
P->pushMatrix();
|
||||
P->multMatrix(glm::perspective((float)(45.0*M_PI/180.0), aspect, 0.01f, 100.0f));
|
||||
// Apply camera transform.
|
||||
MV->pushMatrix();
|
||||
MV->translate(glm::vec3(0, -0.5, -3));
|
||||
|
||||
// Draw mesh using GLSL.
|
||||
prog->bind();
|
||||
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, &P->topMatrix()[0][0]);
|
||||
glUniformMatrix4fv(prog->getUniform("MV"), 1, GL_FALSE, &MV->topMatrix()[0][0]);
|
||||
shape->draw(prog);
|
||||
prog->unbind();
|
||||
|
||||
// Pop matrix stacks.
|
||||
MV->popMatrix();
|
||||
P->popMatrix();
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 2) {
|
||||
cout << "Please specify the resource directory." << endl;
|
||||
return 0;
|
||||
}
|
||||
RESOURCE_DIR = argv[1] + string("/");
|
||||
|
||||
// Set error callback.
|
||||
glfwSetErrorCallback(error_callback);
|
||||
// Initialize the library.
|
||||
if(!glfwInit()) {
|
||||
return -1;
|
||||
}
|
||||
// Create a windowed mode window and its OpenGL context.
|
||||
window = glfwCreateWindow(640, 480, "Alexander Huddleston", NULL, NULL);
|
||||
if(!window) {
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
// Make the window's context current.
|
||||
glfwMakeContextCurrent(window);
|
||||
// Initialize GLEW.
|
||||
glewExperimental = true;
|
||||
if(glewInit() != GLEW_OK) {
|
||||
cerr << "Failed to initialize GLEW" << endl;
|
||||
return -1;
|
||||
}
|
||||
glGetError(); // A bug in glewInit() causes an error that we can safely ignore.
|
||||
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
|
||||
cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
|
||||
GLSL::checkVersion();
|
||||
// Set vsync.
|
||||
glfwSwapInterval(1);
|
||||
// Set keyboard callback.
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
// Set the mouse call back.
|
||||
glfwSetMouseButtonCallback(window, mouse_callback);
|
||||
// Set the window resize call back.
|
||||
glfwSetFramebufferSizeCallback(window, resize_callback);
|
||||
// Initialize scene.
|
||||
init();
|
||||
// Loop until the user closes the window.
|
||||
while(!glfwWindowShouldClose(window)) {
|
||||
// Render scene.
|
||||
render();
|
||||
// Swap front and back buffers.
|
||||
glfwSwapBuffers(window);
|
||||
// Poll for and process events.
|
||||
glfwPollEvents();
|
||||
}
|
||||
// Quit program.
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
1922
A2/src/tiny_obj_loader.h
Normal file
1922
A2/src/tiny_obj_loader.h
Normal file
File diff suppressed because it is too large
Load diff
1
L00(old)/.gitignore
vendored
Normal file
1
L00(old)/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
118
L00(old)/CMakeLists.txt
Normal file
118
L00(old)/CMakeLists.txt
Normal file
|
@ -0,0 +1,118 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(L00)
|
||||
|
||||
# FOR LAB MACHINES ONLY!
|
||||
# DO NOT EDIT
|
||||
SET(DEF_DIR_GLM "C:\\c++\\glm")
|
||||
SET(DEF_DIR_GLFW "C:\\c++\\glfw-3.2.1")
|
||||
SET(DEF_DIR_GLEW "C:\\c++\\glew-2.0.0")
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them show up in IDEs.
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
FILE(GLOB_RECURSE GLSL "resources/*.glsl")
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS} ${GLSL})
|
||||
|
||||
# Get the GLM environment variable. Since GLM is a header-only library, we
|
||||
# just need to add it to the include directory.
|
||||
SET(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
|
||||
IF(NOT GLM_INCLUDE_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLM_INCLUDE_DIR to the root directory of your GLM installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLM in ${DEF_DIR_GLM}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLM})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLM_INCLUDE_DIR ${DEF_DIR_GLM})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLM_INCLUDE_DIR})
|
||||
|
||||
# Get the GLFW environment variable. There should be a CMakeLists.txt in the
|
||||
# specified directory.
|
||||
SET(GLFW_DIR "$ENV{GLFW_DIR}")
|
||||
IF(NOT GLFW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLFW_DIR to the root directory of your GLFW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLFW in ${DEF_DIR_GLFW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLFW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLFW_DIR ${DEF_DIR_GLFW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
OPTION(GLFW_BUILD_EXAMPLES "GLFW_BUILD_EXAMPLES" OFF)
|
||||
OPTION(GLFW_BUILD_TESTS "GLFW_BUILD_TESTS" OFF)
|
||||
OPTION(GLFW_BUILD_DOCS "GLFW_BUILD_DOCS" OFF)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES Release)
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/release)
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/debug)
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLFW_DIR}/include)
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} glfw ${GLFW_LIBRARIES})
|
||||
|
||||
# Get the GLEW environment variable.
|
||||
SET(GLEW_DIR "$ENV{GLEW_DIR}")
|
||||
IF(NOT GLEW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLEW_DIR to the root directory of your GLEW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLEW in ${DEF_DIR_GLEW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLEW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLEW_DIR ${DEF_DIR_GLEW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLEW_DIR}/include)
|
||||
IF(WIN32)
|
||||
# With prebuilt binaries
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/Release/Win32/glew32s.lib)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/libGLEW.a)
|
||||
ENDIF()
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} opengl32.lib)
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
IF(APPLE)
|
||||
# Add required frameworks for GLFW.
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo")
|
||||
ELSE()
|
||||
#Link the Linux OpenGL library
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "GL")
|
||||
ENDIF()
|
||||
ENDIF()
|
11
L00(old)/resources/simple_frag.glsl
Normal file
11
L00(old)/resources/simple_frag.glsl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#version 120
|
||||
|
||||
varying vec3 fragNor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = normalize(fragNor);
|
||||
// Map normal in the range [-1, 1] to color in range [0, 1];
|
||||
vec3 color = 0.5*normal + 0.5;
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
12
L00(old)/resources/simple_vert.glsl
Normal file
12
L00(old)/resources/simple_vert.glsl
Normal file
|
@ -0,0 +1,12 @@
|
|||
#version 120
|
||||
attribute vec4 vertPos;
|
||||
attribute vec3 vertNor;
|
||||
uniform mat4 P;
|
||||
uniform mat4 MV;
|
||||
varying vec3 fragNor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * MV * vertPos;
|
||||
fragNor = (MV * vec4(vertNor, 0.0)).xyz;
|
||||
}
|
5049
L00(old)/resources/teapot.obj
Normal file
5049
L00(old)/resources/teapot.obj
Normal file
File diff suppressed because it is too large
Load diff
152
L00(old)/src/GLSL.cpp
Normal file
152
L00(old)/src/GLSL.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#include "GLSL.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
const char * errorString(GLenum err)
|
||||
{
|
||||
switch(err) {
|
||||
case GL_NO_ERROR:
|
||||
return "No error";
|
||||
case GL_INVALID_ENUM:
|
||||
return "Invalid enum";
|
||||
case GL_INVALID_VALUE:
|
||||
return "Invalid value";
|
||||
case GL_INVALID_OPERATION:
|
||||
return "Invalid operation";
|
||||
case GL_STACK_OVERFLOW:
|
||||
return "Stack overflow";
|
||||
case GL_STACK_UNDERFLOW:
|
||||
return "Stack underflow";
|
||||
case GL_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
return "No error";
|
||||
}
|
||||
}
|
||||
|
||||
void checkVersion()
|
||||
{
|
||||
int major, minor;
|
||||
major = minor = 0;
|
||||
const char *verstr = (const char *)glGetString(GL_VERSION);
|
||||
|
||||
if((verstr == NULL) || (sscanf(verstr, "%d.%d", &major, &minor) != 2)) {
|
||||
printf("Invalid GL_VERSION format %d.%d\n", major, minor);
|
||||
}
|
||||
if(major < 2) {
|
||||
printf("This shader example will not work due to the installed Opengl version, which is %d.%d.\n", major, minor);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void checkError(const char *str)
|
||||
{
|
||||
GLenum glErr = glGetError();
|
||||
if(glErr != GL_NO_ERROR) {
|
||||
if(str) {
|
||||
printf("%s: ", str);
|
||||
}
|
||||
printf("GL_ERROR = %s.\n", errorString(glErr));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void printShaderInfoLog(GLuint shader)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetShaderInfoLog(shader, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Shader InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
void printProgramInfoLog(GLuint program)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetProgramInfoLog(program, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Program InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
char *textFileRead(const char *fn)
|
||||
{
|
||||
FILE *fp;
|
||||
char *content = NULL;
|
||||
int count = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"rt");
|
||||
if(fp != NULL) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
count = (int)ftell(fp);
|
||||
rewind(fp);
|
||||
if(count > 0) {
|
||||
content = (char *)malloc(sizeof(char) * (count+1));
|
||||
count = (int)fread(content,sizeof(char),count,fp);
|
||||
content[count] = '\0';
|
||||
}
|
||||
fclose(fp);
|
||||
} else {
|
||||
printf("error loading %s\n", fn);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
int textFileWrite(const char *fn, const char *s)
|
||||
{
|
||||
FILE *fp;
|
||||
int status = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"w");
|
||||
if(fp != NULL) {
|
||||
if(fwrite(s,sizeof(char),strlen(s),fp) == strlen(s)) {
|
||||
status = 1;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
}
|
40
L00(old)/src/GLSL.h
Normal file
40
L00(old)/src/GLSL.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef __GLSL__
|
||||
#define __GLSL__
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For printing out the current file and line number //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <sstream>
|
||||
|
||||
template <typename T>
|
||||
std::string NumberToString(T x)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
#define GET_FILE_LINE (std::string(__FILE__) + ":" + NumberToString(__LINE__)).c_str()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
void checkVersion();
|
||||
void checkError(const char *str = 0);
|
||||
void printProgramInfoLog(GLuint program);
|
||||
void printShaderInfoLog(GLuint shader);
|
||||
int textFileWrite(const char *filename, const char *s);
|
||||
char *textFileRead(const char *filename);
|
||||
}
|
||||
|
||||
#endif
|
114
L00(old)/src/MatrixStack.cpp
Normal file
114
L00(old)/src/MatrixStack.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
#include "MatrixStack.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
MatrixStack::MatrixStack()
|
||||
{
|
||||
mstack = make_shared< stack<glm::mat4> >();
|
||||
mstack->push(glm::mat4(1.0));
|
||||
}
|
||||
|
||||
MatrixStack::~MatrixStack()
|
||||
{
|
||||
}
|
||||
|
||||
void MatrixStack::pushMatrix()
|
||||
{
|
||||
const glm::mat4 &top = mstack->top();
|
||||
mstack->push(top);
|
||||
assert(mstack->size() < 100);
|
||||
}
|
||||
|
||||
void MatrixStack::popMatrix()
|
||||
{
|
||||
assert(!mstack->empty());
|
||||
mstack->pop();
|
||||
// There should always be one matrix left.
|
||||
assert(!mstack->empty());
|
||||
}
|
||||
|
||||
void MatrixStack::loadIdentity()
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top = glm::mat4(1.0);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(const glm::vec3 &t)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::translate(t);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(float x, float y, float z)
|
||||
{
|
||||
translate(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(const glm::vec3 &s)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::scale(s);
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float x, float y, float z)
|
||||
{
|
||||
scale(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float s)
|
||||
{
|
||||
scale(glm::vec3(s, s, s));
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, const glm::vec3 &axis)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::rotate(angle, axis);
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, float x, float y, float z)
|
||||
{
|
||||
rotate(angle, glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::multMatrix(const glm::mat4 &matrix)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= matrix;
|
||||
}
|
||||
|
||||
const glm::mat4 &MatrixStack::topMatrix() const
|
||||
{
|
||||
return mstack->top();
|
||||
}
|
||||
|
||||
void MatrixStack::print(const glm::mat4 &mat, const char *name)
|
||||
{
|
||||
if(name) {
|
||||
printf("%s = [\n", name);
|
||||
}
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
// mat[j] returns the jth column
|
||||
printf("%- 5.2f ", mat[j][i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if(name) {
|
||||
printf("];");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void MatrixStack::print(const char *name) const
|
||||
{
|
||||
print(mstack->top(), name);
|
||||
}
|
50
L00(old)/src/MatrixStack.h
Normal file
50
L00(old)/src/MatrixStack.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#ifndef _MatrixStack_H_
|
||||
#define _MatrixStack_H_
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <glm/fwd.hpp>
|
||||
|
||||
class MatrixStack
|
||||
{
|
||||
public:
|
||||
MatrixStack();
|
||||
virtual ~MatrixStack();
|
||||
|
||||
// glPushMatrix(): Copies the current matrix and adds it to the top of the stack
|
||||
void pushMatrix();
|
||||
// glPopMatrix(): Removes the top of the stack and sets the current matrix to be the matrix that is now on top
|
||||
void popMatrix();
|
||||
|
||||
// glLoadIdentity(): Sets the top matrix to be the identity
|
||||
void loadIdentity();
|
||||
// glMultMatrix(): Right multiplies the top matrix
|
||||
void multMatrix(const glm::mat4 &matrix);
|
||||
|
||||
// glTranslate(): Right multiplies the top matrix by a translation matrix
|
||||
void translate(const glm::vec3 &trans);
|
||||
void translate(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(const glm::vec3 &scale);
|
||||
void scale(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(float size);
|
||||
// glRotate(): Right multiplies the top matrix by a rotation matrix (angle in radians)
|
||||
void rotate(float angle, const glm::vec3 &axis);
|
||||
void rotate(float angle, float x, float y, float z);
|
||||
|
||||
// glGet(GL_MODELVIEW_MATRIX): Gets the top matrix
|
||||
const glm::mat4 &topMatrix() const;
|
||||
|
||||
// Prints out the specified matrix
|
||||
static void print(const glm::mat4 &mat, const char *name = 0);
|
||||
// Prints out the top matrix
|
||||
void print(const char *name = 0) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr< std::stack<glm::mat4> > mstack;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
126
L00(old)/src/Program.cpp
Normal file
126
L00(old)/src/Program.cpp
Normal file
|
@ -0,0 +1,126 @@
|
|||
#include "Program.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "GLSL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Program::Program() :
|
||||
vShaderName(""),
|
||||
fShaderName(""),
|
||||
pid(0),
|
||||
verbose(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Program::~Program()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Program::setShaderNames(const string &v, const string &f)
|
||||
{
|
||||
vShaderName = v;
|
||||
fShaderName = f;
|
||||
}
|
||||
|
||||
bool Program::init()
|
||||
{
|
||||
GLint rc;
|
||||
|
||||
// Create shader handles
|
||||
GLuint VS = glCreateShader(GL_VERTEX_SHADER);
|
||||
GLuint FS = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
// Read shader sources
|
||||
const char *vshader = GLSL::textFileRead(vShaderName.c_str());
|
||||
const char *fshader = GLSL::textFileRead(fShaderName.c_str());
|
||||
glShaderSource(VS, 1, &vshader, NULL);
|
||||
glShaderSource(FS, 1, &fshader, NULL);
|
||||
|
||||
// Compile vertex shader
|
||||
glCompileShader(VS);
|
||||
glGetShaderiv(VS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(VS);
|
||||
cout << "Error compiling vertex shader " << vShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compile fragment shader
|
||||
glCompileShader(FS);
|
||||
glGetShaderiv(FS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(FS);
|
||||
cout << "Error compiling fragment shader " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the program and link
|
||||
pid = glCreateProgram();
|
||||
glAttachShader(pid, VS);
|
||||
glAttachShader(pid, FS);
|
||||
glLinkProgram(pid);
|
||||
glGetProgramiv(pid, GL_LINK_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printProgramInfoLog(pid);
|
||||
cout << "Error linking shaders " << vShaderName << " and " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Program::bind()
|
||||
{
|
||||
glUseProgram(pid);
|
||||
}
|
||||
|
||||
void Program::unbind()
|
||||
{
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Program::addAttribute(const string &name)
|
||||
{
|
||||
attributes[name] = glGetAttribLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
void Program::addUniform(const string &name)
|
||||
{
|
||||
uniforms[name] = glGetUniformLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
GLint Program::getAttribute(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator attribute = attributes.find(name.c_str());
|
||||
if(attribute == attributes.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not an attribute variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return attribute->second;
|
||||
}
|
||||
|
||||
GLint Program::getUniform(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator uniform = uniforms.find(name.c_str());
|
||||
if(uniform == uniforms.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not a uniform variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return uniform->second;
|
||||
}
|
44
L00(old)/src/Program.h
Normal file
44
L00(old)/src/Program.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#ifndef __Program__
|
||||
#define __Program__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* An OpenGL Program (vertex and fragment shaders)
|
||||
*/
|
||||
class Program
|
||||
{
|
||||
public:
|
||||
Program();
|
||||
virtual ~Program();
|
||||
|
||||
void setVerbose(bool v) { verbose = v; }
|
||||
bool isVerbose() const { return verbose; }
|
||||
|
||||
void setShaderNames(const std::string &v, const std::string &f);
|
||||
virtual bool init();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
|
||||
void addAttribute(const std::string &name);
|
||||
void addUniform(const std::string &name);
|
||||
GLint getAttribute(const std::string &name) const;
|
||||
GLint getUniform(const std::string &name) const;
|
||||
|
||||
protected:
|
||||
std::string vShaderName;
|
||||
std::string fShaderName;
|
||||
|
||||
private:
|
||||
GLuint pid;
|
||||
std::map<std::string,GLint> attributes;
|
||||
std::map<std::string,GLint> uniforms;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
#endif
|
135
L00(old)/src/Shape.cpp
Normal file
135
L00(old)/src/Shape.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
#include "Shape.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "Program.h"
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Shape::Shape() :
|
||||
posBufID(0),
|
||||
norBufID(0),
|
||||
texBufID(0)
|
||||
{
|
||||
}
|
||||
|
||||
Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
void Shape::loadMesh(const string &meshName)
|
||||
{
|
||||
// Load geometry
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
string errStr;
|
||||
bool rc = tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, meshName.c_str());
|
||||
if(!rc) {
|
||||
cerr << errStr << endl;
|
||||
} else {
|
||||
// Some OBJ files have different indices for vertex positions, normals,
|
||||
// and texture coordinates. For example, a cube corner vertex may have
|
||||
// three different normals. Here, we are going to duplicate all such
|
||||
// vertices.
|
||||
// Loop over shapes
|
||||
for(size_t s = 0; s < shapes.size(); s++) {
|
||||
// Loop over faces (polygons)
|
||||
size_t index_offset = 0;
|
||||
for(size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) {
|
||||
size_t fv = shapes[s].mesh.num_face_vertices[f];
|
||||
// Loop over vertices in the face.
|
||||
for(size_t v = 0; v < fv; v++) {
|
||||
// access to vertex
|
||||
tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+0]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+1]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+2]);
|
||||
if(!attrib.normals.empty()) {
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+0]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+1]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+2]);
|
||||
}
|
||||
if(!attrib.texcoords.empty()) {
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+0]);
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+1]);
|
||||
}
|
||||
}
|
||||
index_offset += fv;
|
||||
// per-face material (IGNORE)
|
||||
shapes[s].mesh.material_ids[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shape::init()
|
||||
{
|
||||
// Send the position array to the GPU
|
||||
glGenBuffers(1, &posBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, posBuf.size()*sizeof(float), &posBuf[0], GL_STATIC_DRAW);
|
||||
|
||||
// Send the normal array to the GPU
|
||||
if(!norBuf.empty()) {
|
||||
glGenBuffers(1, &norBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, norBuf.size()*sizeof(float), &norBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Send the texture array to the GPU
|
||||
if(!texBuf.empty()) {
|
||||
glGenBuffers(1, &texBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, texBuf.size()*sizeof(float), &texBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Unbind the arrays
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
void Shape::draw(const shared_ptr<Program> prog) const
|
||||
{
|
||||
// Bind position buffer
|
||||
int h_pos = prog->getAttribute("vertPos");
|
||||
glEnableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glVertexAttribPointer(h_pos, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
|
||||
// Bind normal buffer
|
||||
int h_nor = prog->getAttribute("vertNor");
|
||||
if(h_nor != -1 && norBufID != 0) {
|
||||
glEnableVertexAttribArray(h_nor);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glVertexAttribPointer(h_nor, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Bind texcoords buffer
|
||||
int h_tex = prog->getAttribute("vertTex");
|
||||
if(h_tex != -1 && texBufID != 0) {
|
||||
glEnableVertexAttribArray(h_tex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glVertexAttribPointer(h_tex, 2, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Draw
|
||||
int count = posBuf.size()/3; // number of indices to be rendered
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
// Disable and unbind
|
||||
if(h_tex != -1) {
|
||||
glDisableVertexAttribArray(h_tex);
|
||||
}
|
||||
if(h_nor != -1) {
|
||||
glDisableVertexAttribArray(h_nor);
|
||||
}
|
||||
glDisableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
36
L00(old)/src/Shape.h
Normal file
36
L00(old)/src/Shape.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#ifndef _SHAPE_H_
|
||||
#define _SHAPE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class Program;
|
||||
|
||||
/**
|
||||
* A shape defined by a list of triangles
|
||||
* - posBuf should be of length 3*ntris
|
||||
* - norBuf should be of length 3*ntris (if normals are available)
|
||||
* - texBuf should be of length 2*ntris (if texture coords are available)
|
||||
* posBufID, norBufID, and texBufID are OpenGL buffer identifiers.
|
||||
*/
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
Shape();
|
||||
virtual ~Shape();
|
||||
void loadMesh(const std::string &meshName);
|
||||
void init();
|
||||
void draw(const std::shared_ptr<Program> prog) const;
|
||||
|
||||
private:
|
||||
std::vector<float> posBuf;
|
||||
std::vector<float> norBuf;
|
||||
std::vector<float> texBuf;
|
||||
unsigned posBufID;
|
||||
unsigned norBufID;
|
||||
unsigned texBufID;
|
||||
};
|
||||
|
||||
#endif
|
152
L00(old)/src/main.cpp
Normal file
152
L00(old)/src/main.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "MatrixStack.h"
|
||||
#include "Program.h"
|
||||
#include "Shape.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
GLFWwindow *window; // Main application window
|
||||
string RES_DIR = ""; // Where data files live
|
||||
shared_ptr<Program> prog;
|
||||
shared_ptr<Shape> shape;
|
||||
|
||||
static void error_callback(int error, const char *description)
|
||||
{
|
||||
cerr << description << endl;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
GLSL::checkVersion();
|
||||
|
||||
// Set background color.
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// Enable z-buffer test.
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Initialize mesh.
|
||||
shape = make_shared<Shape>();
|
||||
shape->loadMesh(RES_DIR + "teapot.obj");
|
||||
shape->init();
|
||||
|
||||
// Initialize the GLSL program.
|
||||
prog = make_shared<Program>();
|
||||
prog->setVerbose(false); // Set this to true when debugging.
|
||||
prog->setShaderNames(RES_DIR + "simple_vert.glsl", RES_DIR + "simple_frag.glsl");
|
||||
prog->init();
|
||||
prog->addUniform("P");
|
||||
prog->addUniform("MV");
|
||||
prog->addAttribute("vertPos");
|
||||
prog->addAttribute("vertNor");
|
||||
|
||||
// If there were any OpenGL errors, this will print something.
|
||||
// You can intersperse this line in your code to find the exact location
|
||||
// of your OpenGL error.
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
static void render()
|
||||
{
|
||||
// Get current frame buffer size.
|
||||
int width, height;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
float aspect = width/(float)height;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
// Clear framebuffer.
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Create matrix stacks.
|
||||
auto P = make_shared<MatrixStack>();
|
||||
auto MV = make_shared<MatrixStack>();
|
||||
// Apply projection.
|
||||
P->pushMatrix();
|
||||
P->multMatrix(glm::perspective((float)(45.0*M_PI/180.0), aspect, 0.01f, 100.0f));
|
||||
// Apply camera transform.
|
||||
MV->pushMatrix();
|
||||
MV->translate(glm::vec3(0, -0.5, -3));
|
||||
|
||||
// Draw mesh using GLSL.
|
||||
prog->bind();
|
||||
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, &P->topMatrix()[0][0]);
|
||||
glUniformMatrix4fv(prog->getUniform("MV"), 1, GL_FALSE, &MV->topMatrix()[0][0]);
|
||||
shape->draw(prog);
|
||||
prog->unbind();
|
||||
|
||||
// Pop matrix stacks.
|
||||
MV->popMatrix();
|
||||
P->popMatrix();
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 2) {
|
||||
cout << "Please specify the resource directory." << endl;
|
||||
return 0;
|
||||
}
|
||||
RES_DIR = argv[1] + string("/");
|
||||
|
||||
// Set error callback.
|
||||
glfwSetErrorCallback(error_callback);
|
||||
// Initialize the library.
|
||||
if(!glfwInit()) {
|
||||
return -1;
|
||||
}
|
||||
// Create a windowed mode window and its OpenGL context.
|
||||
window = glfwCreateWindow(640, 480, "YOUR NAME", NULL, NULL);
|
||||
if(!window) {
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
// Make the window's context current.
|
||||
glfwMakeContextCurrent(window);
|
||||
// Initialize GLEW.
|
||||
glewExperimental = true;
|
||||
if(glewInit() != GLEW_OK) {
|
||||
cerr << "Failed to initialize GLEW" << endl;
|
||||
return -1;
|
||||
}
|
||||
glGetError(); // A bug in glewInit() causes an error that we can safely ignore.
|
||||
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
|
||||
cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
|
||||
// Set vsync.
|
||||
glfwSwapInterval(1);
|
||||
// Set keyboard callback.
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
// Initialize scene.
|
||||
init();
|
||||
// Loop until the user closes the window.
|
||||
while(!glfwWindowShouldClose(window)) {
|
||||
// Render scene.
|
||||
render();
|
||||
// Swap front and back buffers.
|
||||
glfwSwapBuffers(window);
|
||||
// Poll for and process events.
|
||||
glfwPollEvents();
|
||||
}
|
||||
// Quit program.
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
1922
L00(old)/src/tiny_obj_loader.h
Normal file
1922
L00(old)/src/tiny_obj_loader.h
Normal file
File diff suppressed because it is too large
Load diff
BIN
L00.zip
Normal file
BIN
L00.zip
Normal file
Binary file not shown.
1
L00/.gitignore
vendored
Normal file
1
L00/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
118
L00/CMakeLists.txt
Normal file
118
L00/CMakeLists.txt
Normal file
|
@ -0,0 +1,118 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(L00)
|
||||
|
||||
# FOR LAB MACHINES ONLY!
|
||||
# DO NOT EDIT
|
||||
SET(DEF_DIR_GLM "C:\\c++\\glm")
|
||||
SET(DEF_DIR_GLFW "C:\\c++\\glfw-3.2.1")
|
||||
SET(DEF_DIR_GLEW "C:\\c++\\glew-2.0.0")
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them show up in IDEs.
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
FILE(GLOB_RECURSE GLSL "resources/*.glsl")
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS} ${GLSL})
|
||||
|
||||
# Get the GLM environment variable. Since GLM is a header-only library, we
|
||||
# just need to add it to the include directory.
|
||||
SET(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
|
||||
IF(NOT GLM_INCLUDE_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLM_INCLUDE_DIR to the root directory of your GLM installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLM in ${DEF_DIR_GLM}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLM})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLM_INCLUDE_DIR ${DEF_DIR_GLM})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLM_INCLUDE_DIR})
|
||||
|
||||
# Get the GLFW environment variable. There should be a CMakeLists.txt in the
|
||||
# specified directory.
|
||||
SET(GLFW_DIR "$ENV{GLFW_DIR}")
|
||||
IF(NOT GLFW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLFW_DIR to the root directory of your GLFW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLFW in ${DEF_DIR_GLFW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLFW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLFW_DIR ${DEF_DIR_GLFW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
OPTION(GLFW_BUILD_EXAMPLES "GLFW_BUILD_EXAMPLES" OFF)
|
||||
OPTION(GLFW_BUILD_TESTS "GLFW_BUILD_TESTS" OFF)
|
||||
OPTION(GLFW_BUILD_DOCS "GLFW_BUILD_DOCS" OFF)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES Release)
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/release)
|
||||
ELSE()
|
||||
ADD_SUBDIRECTORY(${GLFW_DIR} ${GLFW_DIR}/debug)
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLFW_DIR}/include)
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} glfw ${GLFW_LIBRARIES})
|
||||
|
||||
# Get the GLEW environment variable.
|
||||
SET(GLEW_DIR "$ENV{GLEW_DIR}")
|
||||
IF(NOT GLEW_DIR)
|
||||
# The environment variable was not set
|
||||
SET(ERR_MSG "Please point the environment variable GLEW_DIR to the root directory of your GLEW installation.")
|
||||
IF(WIN32)
|
||||
# On Windows, try the default location
|
||||
MESSAGE(STATUS "Looking for GLEW in ${DEF_DIR_GLEW}")
|
||||
IF(IS_DIRECTORY ${DEF_DIR_GLEW})
|
||||
MESSAGE(STATUS "Found!")
|
||||
SET(GLEW_DIR ${DEF_DIR_GLEW})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR ${ERR_MSG})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${GLEW_DIR}/include)
|
||||
IF(WIN32)
|
||||
# With prebuilt binaries
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/Release/Win32/glew32s.lib)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${GLEW_DIR}/lib/libGLEW.a)
|
||||
ENDIF()
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} opengl32.lib)
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
IF(APPLE)
|
||||
# Add required frameworks for GLFW.
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo")
|
||||
ELSE()
|
||||
#Link the Linux OpenGL library
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} "GL")
|
||||
ENDIF()
|
||||
ENDIF()
|
11
L00/resources/simple_frag.glsl
Normal file
11
L00/resources/simple_frag.glsl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#version 120
|
||||
|
||||
varying vec3 vNor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = normalize(vNor);
|
||||
// Map normal in the range [-1, 1] to color in range [0, 1];
|
||||
vec3 color = 0.5*normal + 0.5;
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
12
L00/resources/simple_vert.glsl
Normal file
12
L00/resources/simple_vert.glsl
Normal file
|
@ -0,0 +1,12 @@
|
|||
#version 120
|
||||
attribute vec4 aPos;
|
||||
attribute vec3 aNor;
|
||||
uniform mat4 P;
|
||||
uniform mat4 MV;
|
||||
varying vec3 vNor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * MV * aPos;
|
||||
vNor = (MV * vec4(aNor, 0.0)).xyz;
|
||||
}
|
5049
L00/resources/teapot.obj
Normal file
5049
L00/resources/teapot.obj
Normal file
File diff suppressed because it is too large
Load diff
152
L00/src/GLSL.cpp
Normal file
152
L00/src/GLSL.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#include "GLSL.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
const char * errorString(GLenum err)
|
||||
{
|
||||
switch(err) {
|
||||
case GL_NO_ERROR:
|
||||
return "No error";
|
||||
case GL_INVALID_ENUM:
|
||||
return "Invalid enum";
|
||||
case GL_INVALID_VALUE:
|
||||
return "Invalid value";
|
||||
case GL_INVALID_OPERATION:
|
||||
return "Invalid operation";
|
||||
case GL_STACK_OVERFLOW:
|
||||
return "Stack overflow";
|
||||
case GL_STACK_UNDERFLOW:
|
||||
return "Stack underflow";
|
||||
case GL_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
return "No error";
|
||||
}
|
||||
}
|
||||
|
||||
void checkVersion()
|
||||
{
|
||||
int major, minor;
|
||||
major = minor = 0;
|
||||
const char *verstr = (const char *)glGetString(GL_VERSION);
|
||||
|
||||
if((verstr == NULL) || (sscanf(verstr, "%d.%d", &major, &minor) != 2)) {
|
||||
printf("Invalid GL_VERSION format %d.%d\n", major, minor);
|
||||
}
|
||||
if(major < 2) {
|
||||
printf("This shader example will not work due to the installed Opengl version, which is %d.%d.\n", major, minor);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void checkError(const char *str)
|
||||
{
|
||||
GLenum glErr = glGetError();
|
||||
if(glErr != GL_NO_ERROR) {
|
||||
if(str) {
|
||||
printf("%s: ", str);
|
||||
}
|
||||
printf("GL_ERROR = %s.\n", errorString(glErr));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void printShaderInfoLog(GLuint shader)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetShaderInfoLog(shader, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Shader InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
void printProgramInfoLog(GLuint program)
|
||||
{
|
||||
GLint infologLength = 0;
|
||||
GLint charsWritten = 0;
|
||||
GLchar *infoLog = 0;
|
||||
|
||||
checkError(GET_FILE_LINE);
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infologLength);
|
||||
checkError(GET_FILE_LINE);
|
||||
|
||||
if(infologLength > 0) {
|
||||
infoLog = (GLchar *)malloc(infologLength);
|
||||
if(infoLog == NULL) {
|
||||
puts("ERROR: Could not allocate InfoLog buffer");
|
||||
exit(1);
|
||||
}
|
||||
glGetProgramInfoLog(program, infologLength, &charsWritten, infoLog);
|
||||
checkError(GET_FILE_LINE);
|
||||
printf("Program InfoLog:\n%s\n\n", infoLog);
|
||||
free(infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
char *textFileRead(const char *fn)
|
||||
{
|
||||
FILE *fp;
|
||||
char *content = NULL;
|
||||
int count = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"rt");
|
||||
if(fp != NULL) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
count = (int)ftell(fp);
|
||||
rewind(fp);
|
||||
if(count > 0) {
|
||||
content = (char *)malloc(sizeof(char) * (count+1));
|
||||
count = (int)fread(content,sizeof(char),count,fp);
|
||||
content[count] = '\0';
|
||||
}
|
||||
fclose(fp);
|
||||
} else {
|
||||
printf("error loading %s\n", fn);
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
int textFileWrite(const char *fn, const char *s)
|
||||
{
|
||||
FILE *fp;
|
||||
int status = 0;
|
||||
if(fn != NULL) {
|
||||
fp = fopen(fn,"w");
|
||||
if(fp != NULL) {
|
||||
if(fwrite(s,sizeof(char),strlen(s),fp) == strlen(s)) {
|
||||
status = 1;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
}
|
40
L00/src/GLSL.h
Normal file
40
L00/src/GLSL.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
|
||||
// Created by zwood on 2/21/10.
|
||||
// Modified by sueda 10/15/15.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef __GLSL__
|
||||
#define __GLSL__
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For printing out the current file and line number //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <sstream>
|
||||
|
||||
template <typename T>
|
||||
std::string NumberToString(T x)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
#define GET_FILE_LINE (std::string(__FILE__) + ":" + NumberToString(__LINE__)).c_str()
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace GLSL {
|
||||
|
||||
void checkVersion();
|
||||
void checkError(const char *str = 0);
|
||||
void printProgramInfoLog(GLuint program);
|
||||
void printShaderInfoLog(GLuint shader);
|
||||
int textFileWrite(const char *filename, const char *s);
|
||||
char *textFileRead(const char *filename);
|
||||
}
|
||||
|
||||
#endif
|
114
L00/src/MatrixStack.cpp
Normal file
114
L00/src/MatrixStack.cpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
#include "MatrixStack.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
MatrixStack::MatrixStack()
|
||||
{
|
||||
mstack = make_shared< stack<glm::mat4> >();
|
||||
mstack->push(glm::mat4(1.0));
|
||||
}
|
||||
|
||||
MatrixStack::~MatrixStack()
|
||||
{
|
||||
}
|
||||
|
||||
void MatrixStack::pushMatrix()
|
||||
{
|
||||
const glm::mat4 &top = mstack->top();
|
||||
mstack->push(top);
|
||||
assert(mstack->size() < 100);
|
||||
}
|
||||
|
||||
void MatrixStack::popMatrix()
|
||||
{
|
||||
assert(!mstack->empty());
|
||||
mstack->pop();
|
||||
// There should always be one matrix left.
|
||||
assert(!mstack->empty());
|
||||
}
|
||||
|
||||
void MatrixStack::loadIdentity()
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top = glm::mat4(1.0);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(const glm::vec3 &t)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::translate(t);
|
||||
}
|
||||
|
||||
void MatrixStack::translate(float x, float y, float z)
|
||||
{
|
||||
translate(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(const glm::vec3 &s)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::scale(s);
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float x, float y, float z)
|
||||
{
|
||||
scale(glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::scale(float s)
|
||||
{
|
||||
scale(glm::vec3(s, s, s));
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, const glm::vec3 &axis)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= glm::rotate(angle, axis);
|
||||
}
|
||||
|
||||
void MatrixStack::rotate(float angle, float x, float y, float z)
|
||||
{
|
||||
rotate(angle, glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
void MatrixStack::multMatrix(const glm::mat4 &matrix)
|
||||
{
|
||||
glm::mat4 &top = mstack->top();
|
||||
top *= matrix;
|
||||
}
|
||||
|
||||
const glm::mat4 &MatrixStack::topMatrix() const
|
||||
{
|
||||
return mstack->top();
|
||||
}
|
||||
|
||||
void MatrixStack::print(const glm::mat4 &mat, const char *name)
|
||||
{
|
||||
if(name) {
|
||||
printf("%s = [\n", name);
|
||||
}
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for(int j = 0; j < 4; ++j) {
|
||||
// mat[j] returns the jth column
|
||||
printf("%- 5.2f ", mat[j][i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if(name) {
|
||||
printf("];");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void MatrixStack::print(const char *name) const
|
||||
{
|
||||
print(mstack->top(), name);
|
||||
}
|
50
L00/src/MatrixStack.h
Normal file
50
L00/src/MatrixStack.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#ifndef _MatrixStack_H_
|
||||
#define _MatrixStack_H_
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <glm/fwd.hpp>
|
||||
|
||||
class MatrixStack
|
||||
{
|
||||
public:
|
||||
MatrixStack();
|
||||
virtual ~MatrixStack();
|
||||
|
||||
// glPushMatrix(): Copies the current matrix and adds it to the top of the stack
|
||||
void pushMatrix();
|
||||
// glPopMatrix(): Removes the top of the stack and sets the current matrix to be the matrix that is now on top
|
||||
void popMatrix();
|
||||
|
||||
// glLoadIdentity(): Sets the top matrix to be the identity
|
||||
void loadIdentity();
|
||||
// glMultMatrix(): Right multiplies the top matrix
|
||||
void multMatrix(const glm::mat4 &matrix);
|
||||
|
||||
// glTranslate(): Right multiplies the top matrix by a translation matrix
|
||||
void translate(const glm::vec3 &trans);
|
||||
void translate(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(const glm::vec3 &scale);
|
||||
void scale(float x, float y, float z);
|
||||
// glScale(): Right multiplies the top matrix by a scaling matrix
|
||||
void scale(float size);
|
||||
// glRotate(): Right multiplies the top matrix by a rotation matrix (angle in radians)
|
||||
void rotate(float angle, const glm::vec3 &axis);
|
||||
void rotate(float angle, float x, float y, float z);
|
||||
|
||||
// glGet(GL_MODELVIEW_MATRIX): Gets the top matrix
|
||||
const glm::mat4 &topMatrix() const;
|
||||
|
||||
// Prints out the specified matrix
|
||||
static void print(const glm::mat4 &mat, const char *name = 0);
|
||||
// Prints out the top matrix
|
||||
void print(const char *name = 0) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr< std::stack<glm::mat4> > mstack;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
126
L00/src/Program.cpp
Normal file
126
L00/src/Program.cpp
Normal file
|
@ -0,0 +1,126 @@
|
|||
#include "Program.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include "GLSL.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Program::Program() :
|
||||
vShaderName(""),
|
||||
fShaderName(""),
|
||||
pid(0),
|
||||
verbose(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Program::~Program()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Program::setShaderNames(const string &v, const string &f)
|
||||
{
|
||||
vShaderName = v;
|
||||
fShaderName = f;
|
||||
}
|
||||
|
||||
bool Program::init()
|
||||
{
|
||||
GLint rc;
|
||||
|
||||
// Create shader handles
|
||||
GLuint VS = glCreateShader(GL_VERTEX_SHADER);
|
||||
GLuint FS = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
// Read shader sources
|
||||
const char *vshader = GLSL::textFileRead(vShaderName.c_str());
|
||||
const char *fshader = GLSL::textFileRead(fShaderName.c_str());
|
||||
glShaderSource(VS, 1, &vshader, NULL);
|
||||
glShaderSource(FS, 1, &fshader, NULL);
|
||||
|
||||
// Compile vertex shader
|
||||
glCompileShader(VS);
|
||||
glGetShaderiv(VS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(VS);
|
||||
cout << "Error compiling vertex shader " << vShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compile fragment shader
|
||||
glCompileShader(FS);
|
||||
glGetShaderiv(FS, GL_COMPILE_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printShaderInfoLog(FS);
|
||||
cout << "Error compiling fragment shader " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the program and link
|
||||
pid = glCreateProgram();
|
||||
glAttachShader(pid, VS);
|
||||
glAttachShader(pid, FS);
|
||||
glLinkProgram(pid);
|
||||
glGetProgramiv(pid, GL_LINK_STATUS, &rc);
|
||||
if(!rc) {
|
||||
if(isVerbose()) {
|
||||
GLSL::printProgramInfoLog(pid);
|
||||
cout << "Error linking shaders " << vShaderName << " and " << fShaderName << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Program::bind()
|
||||
{
|
||||
glUseProgram(pid);
|
||||
}
|
||||
|
||||
void Program::unbind()
|
||||
{
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void Program::addAttribute(const string &name)
|
||||
{
|
||||
attributes[name] = glGetAttribLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
void Program::addUniform(const string &name)
|
||||
{
|
||||
uniforms[name] = glGetUniformLocation(pid, name.c_str());
|
||||
}
|
||||
|
||||
GLint Program::getAttribute(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator attribute = attributes.find(name.c_str());
|
||||
if(attribute == attributes.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not an attribute variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return attribute->second;
|
||||
}
|
||||
|
||||
GLint Program::getUniform(const string &name) const
|
||||
{
|
||||
map<string,GLint>::const_iterator uniform = uniforms.find(name.c_str());
|
||||
if(uniform == uniforms.end()) {
|
||||
if(isVerbose()) {
|
||||
cout << name << " is not a uniform variable" << endl;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return uniform->second;
|
||||
}
|
44
L00/src/Program.h
Normal file
44
L00/src/Program.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#ifndef __Program__
|
||||
#define __Program__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* An OpenGL Program (vertex and fragment shaders)
|
||||
*/
|
||||
class Program
|
||||
{
|
||||
public:
|
||||
Program();
|
||||
virtual ~Program();
|
||||
|
||||
void setVerbose(bool v) { verbose = v; }
|
||||
bool isVerbose() const { return verbose; }
|
||||
|
||||
void setShaderNames(const std::string &v, const std::string &f);
|
||||
virtual bool init();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
|
||||
void addAttribute(const std::string &name);
|
||||
void addUniform(const std::string &name);
|
||||
GLint getAttribute(const std::string &name) const;
|
||||
GLint getUniform(const std::string &name) const;
|
||||
|
||||
protected:
|
||||
std::string vShaderName;
|
||||
std::string fShaderName;
|
||||
|
||||
private:
|
||||
GLuint pid;
|
||||
std::map<std::string,GLint> attributes;
|
||||
std::map<std::string,GLint> uniforms;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
#endif
|
135
L00/src/Shape.cpp
Normal file
135
L00/src/Shape.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
#include "Shape.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "Program.h"
|
||||
|
||||
#define TINYOBJLOADER_IMPLEMENTATION
|
||||
#include "tiny_obj_loader.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Shape::Shape() :
|
||||
posBufID(0),
|
||||
norBufID(0),
|
||||
texBufID(0)
|
||||
{
|
||||
}
|
||||
|
||||
Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
void Shape::loadMesh(const string &meshName)
|
||||
{
|
||||
// Load geometry
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
string errStr;
|
||||
bool rc = tinyobj::LoadObj(&attrib, &shapes, &materials, &errStr, meshName.c_str());
|
||||
if(!rc) {
|
||||
cerr << errStr << endl;
|
||||
} else {
|
||||
// Some OBJ files have different indices for vertex positions, normals,
|
||||
// and texture coordinates. For example, a cube corner vertex may have
|
||||
// three different normals. Here, we are going to duplicate all such
|
||||
// vertices.
|
||||
// Loop over shapes
|
||||
for(size_t s = 0; s < shapes.size(); s++) {
|
||||
// Loop over faces (polygons)
|
||||
size_t index_offset = 0;
|
||||
for(size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) {
|
||||
size_t fv = shapes[s].mesh.num_face_vertices[f];
|
||||
// Loop over vertices in the face.
|
||||
for(size_t v = 0; v < fv; v++) {
|
||||
// access to vertex
|
||||
tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+0]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+1]);
|
||||
posBuf.push_back(attrib.vertices[3*idx.vertex_index+2]);
|
||||
if(!attrib.normals.empty()) {
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+0]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+1]);
|
||||
norBuf.push_back(attrib.normals[3*idx.normal_index+2]);
|
||||
}
|
||||
if(!attrib.texcoords.empty()) {
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+0]);
|
||||
texBuf.push_back(attrib.texcoords[2*idx.texcoord_index+1]);
|
||||
}
|
||||
}
|
||||
index_offset += fv;
|
||||
// per-face material (IGNORE)
|
||||
shapes[s].mesh.material_ids[f];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shape::init()
|
||||
{
|
||||
// Send the position array to the GPU
|
||||
glGenBuffers(1, &posBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, posBuf.size()*sizeof(float), &posBuf[0], GL_STATIC_DRAW);
|
||||
|
||||
// Send the normal array to the GPU
|
||||
if(!norBuf.empty()) {
|
||||
glGenBuffers(1, &norBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, norBuf.size()*sizeof(float), &norBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Send the texture array to the GPU
|
||||
if(!texBuf.empty()) {
|
||||
glGenBuffers(1, &texBufID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glBufferData(GL_ARRAY_BUFFER, texBuf.size()*sizeof(float), &texBuf[0], GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
// Unbind the arrays
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
void Shape::draw(const shared_ptr<Program> prog) const
|
||||
{
|
||||
// Bind position buffer
|
||||
int h_pos = prog->getAttribute("aPos");
|
||||
glEnableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, posBufID);
|
||||
glVertexAttribPointer(h_pos, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
|
||||
// Bind normal buffer
|
||||
int h_nor = prog->getAttribute("aNor");
|
||||
if(h_nor != -1 && norBufID != 0) {
|
||||
glEnableVertexAttribArray(h_nor);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, norBufID);
|
||||
glVertexAttribPointer(h_nor, 3, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Bind texcoords buffer
|
||||
int h_tex = prog->getAttribute("aTex");
|
||||
if(h_tex != -1 && texBufID != 0) {
|
||||
glEnableVertexAttribArray(h_tex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, texBufID);
|
||||
glVertexAttribPointer(h_tex, 2, GL_FLOAT, GL_FALSE, 0, (const void *)0);
|
||||
}
|
||||
|
||||
// Draw
|
||||
int count = posBuf.size()/3; // number of indices to be rendered
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
// Disable and unbind
|
||||
if(h_tex != -1) {
|
||||
glDisableVertexAttribArray(h_tex);
|
||||
}
|
||||
if(h_nor != -1) {
|
||||
glDisableVertexAttribArray(h_nor);
|
||||
}
|
||||
glDisableVertexAttribArray(h_pos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
36
L00/src/Shape.h
Normal file
36
L00/src/Shape.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#ifndef _SHAPE_H_
|
||||
#define _SHAPE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class Program;
|
||||
|
||||
/**
|
||||
* A shape defined by a list of triangles
|
||||
* - posBuf should be of length 3*ntris
|
||||
* - norBuf should be of length 3*ntris (if normals are available)
|
||||
* - texBuf should be of length 2*ntris (if texture coords are available)
|
||||
* posBufID, norBufID, and texBufID are OpenGL buffer identifiers.
|
||||
*/
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
Shape();
|
||||
virtual ~Shape();
|
||||
void loadMesh(const std::string &meshName);
|
||||
void init();
|
||||
void draw(const std::shared_ptr<Program> prog) const;
|
||||
|
||||
private:
|
||||
std::vector<float> posBuf;
|
||||
std::vector<float> norBuf;
|
||||
std::vector<float> texBuf;
|
||||
unsigned posBufID;
|
||||
unsigned norBufID;
|
||||
unsigned texBufID;
|
||||
};
|
||||
|
||||
#endif
|
152
L00/src/main.cpp
Normal file
152
L00/src/main.cpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "GLSL.h"
|
||||
#include "MatrixStack.h"
|
||||
#include "Program.h"
|
||||
#include "Shape.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
GLFWwindow *window; // Main application window
|
||||
string RES_DIR = ""; // Where data files live
|
||||
shared_ptr<Program> prog;
|
||||
shared_ptr<Shape> shape;
|
||||
|
||||
static void error_callback(int error, const char *description)
|
||||
{
|
||||
cerr << description << endl;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
GLSL::checkVersion();
|
||||
|
||||
// Set background color.
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// Enable z-buffer test.
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Initialize mesh.
|
||||
shape = make_shared<Shape>();
|
||||
shape->loadMesh(RES_DIR + "teapot.obj");
|
||||
shape->init();
|
||||
|
||||
// Initialize the GLSL program.
|
||||
prog = make_shared<Program>();
|
||||
prog->setVerbose(false); // Set this to true when debugging.
|
||||
prog->setShaderNames(RES_DIR + "simple_vert.glsl", RES_DIR + "simple_frag.glsl");
|
||||
prog->init();
|
||||
prog->addUniform("P");
|
||||
prog->addUniform("MV");
|
||||
prog->addAttribute("aPos");
|
||||
prog->addAttribute("aNor");
|
||||
|
||||
// If there were any OpenGL errors, this will print something.
|
||||
// You can intersperse this line in your code to find the exact location
|
||||
// of your OpenGL error.
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
static void render()
|
||||
{
|
||||
// Get current frame buffer size.
|
||||
int width, height;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
float aspect = width/(float)height;
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
// Clear framebuffer.
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Create matrix stacks.
|
||||
auto P = make_shared<MatrixStack>();
|
||||
auto MV = make_shared<MatrixStack>();
|
||||
// Apply projection.
|
||||
P->pushMatrix();
|
||||
P->multMatrix(glm::perspective((float)(45.0*M_PI/180.0), aspect, 0.01f, 100.0f));
|
||||
// Apply camera transform.
|
||||
MV->pushMatrix();
|
||||
MV->translate(glm::vec3(0, -0.5, -3));
|
||||
|
||||
// Draw mesh using GLSL.
|
||||
prog->bind();
|
||||
glUniformMatrix4fv(prog->getUniform("P"), 1, GL_FALSE, &P->topMatrix()[0][0]);
|
||||
glUniformMatrix4fv(prog->getUniform("MV"), 1, GL_FALSE, &MV->topMatrix()[0][0]);
|
||||
shape->draw(prog);
|
||||
prog->unbind();
|
||||
|
||||
// Pop matrix stacks.
|
||||
MV->popMatrix();
|
||||
P->popMatrix();
|
||||
|
||||
GLSL::checkError(GET_FILE_LINE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 2) {
|
||||
cout << "Please specify the resource directory." << endl;
|
||||
return 0;
|
||||
}
|
||||
RES_DIR = argv[1] + string("/");
|
||||
|
||||
// Set error callback.
|
||||
glfwSetErrorCallback(error_callback);
|
||||
// Initialize the library.
|
||||
if(!glfwInit()) {
|
||||
return -1;
|
||||
}
|
||||
// Create a windowed mode window and its OpenGL context.
|
||||
window = glfwCreateWindow(640, 480, "YOUR NAME", NULL, NULL);
|
||||
if(!window) {
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
// Make the window's context current.
|
||||
glfwMakeContextCurrent(window);
|
||||
// Initialize GLEW.
|
||||
glewExperimental = true;
|
||||
if(glewInit() != GLEW_OK) {
|
||||
cerr << "Failed to initialize GLEW" << endl;
|
||||
return -1;
|
||||
}
|
||||
glGetError(); // A bug in glewInit() causes an error that we can safely ignore.
|
||||
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
|
||||
cout << "GLSL version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
|
||||
// Set vsync.
|
||||
glfwSwapInterval(1);
|
||||
// Set keyboard callback.
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
// Initialize scene.
|
||||
init();
|
||||
// Loop until the user closes the window.
|
||||
while(!glfwWindowShouldClose(window)) {
|
||||
// Render scene.
|
||||
render();
|
||||
// Swap front and back buffers.
|
||||
glfwSwapBuffers(window);
|
||||
// Poll for and process events.
|
||||
glfwPollEvents();
|
||||
}
|
||||
// Quit program.
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
1922
L00/src/tiny_obj_loader.h
Normal file
1922
L00/src/tiny_obj_loader.h
Normal file
File diff suppressed because it is too large
Load diff
BIN
L01.zip
Normal file
BIN
L01.zip
Normal file
Binary file not shown.
1
L01/.gitignore
vendored
Normal file
1
L01/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
34
L01/CMakeLists.txt
Normal file
34
L01/CMakeLists.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# Name of the project
|
||||
PROJECT(L01)
|
||||
|
||||
# Is this the solution?
|
||||
# Override with `cmake -DSOL=ON ..`
|
||||
OPTION(SOL "Solution" OFF)
|
||||
|
||||
# Use glob to get the list of all source files.
|
||||
# We don't really need to include header and resource files to build, but it's
|
||||
# nice to have them also show up in IDEs.
|
||||
IF(${SOL})
|
||||
FILE(GLOB_RECURSE SOURCES "src0/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src0/*.h")
|
||||
ELSE()
|
||||
FILE(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADERS "src/*.h")
|
||||
ENDIF()
|
||||
|
||||
# Set the executable.
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
|
||||
# OS specific options and libraries
|
||||
IF(WIN32)
|
||||
# c++11 is enabled by default.
|
||||
# -Wall produces way too many warnings.
|
||||
# -pedantic is not supported.
|
||||
# Disable warning 4996.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
|
||||
ELSE()
|
||||
# Enable all pedantic warnings.
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
|
||||
ENDIF()
|
87
L01/src/Image.cpp
Normal file
87
L01/src/Image.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include "Image.h"
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Tri::Tri()
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = 0.0;
|
||||
v1.y = 0.0;
|
||||
v1.z = 0.0;
|
||||
vertex v2;
|
||||
v2.x = 0.0;
|
||||
v2.y = 0.0;
|
||||
v2.z = 0.0;
|
||||
vertex v3;
|
||||
v3.x = 0.0;
|
||||
v3.y = 0.0;
|
||||
v3.z = 0.0;
|
||||
v.push_back(v1);
|
||||
v.push_back(v2);
|
||||
v.push_back(v3);
|
||||
}
|
||||
|
||||
Tri::Tri(vertex &one, vertex &two, vertex &three)
|
||||
{
|
||||
v.push_back(one);
|
||||
v.push_back(two);
|
||||
v.push_back(three);
|
||||
}
|
||||
|
||||
Image::Image(int w, int h) :
|
||||
width(w),
|
||||
height(h),
|
||||
comp(3),
|
||||
pixels(width*height*comp, 0)
|
||||
{
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
void Image::setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
// The pixel data is laid out row by row. Each row consists of 'width'
|
||||
// columns, and each column consists of 3 unsigned chars.
|
||||
|
||||
// First check for bounds
|
||||
if(y < 0 || y >= height) {
|
||||
cout << "Row " << y << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
if(x < 0 || x >= width) {
|
||||
cout << "Col " << x << " is out of bounds" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Since the origin (0, 0) of the image is the upper left corner, we need
|
||||
// to flip the row to make the origin be the lower left corner.
|
||||
y = height - y - 1;
|
||||
// index corresponding to row and col, (assuming single component image)
|
||||
int index = y*width + x;
|
||||
// Multiply by 3 to get the index for the rgb components.
|
||||
assert(index >= 0);
|
||||
assert(3*index + 2 < (int)pixels.size());
|
||||
pixels[3*index + 0] = r;
|
||||
pixels[3*index + 1] = g;
|
||||
pixels[3*index + 2] = b;
|
||||
}
|
||||
|
||||
void Image::writeToFile(const string &filename)
|
||||
{
|
||||
// The distance in bytes from the first byte of a row of pixels to the
|
||||
// first byte of the next row of pixels
|
||||
int stride_in_bytes = width*comp*sizeof(unsigned char);
|
||||
int rc = stbi_write_png(filename.c_str(), width, height, comp, &pixels[0], stride_in_bytes);
|
||||
if(rc) {
|
||||
cout << "Wrote to " << filename << endl;
|
||||
} else {
|
||||
cout << "Couldn't write to " << filename << endl;
|
||||
}
|
||||
}
|
40
L01/src/Image.h
Normal file
40
L01/src/Image.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
#ifndef _IMAGE_H_
|
||||
#define _IMAGE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct vertex
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
float z = 0.0;
|
||||
};
|
||||
|
||||
class Tri
|
||||
{
|
||||
public:
|
||||
Tri();
|
||||
Tri(vertex &one, vertex &two, vertex &three);
|
||||
std::vector<vertex> v;
|
||||
};
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
Image(int width, int height);
|
||||
virtual ~Image();
|
||||
void setPixel(int x, int y, unsigned char r, unsigned char g, unsigned char b);
|
||||
void writeToFile(const std::string &filename);
|
||||
int getWidth() const { return width; }
|
||||
int getHeight() const { return height; }
|
||||
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
int comp;
|
||||
std::vector<unsigned char> pixels;
|
||||
};
|
||||
|
||||
#endif
|
87
L01/src/main.cpp
Normal file
87
L01/src/main.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "Image.h"
|
||||
|
||||
// This allows you to skip the `std::` in front of C++ standard library
|
||||
// functions. You can also say `using std::cout` to be more selective.
|
||||
// You should never do this in a header file.
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc < 10) {
|
||||
cout << "Usage: L01 filename width height x1 y1 x2 y2 x3 y3" << endl;
|
||||
return 0;
|
||||
}
|
||||
// Output filename
|
||||
string filename(argv[1]);
|
||||
// Width of image
|
||||
int width = atoi(argv[2]);
|
||||
// Height of image
|
||||
int height = atoi(argv[3]);
|
||||
|
||||
// Initialize coordinate variables to make things easier
|
||||
float x1 = atoi(argv[4]);
|
||||
float y1 = atoi(argv[5]);
|
||||
float x2 = atoi(argv[6]);
|
||||
float y2 = atoi(argv[7]);
|
||||
float x3 = atoi(argv[8]);
|
||||
float y3 = atoi(argv[9]);
|
||||
|
||||
// Vertex 1
|
||||
vertex v1;
|
||||
v1.x = x1;
|
||||
v1.y = y1;
|
||||
v1.z = 0.0;
|
||||
// Vertex 2
|
||||
vertex v2;
|
||||
v2.x = x2;
|
||||
v2.y = y2;
|
||||
v2.z = 0.0;
|
||||
// Vertex 3
|
||||
vertex v3;
|
||||
v3.x = x3;
|
||||
v3.y = y3;
|
||||
v3.z = 0.0;
|
||||
// Triangle
|
||||
Tri t(v1, v2, v3);
|
||||
|
||||
// Find xmin, xmax, ymin, ymax
|
||||
float xmin = x1;
|
||||
float xmax = x1;
|
||||
float ymin = y1;
|
||||
float ymax = y1;
|
||||
if(x2 < xmin)
|
||||
xmin = x2;
|
||||
if(x3 < xmin)
|
||||
xmin = x3;
|
||||
if(x2 > xmax)
|
||||
xmax = x2;
|
||||
if(x3 > xmax)
|
||||
xmax = x3;
|
||||
if(y2 < ymin)
|
||||
ymin = y2;
|
||||
if(y3 < ymin)
|
||||
ymin = y3;
|
||||
if(y2 > ymax)
|
||||
ymax = y2;
|
||||
if(y3 > ymax)
|
||||
ymax = y3;
|
||||
|
||||
// Create the image. We're using a `shared_ptr`, a C++11 feature.
|
||||
auto image = make_shared<Image>(width, height);
|
||||
// Draw a rectangle
|
||||
for(int y = ymin; y < ymax; ++y) {
|
||||
for(int x = xmin; x < xmax; ++x) {
|
||||
unsigned char r = 255;
|
||||
unsigned char g = 0;
|
||||
unsigned char b = 0;
|
||||
image->setPixel(x, y, r, g, b);
|
||||
}
|
||||
}
|
||||
// Write image to file
|
||||
image->writeToFile(filename);
|
||||
return 0;
|
||||
}
|
1048
L01/src/stb_image_write.h
Normal file
1048
L01/src/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load diff
33
L01/src/triangle.cpp
Normal file
33
L01/src/triangle.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "triangle.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Tri::Tri()
|
||||
{
|
||||
vertex v1;
|
||||
v1.x = 0.0;
|
||||
v1.y = 0.0;
|
||||
v1.z = 0.0;
|
||||
vertex v2;
|
||||
v2.x = 0.0;
|
||||
v2.y = 0.0;
|
||||
v2.z = 0.0;
|
||||
vertex v3;
|
||||
v3.x = 0.0;
|
||||
v3.y = 0.0;
|
||||
v3.z = 0.0;
|
||||
v.push_back(v1);
|
||||
v.push_back(v2);
|
||||
v.push_back(v3);
|
||||
}
|
||||
|
||||
Tri::Tri(vertex &one, vertex &two, vertex &three) :
|
||||
v.push_back(one),
|
||||
v.push_back(two),
|
||||
v.push_back(three)
|
||||
{
|
||||
}
|
23
L01/src/triangle.h
Normal file
23
L01/src/triangle.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#ifndef _TRIANGLE_H_
|
||||
#define _TRIANGLE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct vertex
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
float z = 0.0;
|
||||
};
|
||||
|
||||
class Tri
|
||||
{
|
||||
public:
|
||||
Tri();
|
||||
Tri(vertex &one, vertex &two, vertex &three);
|
||||
std::vector<vertex> v;
|
||||
};
|
||||
|
||||
#endif
|
1
L02/.gitignore
vendored
Normal file
1
L02/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
68
L02/CMakeFiles/3.7.2/CMakeCCompiler.cmake
Normal file
68
L02/CMakeFiles/3.7.2/CMakeCCompiler.cmake
Normal file
|
@ -0,0 +1,68 @@
|
|||
set(CMAKE_C_COMPILER "/usr/lib/hardening-wrapper/bin/cc")
|
||||
set(CMAKE_C_COMPILER_ARG1 "")
|
||||
set(CMAKE_C_COMPILER_ID "GNU")
|
||||
set(CMAKE_C_COMPILER_VERSION "6.3.1")
|
||||
set(CMAKE_C_COMPILER_WRAPPER "")
|
||||
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11")
|
||||
set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert")
|
||||
set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes")
|
||||
set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros")
|
||||
set(CMAKE_C11_COMPILE_FEATURES "c_static_assert")
|
||||
|
||||
set(CMAKE_C_PLATFORM_ID "Linux")
|
||||
set(CMAKE_C_SIMULATE_ID "")
|
||||
set(CMAKE_C_SIMULATE_VERSION "")
|
||||
|
||||
set(CMAKE_AR "/usr/bin/ar")
|
||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
||||
set(CMAKE_LINKER "/usr/lib/hardening-wrapper/bin/ld")
|
||||
set(CMAKE_COMPILER_IS_GNUCC 1)
|
||||
set(CMAKE_C_COMPILER_LOADED 1)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_C_ABI_COMPILED TRUE)
|
||||
set(CMAKE_COMPILER_IS_MINGW )
|
||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
||||
set(CYGWIN 1)
|
||||
set(UNIX 1)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER_ENV_VAR "CC")
|
||||
|
||||
if(CMAKE_COMPILER_IS_MINGW)
|
||||
set(MINGW 1)
|
||||
endif()
|
||||
set(CMAKE_C_COMPILER_ID_RUN 1)
|
||||
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
|
||||
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
set(CMAKE_C_LINKER_PREFERENCE 10)
|
||||
|
||||
# Save compiler ABI information.
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR "8")
|
||||
set(CMAKE_C_COMPILER_ABI "ELF")
|
||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "")
|
||||
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ABI)
|
||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_LIBRARY_ARCHITECTURE)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
|
||||
if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c")
|
||||
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/hardening-wrapper/bin;/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1;/usr/lib;/lib")
|
||||
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
69
L02/CMakeFiles/3.7.2/CMakeCXXCompiler.cmake
Normal file
69
L02/CMakeFiles/3.7.2/CMakeCXXCompiler.cmake
Normal file
|
@ -0,0 +1,69 @@
|
|||
set(CMAKE_CXX_COMPILER "/usr/lib/hardening-wrapper/bin/c++")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "")
|
||||
set(CMAKE_CXX_COMPILER_ID "GNU")
|
||||
set(CMAKE_CXX_COMPILER_VERSION "6.3.1")
|
||||
set(CMAKE_CXX_COMPILER_WRAPPER "")
|
||||
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
|
||||
set(CMAKE_CXX_COMPILE_FEATURES "cxx_template_template_parameters;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES "cxx_template_template_parameters")
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES "cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES "cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
|
||||
|
||||
set(CMAKE_CXX_PLATFORM_ID "Linux")
|
||||
set(CMAKE_CXX_SIMULATE_ID "")
|
||||
set(CMAKE_CXX_SIMULATE_VERSION "")
|
||||
|
||||
set(CMAKE_AR "/usr/bin/ar")
|
||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
||||
set(CMAKE_LINKER "/usr/lib/hardening-wrapper/bin/ld")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
set(CMAKE_CXX_COMPILER_LOADED 1)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_CXX_ABI_COMPILED TRUE)
|
||||
set(CMAKE_COMPILER_IS_MINGW )
|
||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
||||
set(CYGWIN 1)
|
||||
set(UNIX 1)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
|
||||
|
||||
if(CMAKE_COMPILER_IS_MINGW)
|
||||
set(MINGW 1)
|
||||
endif()
|
||||
set(CMAKE_CXX_COMPILER_ID_RUN 1)
|
||||
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE 30)
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
|
||||
|
||||
# Save compiler ABI information.
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
|
||||
set(CMAKE_CXX_COMPILER_ABI "ELF")
|
||||
set(CMAKE_CXX_LIBRARY_ARCHITECTURE "")
|
||||
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ABI)
|
||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
|
||||
if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/hardening-wrapper/bin;/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1;/usr/lib;/lib")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
BIN
L02/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_C.bin
Executable file
BIN
L02/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_C.bin
Executable file
Binary file not shown.
BIN
L02/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_CXX.bin
Executable file
BIN
L02/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_CXX.bin
Executable file
Binary file not shown.
15
L02/CMakeFiles/3.7.2/CMakeSystem.cmake
Normal file
15
L02/CMakeFiles/3.7.2/CMakeSystem.cmake
Normal file
|
@ -0,0 +1,15 @@
|
|||
set(CMAKE_HOST_SYSTEM "Linux-4.8.13-1-ARCH")
|
||||
set(CMAKE_HOST_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_HOST_SYSTEM_VERSION "4.8.13-1-ARCH")
|
||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
|
||||
|
||||
|
||||
|
||||
set(CMAKE_SYSTEM "Linux-4.8.13-1-ARCH")
|
||||
set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_VERSION "4.8.13-1-ARCH")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
||||
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
|
||||
set(CMAKE_SYSTEM_LOADED 1)
|
561
L02/CMakeFiles/3.7.2/CompilerIdC/CMakeCCompilerId.c
Normal file
561
L02/CMakeFiles/3.7.2/CompilerIdC/CMakeCCompilerId.c
Normal file
|
@ -0,0 +1,561 @@
|
|||
#ifdef __cplusplus
|
||||
# error "A C++ compiler has been selected for C."
|
||||
#endif
|
||||
|
||||
#if defined(__18CXX)
|
||||
# define ID_VOID_MAIN
|
||||
#endif
|
||||
#if defined(__CLASSIC_C__)
|
||||
/* cv-qualifiers did not exist in K&R C */
|
||||
# define const
|
||||
# define volatile
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number components: V=Version, R=Revision, P=Patch
|
||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
/* __INTEL_COMPILER = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
||||
# if defined(__INTEL_COMPILER_UPDATE)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
||||
# else
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
||||
# endif
|
||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
||||
# endif
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__PATHCC__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
||||
# if defined(__PATHCC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||
# define COMPILER_ID "Embarcadero"
|
||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
/* __BORLANDC__ = 0xVRR */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
||||
|
||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
||||
# define COMPILER_ID "Watcom"
|
||||
/* __WATCOMC__ = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "OpenWatcom"
|
||||
/* __WATCOMC__ = VVRP + 1100 */
|
||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SUNPRO_C)
|
||||
# define COMPILER_ID "SunPro"
|
||||
# if __SUNPRO_C >= 0x5100
|
||||
/* __SUNPRO_C = 0xVRRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
||||
# else
|
||||
/* __SUNPRO_CC = 0xVRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
||||
# endif
|
||||
|
||||
#elif defined(__HP_cc)
|
||||
# define COMPILER_ID "HP"
|
||||
/* __HP_cc = VVRRPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
|
||||
|
||||
#elif defined(__DECC)
|
||||
# define COMPILER_ID "Compaq"
|
||||
/* __DECC_VER = VVRRTPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
|
||||
|
||||
#elif defined(__IBMC__) && defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
|
||||
# define COMPILER_ID "VisualAge"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
||||
# if defined(__PGIC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_CRAYC)
|
||||
# define COMPILER_ID "Cray"
|
||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# define COMPILER_ID "TI"
|
||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
||||
|
||||
#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
|
||||
# define COMPILER_ID "Fujitsu"
|
||||
|
||||
#elif defined(__TINYC__)
|
||||
# define COMPILER_ID "TinyCC"
|
||||
|
||||
#elif defined(__BCC__)
|
||||
# define COMPILER_ID "Bruce"
|
||||
|
||||
#elif defined(__SCO_VERSION__)
|
||||
# define COMPILER_ID "SCO"
|
||||
|
||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
||||
# define COMPILER_ID "AppleClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
||||
|
||||
#elif defined(__clang__)
|
||||
# define COMPILER_ID "Clang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_ID "GNU"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
/* _MSC_VER = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# if defined(_MSC_FULL_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
||||
# else
|
||||
/* _MSC_FULL_VER = VVRRPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_MSC_BUILD)
|
||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
||||
# endif
|
||||
|
||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
# define COMPILER_ID "ADSP"
|
||||
#if defined(__VISUALDSPVERSION__)
|
||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
||||
#endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
|
||||
# define COMPILER_ID "IAR"
|
||||
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
# define COMPILER_ID "ARMCC"
|
||||
#if __ARMCC_VERSION >= 1000000
|
||||
/* __ARMCC_VERSION = VRRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#else
|
||||
/* __ARMCC_VERSION = VRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(SDCC)
|
||||
# define COMPILER_ID "SDCC"
|
||||
/* SDCC = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(SDCC % 10)
|
||||
|
||||
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
# if defined(_SGI_COMPILER_VERSION)
|
||||
/* _SGI_COMPILER_VERSION = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
|
||||
# else
|
||||
/* _COMPILER_VERSION = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
|
||||
# endif
|
||||
|
||||
|
||||
/* These compilers are either not known or too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__sgi)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
#ifdef SIMULATE_ID
|
||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
#endif
|
||||
|
||||
#ifdef __QNXNTO__
|
||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_HELPER(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
|
||||
# define PLATFORM_ID "IRIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__LINUX__)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
# elif defined(__DOS__)
|
||||
# define PLATFORM_ID "DOS"
|
||||
|
||||
# elif defined(__OS2__)
|
||||
# define PLATFORM_ID "OS2"
|
||||
|
||||
# elif defined(__WINDOWS__)
|
||||
# define PLATFORM_ID "Windows3x"
|
||||
|
||||
# else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
# endif
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# elif defined(_M_ARM)
|
||||
# if _M_ARM == 4
|
||||
# define ARCHITECTURE_ID "ARMV4I"
|
||||
# elif _M_ARM == 5
|
||||
# define ARCHITECTURE_ID "ARMV5I"
|
||||
# else
|
||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
||||
# endif
|
||||
|
||||
# elif defined(_M_MIPS)
|
||||
# define ARCHITECTURE_ID "MIPS"
|
||||
|
||||
# elif defined(_M_SH)
|
||||
# define ARCHITECTURE_ID "SHx"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(_M_I86)
|
||||
# define ARCHITECTURE_ID "I86"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID
|
||||
#endif
|
||||
|
||||
/* Convert integer to decimal digit literals. */
|
||||
#define DEC(n) \
|
||||
('0' + (((n) / 10000000)%10)), \
|
||||
('0' + (((n) / 1000000)%10)), \
|
||||
('0' + (((n) / 100000)%10)), \
|
||||
('0' + (((n) / 10000)%10)), \
|
||||
('0' + (((n) / 1000)%10)), \
|
||||
('0' + (((n) / 100)%10)), \
|
||||
('0' + (((n) / 10)%10)), \
|
||||
('0' + ((n) % 10))
|
||||
|
||||
/* Convert integer to hex digit literals. */
|
||||
#define HEX(n) \
|
||||
('0' + ((n)>>28 & 0xF)), \
|
||||
('0' + ((n)>>24 & 0xF)), \
|
||||
('0' + ((n)>>20 & 0xF)), \
|
||||
('0' + ((n)>>16 & 0xF)), \
|
||||
('0' + ((n)>>12 & 0xF)), \
|
||||
('0' + ((n)>>8 & 0xF)), \
|
||||
('0' + ((n)>>4 & 0xF)), \
|
||||
('0' + ((n) & 0xF))
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
char const info_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
||||
COMPILER_VERSION_MAJOR,
|
||||
# ifdef COMPILER_VERSION_MINOR
|
||||
'.', COMPILER_VERSION_MINOR,
|
||||
# ifdef COMPILER_VERSION_PATCH
|
||||
'.', COMPILER_VERSION_PATCH,
|
||||
# ifdef COMPILER_VERSION_TWEAK
|
||||
'.', COMPILER_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
char const info_simulate_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
||||
SIMULATE_VERSION_MAJOR,
|
||||
# ifdef SIMULATE_VERSION_MINOR
|
||||
'.', SIMULATE_VERSION_MINOR,
|
||||
# ifdef SIMULATE_VERSION_PATCH
|
||||
'.', SIMULATE_VERSION_PATCH,
|
||||
# ifdef SIMULATE_VERSION_TWEAK
|
||||
'.', SIMULATE_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined(__STDC__)
|
||||
# if defined(_MSC_VER) && !defined(__clang__)
|
||||
# define C_DIALECT "90"
|
||||
# else
|
||||
# define C_DIALECT
|
||||
# endif
|
||||
#elif __STDC_VERSION__ >= 201000L
|
||||
# define C_DIALECT "11"
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
# define C_DIALECT "99"
|
||||
#else
|
||||
# define C_DIALECT "90"
|
||||
#endif
|
||||
const char* info_language_dialect_default =
|
||||
"INFO" ":" "dialect_default[" C_DIALECT "]";
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef ID_VOID_MAIN
|
||||
void main() {}
|
||||
#else
|
||||
# if defined(__CLASSIC_C__)
|
||||
int main(argc, argv) int argc; char *argv[];
|
||||
# else
|
||||
int main(int argc, char* argv[])
|
||||
# endif
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
require += info_arch[argc];
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
require += info_version[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_ID
|
||||
require += info_simulate[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
require += info_simulate_version[argc];
|
||||
#endif
|
||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
||||
require += info_cray[argc];
|
||||
#endif
|
||||
require += info_language_dialect_default[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
||||
#endif
|
BIN
L02/CMakeFiles/3.7.2/CompilerIdC/a.out
Executable file
BIN
L02/CMakeFiles/3.7.2/CompilerIdC/a.out
Executable file
Binary file not shown.
533
L02/CMakeFiles/3.7.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
Normal file
533
L02/CMakeFiles/3.7.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
Normal file
|
@ -0,0 +1,533 @@
|
|||
/* This source file must have a .cpp extension so that all C++ compilers
|
||||
recognize the extension without flags. Borland does not know .cxx for
|
||||
example. */
|
||||
#ifndef __cplusplus
|
||||
# error "A C compiler has been selected for C++."
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number components: V=Version, R=Revision, P=Patch
|
||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
||||
|
||||
#if defined(__COMO__)
|
||||
# define COMPILER_ID "Comeau"
|
||||
/* __COMO_VERSION__ = VRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
|
||||
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
/* __INTEL_COMPILER = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
||||
# if defined(__INTEL_COMPILER_UPDATE)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
||||
# else
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
||||
# endif
|
||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
||||
# endif
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__PATHCC__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
||||
# if defined(__PATHCC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||
# define COMPILER_ID "Embarcadero"
|
||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
/* __BORLANDC__ = 0xVRR */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
||||
|
||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
||||
# define COMPILER_ID "Watcom"
|
||||
/* __WATCOMC__ = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "OpenWatcom"
|
||||
/* __WATCOMC__ = VVRP + 1100 */
|
||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SUNPRO_CC)
|
||||
# define COMPILER_ID "SunPro"
|
||||
# if __SUNPRO_CC >= 0x5100
|
||||
/* __SUNPRO_CC = 0xVRRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# else
|
||||
/* __SUNPRO_CC = 0xVRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# endif
|
||||
|
||||
#elif defined(__HP_aCC)
|
||||
# define COMPILER_ID "HP"
|
||||
/* __HP_aCC = VVRRPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
|
||||
|
||||
#elif defined(__DECCXX)
|
||||
# define COMPILER_ID "Compaq"
|
||||
/* __DECCXX_VER = VVRRTPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
|
||||
|
||||
#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
|
||||
# define COMPILER_ID "VisualAge"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
||||
# if defined(__PGIC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_CRAYC)
|
||||
# define COMPILER_ID "Cray"
|
||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# define COMPILER_ID "TI"
|
||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
||||
|
||||
#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)
|
||||
# define COMPILER_ID "Fujitsu"
|
||||
|
||||
#elif defined(__SCO_VERSION__)
|
||||
# define COMPILER_ID "SCO"
|
||||
|
||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
||||
# define COMPILER_ID "AppleClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
||||
|
||||
#elif defined(__clang__)
|
||||
# define COMPILER_ID "Clang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_ID "GNU"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
/* _MSC_VER = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# if defined(_MSC_FULL_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
||||
# else
|
||||
/* _MSC_FULL_VER = VVRRPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_MSC_BUILD)
|
||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
||||
# endif
|
||||
|
||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
# define COMPILER_ID "ADSP"
|
||||
#if defined(__VISUALDSPVERSION__)
|
||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
||||
#endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
|
||||
# define COMPILER_ID "IAR"
|
||||
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
# define COMPILER_ID "ARMCC"
|
||||
#if __ARMCC_VERSION >= 1000000
|
||||
/* __ARMCC_VERSION = VRRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#else
|
||||
/* __ARMCC_VERSION = VRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
# if defined(_SGI_COMPILER_VERSION)
|
||||
/* _SGI_COMPILER_VERSION = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
|
||||
# else
|
||||
/* _COMPILER_VERSION = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
|
||||
# endif
|
||||
|
||||
|
||||
/* These compilers are either not known or too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__sgi)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
#ifdef SIMULATE_ID
|
||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
#endif
|
||||
|
||||
#ifdef __QNXNTO__
|
||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_HELPER(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
|
||||
# define PLATFORM_ID "IRIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__LINUX__)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
# elif defined(__DOS__)
|
||||
# define PLATFORM_ID "DOS"
|
||||
|
||||
# elif defined(__OS2__)
|
||||
# define PLATFORM_ID "OS2"
|
||||
|
||||
# elif defined(__WINDOWS__)
|
||||
# define PLATFORM_ID "Windows3x"
|
||||
|
||||
# else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
# endif
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# elif defined(_M_ARM)
|
||||
# if _M_ARM == 4
|
||||
# define ARCHITECTURE_ID "ARMV4I"
|
||||
# elif _M_ARM == 5
|
||||
# define ARCHITECTURE_ID "ARMV5I"
|
||||
# else
|
||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
||||
# endif
|
||||
|
||||
# elif defined(_M_MIPS)
|
||||
# define ARCHITECTURE_ID "MIPS"
|
||||
|
||||
# elif defined(_M_SH)
|
||||
# define ARCHITECTURE_ID "SHx"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(_M_I86)
|
||||
# define ARCHITECTURE_ID "I86"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID
|
||||
#endif
|
||||
|
||||
/* Convert integer to decimal digit literals. */
|
||||
#define DEC(n) \
|
||||
('0' + (((n) / 10000000)%10)), \
|
||||
('0' + (((n) / 1000000)%10)), \
|
||||
('0' + (((n) / 100000)%10)), \
|
||||
('0' + (((n) / 10000)%10)), \
|
||||
('0' + (((n) / 1000)%10)), \
|
||||
('0' + (((n) / 100)%10)), \
|
||||
('0' + (((n) / 10)%10)), \
|
||||
('0' + ((n) % 10))
|
||||
|
||||
/* Convert integer to hex digit literals. */
|
||||
#define HEX(n) \
|
||||
('0' + ((n)>>28 & 0xF)), \
|
||||
('0' + ((n)>>24 & 0xF)), \
|
||||
('0' + ((n)>>20 & 0xF)), \
|
||||
('0' + ((n)>>16 & 0xF)), \
|
||||
('0' + ((n)>>12 & 0xF)), \
|
||||
('0' + ((n)>>8 & 0xF)), \
|
||||
('0' + ((n)>>4 & 0xF)), \
|
||||
('0' + ((n) & 0xF))
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
char const info_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
||||
COMPILER_VERSION_MAJOR,
|
||||
# ifdef COMPILER_VERSION_MINOR
|
||||
'.', COMPILER_VERSION_MINOR,
|
||||
# ifdef COMPILER_VERSION_PATCH
|
||||
'.', COMPILER_VERSION_PATCH,
|
||||
# ifdef COMPILER_VERSION_TWEAK
|
||||
'.', COMPILER_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
char const info_simulate_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
||||
SIMULATE_VERSION_MAJOR,
|
||||
# ifdef SIMULATE_VERSION_MINOR
|
||||
'.', SIMULATE_VERSION_MINOR,
|
||||
# ifdef SIMULATE_VERSION_PATCH
|
||||
'.', SIMULATE_VERSION_PATCH,
|
||||
# ifdef SIMULATE_VERSION_TWEAK
|
||||
'.', SIMULATE_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
|
||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
||||
#if __cplusplus >= 201402L
|
||||
"14"
|
||||
#elif __cplusplus >= 201103L
|
||||
"11"
|
||||
#else
|
||||
"98"
|
||||
#endif
|
||||
"]";
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
require += info_version[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_ID
|
||||
require += info_simulate[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
require += info_simulate_version[argc];
|
||||
#endif
|
||||
#if defined(__CRAYXE) || defined(__CRAYXC)
|
||||
require += info_cray[argc];
|
||||
#endif
|
||||
require += info_language_dialect_default[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
BIN
L02/CMakeFiles/3.7.2/CompilerIdCXX/a.out
Executable file
BIN
L02/CMakeFiles/3.7.2/CompilerIdCXX/a.out
Executable file
Binary file not shown.
16
L02/CMakeFiles/CMakeDirectoryInformation.cmake
Normal file
16
L02/CMakeFiles/CMakeDirectoryInformation.cmake
Normal file
|
@ -0,0 +1,16 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.7
|
||||
|
||||
# Relative path conversion top directories.
|
||||
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/shadow8t4/Documents/CSCE441/L02")
|
||||
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/shadow8t4/Documents/CSCE441/L02/build")
|
||||
|
||||
# Force unix paths in dependencies.
|
||||
set(CMAKE_FORCE_UNIX_PATHS 1)
|
||||
|
||||
|
||||
# The C and CXX include file regular expressions for this directory.
|
||||
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
|
||||
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
|
||||
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
|
||||
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
|
544
L02/CMakeFiles/CMakeOutput.log
Normal file
544
L02/CMakeFiles/CMakeOutput.log
Normal file
|
@ -0,0 +1,544 @@
|
|||
The system is: Linux - 4.8.13-1-ARCH - x86_64
|
||||
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
|
||||
Compiler: /usr/lib/hardening-wrapper/bin/cc
|
||||
Build flags:
|
||||
Id flags:
|
||||
|
||||
The output was:
|
||||
0
|
||||
|
||||
|
||||
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
|
||||
|
||||
The C compiler identification is GNU, found in "/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/3.7.2/CompilerIdC/a.out"
|
||||
|
||||
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
|
||||
Compiler: /usr/lib/hardening-wrapper/bin/c++
|
||||
Build flags:
|
||||
Id flags:
|
||||
|
||||
The output was:
|
||||
0
|
||||
|
||||
|
||||
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
|
||||
|
||||
The CXX compiler identification is GNU, found in "/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/3.7.2/CompilerIdCXX/a.out"
|
||||
|
||||
Determining if the C compiler works passed with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_a24a7/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_a24a7.dir/build.make CMakeFiles/cmTC_a24a7.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building C object CMakeFiles/cmTC_a24a7.dir/testCCompiler.c.o
|
||||
/usr/lib/hardening-wrapper/bin/cc -o CMakeFiles/cmTC_a24a7.dir/testCCompiler.c.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp/testCCompiler.c
|
||||
Linking C executable cmTC_a24a7
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a24a7.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/cc CMakeFiles/cmTC_a24a7.dir/testCCompiler.c.o -o cmTC_a24a7 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Detecting C compiler ABI info compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_89404/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_89404.dir/build.make CMakeFiles/cmTC_89404.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building C object CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o
|
||||
/usr/lib/hardening-wrapper/bin/cc -o CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.7/Modules/CMakeCCompilerABI.c
|
||||
Linking C executable cmTC_89404
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_89404.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/cc -v CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -o cmTC_89404 -rdynamic
|
||||
Using built-in specs.
|
||||
COLLECT_GCC=/usr/bin/cc
|
||||
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
|
||||
Target: x86_64-pc-linux-gnu
|
||||
Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release
|
||||
Thread model: posix
|
||||
gcc version 6.3.1 20170109 (GCC)
|
||||
COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/
|
||||
LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../:/lib/:/usr/lib/
|
||||
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_89404' '-rdynamic' '-mtune=generic' '-march=x86-64'
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccNP9yHN.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_89404 /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o -L/usr/lib/hardening-wrapper/bin -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../.. CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o
|
||||
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_89404' '-rdynamic' '-mtune=generic' '-march=x86-64'
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Parsed C implicit link information from above output:
|
||||
link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
|
||||
ignore line: [Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp]
|
||||
ignore line: []
|
||||
ignore line: [Run Build Command:"/usr/bin/make" "cmTC_89404/fast"]
|
||||
ignore line: [/usr/bin/make -f CMakeFiles/cmTC_89404.dir/build.make CMakeFiles/cmTC_89404.dir/build]
|
||||
ignore line: [make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp']
|
||||
ignore line: [Building C object CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o]
|
||||
ignore line: [/usr/lib/hardening-wrapper/bin/cc -o CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.7/Modules/CMakeCCompilerABI.c]
|
||||
ignore line: [Linking C executable cmTC_89404]
|
||||
ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_89404.dir/link.txt --verbose=1]
|
||||
ignore line: [/usr/lib/hardening-wrapper/bin/cc -v CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -o cmTC_89404 -rdynamic ]
|
||||
ignore line: [Using built-in specs.]
|
||||
ignore line: [COLLECT_GCC=/usr/bin/cc]
|
||||
ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper]
|
||||
ignore line: [Target: x86_64-pc-linux-gnu]
|
||||
ignore line: [Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release]
|
||||
ignore line: [Thread model: posix]
|
||||
ignore line: [gcc version 6.3.1 20170109 (GCC) ]
|
||||
ignore line: [COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/]
|
||||
ignore line: [LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../:/lib/:/usr/lib/]
|
||||
ignore line: [COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_89404' '-rdynamic' '-mtune=generic' '-march=x86-64']
|
||||
link line: [ /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccNP9yHN.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_89404 /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o -L/usr/lib/hardening-wrapper/bin -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../.. CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o]
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2] ==> ignore
|
||||
arg [-plugin] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so] ==> ignore
|
||||
arg [-plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper] ==> ignore
|
||||
arg [-plugin-opt=-fresolution=/tmp/ccNP9yHN.res] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lc] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
||||
arg [--build-id] ==> ignore
|
||||
arg [--eh-frame-hdr] ==> ignore
|
||||
arg [--hash-style=gnu] ==> ignore
|
||||
arg [-m] ==> ignore
|
||||
arg [elf_x86_64] ==> ignore
|
||||
arg [-export-dynamic] ==> ignore
|
||||
arg [-dynamic-linker] ==> ignore
|
||||
arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
|
||||
arg [-pie] ==> ignore
|
||||
arg [-o] ==> ignore
|
||||
arg [cmTC_89404] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o] ==> ignore
|
||||
arg [-L/usr/lib/hardening-wrapper/bin] ==> dir [/usr/lib/hardening-wrapper/bin]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib]
|
||||
arg [-L/lib/../lib] ==> dir [/lib/../lib]
|
||||
arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..]
|
||||
arg [CMakeFiles/cmTC_89404.dir/CMakeCCompilerABI.c.o] ==> ignore
|
||||
arg [-lgcc] ==> lib [gcc]
|
||||
arg [--as-needed] ==> ignore
|
||||
arg [-lgcc_s] ==> lib [gcc_s]
|
||||
arg [--no-as-needed] ==> ignore
|
||||
arg [-lc] ==> lib [c]
|
||||
arg [-lgcc] ==> lib [gcc]
|
||||
arg [--as-needed] ==> ignore
|
||||
arg [-lgcc_s] ==> lib [gcc_s]
|
||||
arg [--no-as-needed] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o] ==> ignore
|
||||
remove lib [gcc]
|
||||
remove lib [gcc_s]
|
||||
remove lib [gcc]
|
||||
remove lib [gcc_s]
|
||||
collapse library dir [/usr/lib/hardening-wrapper/bin] ==> [/usr/lib/hardening-wrapper/bin]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1] ==> [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib] ==> [/usr/lib]
|
||||
collapse library dir [/lib/../lib] ==> [/lib]
|
||||
collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..] ==> [/usr/lib]
|
||||
implicit libs: [c]
|
||||
implicit dirs: [/usr/lib/hardening-wrapper/bin;/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1;/usr/lib;/lib]
|
||||
implicit fwks: []
|
||||
|
||||
|
||||
|
||||
|
||||
Detecting C [-std=c11] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_82150/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_82150.dir/build.make CMakeFiles/cmTC_82150.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building C object CMakeFiles/cmTC_82150.dir/feature_tests.c.o
|
||||
/usr/lib/hardening-wrapper/bin/cc -std=c11 -o CMakeFiles/cmTC_82150.dir/feature_tests.c.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.c
|
||||
Linking C executable cmTC_82150
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_82150.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/cc CMakeFiles/cmTC_82150.dir/feature_tests.c.o -o cmTC_82150 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: C_FEATURE:1c_function_prototypes
|
||||
Feature record: C_FEATURE:1c_restrict
|
||||
Feature record: C_FEATURE:1c_static_assert
|
||||
Feature record: C_FEATURE:1c_variadic_macros
|
||||
|
||||
|
||||
Detecting C [-std=c99] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_1c427/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_1c427.dir/build.make CMakeFiles/cmTC_1c427.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building C object CMakeFiles/cmTC_1c427.dir/feature_tests.c.o
|
||||
/usr/lib/hardening-wrapper/bin/cc -std=c99 -o CMakeFiles/cmTC_1c427.dir/feature_tests.c.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.c
|
||||
Linking C executable cmTC_1c427
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1c427.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/cc CMakeFiles/cmTC_1c427.dir/feature_tests.c.o -o cmTC_1c427 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: C_FEATURE:1c_function_prototypes
|
||||
Feature record: C_FEATURE:1c_restrict
|
||||
Feature record: C_FEATURE:0c_static_assert
|
||||
Feature record: C_FEATURE:1c_variadic_macros
|
||||
|
||||
|
||||
Detecting C [-std=c90] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_6a547/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_6a547.dir/build.make CMakeFiles/cmTC_6a547.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building C object CMakeFiles/cmTC_6a547.dir/feature_tests.c.o
|
||||
/usr/lib/hardening-wrapper/bin/cc -std=c90 -o CMakeFiles/cmTC_6a547.dir/feature_tests.c.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.c
|
||||
Linking C executable cmTC_6a547
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_6a547.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/cc CMakeFiles/cmTC_6a547.dir/feature_tests.c.o -o cmTC_6a547 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: C_FEATURE:1c_function_prototypes
|
||||
Feature record: C_FEATURE:0c_restrict
|
||||
Feature record: C_FEATURE:0c_static_assert
|
||||
Feature record: C_FEATURE:0c_variadic_macros
|
||||
Determining if the CXX compiler works passed with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_f3383/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_f3383.dir/build.make CMakeFiles/cmTC_f3383.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building CXX object CMakeFiles/cmTC_f3383.dir/testCXXCompiler.cxx.o
|
||||
/usr/lib/hardening-wrapper/bin/c++ -o CMakeFiles/cmTC_f3383.dir/testCXXCompiler.cxx.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
|
||||
Linking CXX executable cmTC_f3383
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f3383.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/c++ CMakeFiles/cmTC_f3383.dir/testCXXCompiler.cxx.o -o cmTC_f3383 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Detecting CXX compiler ABI info compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_ad6b8/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_ad6b8.dir/build.make CMakeFiles/cmTC_ad6b8.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building CXX object CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o
|
||||
/usr/lib/hardening-wrapper/bin/c++ -o CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp
|
||||
Linking CXX executable cmTC_ad6b8
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ad6b8.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/c++ -v CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_ad6b8 -rdynamic
|
||||
Using built-in specs.
|
||||
COLLECT_GCC=/usr/bin/c++
|
||||
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper
|
||||
Target: x86_64-pc-linux-gnu
|
||||
Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release
|
||||
Thread model: posix
|
||||
gcc version 6.3.1 20170109 (GCC)
|
||||
COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/
|
||||
LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../:/lib/:/usr/lib/
|
||||
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_ad6b8' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
||||
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJChkf9.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_ad6b8 /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o -L/usr/lib/hardening-wrapper/bin -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../.. CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o
|
||||
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_ad6b8' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Parsed CXX implicit link information from above output:
|
||||
link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
|
||||
ignore line: [Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp]
|
||||
ignore line: []
|
||||
ignore line: [Run Build Command:"/usr/bin/make" "cmTC_ad6b8/fast"]
|
||||
ignore line: [/usr/bin/make -f CMakeFiles/cmTC_ad6b8.dir/build.make CMakeFiles/cmTC_ad6b8.dir/build]
|
||||
ignore line: [make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp']
|
||||
ignore line: [Building CXX object CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o]
|
||||
ignore line: [/usr/lib/hardening-wrapper/bin/c++ -o CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp]
|
||||
ignore line: [Linking CXX executable cmTC_ad6b8]
|
||||
ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ad6b8.dir/link.txt --verbose=1]
|
||||
ignore line: [/usr/lib/hardening-wrapper/bin/c++ -v CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_ad6b8 -rdynamic ]
|
||||
ignore line: [Using built-in specs.]
|
||||
ignore line: [COLLECT_GCC=/usr/bin/c++]
|
||||
ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper]
|
||||
ignore line: [Target: x86_64-pc-linux-gnu]
|
||||
ignore line: [Configured with: /build/gcc-multilib/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release]
|
||||
ignore line: [Thread model: posix]
|
||||
ignore line: [gcc version 6.3.1 20170109 (GCC) ]
|
||||
ignore line: [COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/]
|
||||
ignore line: [LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../:/lib/:/usr/lib/]
|
||||
ignore line: [COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-pie' '-fstack-check=specific' '-fstack-protector-strong' '-v' '-o' 'cmTC_ad6b8' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64']
|
||||
link line: [ /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJChkf9.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_ad6b8 /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o -L/usr/lib/hardening-wrapper/bin -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../.. CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o]
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/collect2] ==> ignore
|
||||
arg [-plugin] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/liblto_plugin.so] ==> ignore
|
||||
arg [-plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/lto-wrapper] ==> ignore
|
||||
arg [-plugin-opt=-fresolution=/tmp/ccJChkf9.res] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lc] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc_s] ==> ignore
|
||||
arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
|
||||
arg [--build-id] ==> ignore
|
||||
arg [--eh-frame-hdr] ==> ignore
|
||||
arg [--hash-style=gnu] ==> ignore
|
||||
arg [-m] ==> ignore
|
||||
arg [elf_x86_64] ==> ignore
|
||||
arg [-export-dynamic] ==> ignore
|
||||
arg [-dynamic-linker] ==> ignore
|
||||
arg [/lib64/ld-linux-x86-64.so.2] ==> ignore
|
||||
arg [-pie] ==> ignore
|
||||
arg [-o] ==> ignore
|
||||
arg [cmTC_ad6b8] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/Scrt1.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crti.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtbeginS.o] ==> ignore
|
||||
arg [-L/usr/lib/hardening-wrapper/bin] ==> dir [/usr/lib/hardening-wrapper/bin]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib]
|
||||
arg [-L/lib/../lib] ==> dir [/lib/../lib]
|
||||
arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib]
|
||||
arg [-L/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..] ==> dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..]
|
||||
arg [CMakeFiles/cmTC_ad6b8.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore
|
||||
arg [-lstdc++] ==> lib [stdc++]
|
||||
arg [-lm] ==> lib [m]
|
||||
arg [-lgcc_s] ==> lib [gcc_s]
|
||||
arg [-lgcc] ==> lib [gcc]
|
||||
arg [-lc] ==> lib [c]
|
||||
arg [-lgcc_s] ==> lib [gcc_s]
|
||||
arg [-lgcc] ==> lib [gcc]
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/crtendS.o] ==> ignore
|
||||
arg [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/crtn.o] ==> ignore
|
||||
remove lib [gcc_s]
|
||||
remove lib [gcc]
|
||||
remove lib [gcc_s]
|
||||
remove lib [gcc]
|
||||
collapse library dir [/usr/lib/hardening-wrapper/bin] ==> [/usr/lib/hardening-wrapper/bin]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1] ==> [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib] ==> [/usr/lib]
|
||||
collapse library dir [/lib/../lib] ==> [/lib]
|
||||
collapse library dir [/usr/lib/../lib] ==> [/usr/lib]
|
||||
collapse library dir [/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../..] ==> [/usr/lib]
|
||||
implicit libs: [stdc++;m;c]
|
||||
implicit dirs: [/usr/lib/hardening-wrapper/bin;/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1;/usr/lib;/lib]
|
||||
implicit fwks: []
|
||||
|
||||
|
||||
|
||||
|
||||
Detecting CXX [-std=c++14] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_e6959/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_e6959.dir/build.make CMakeFiles/cmTC_e6959.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building CXX object CMakeFiles/cmTC_e6959.dir/feature_tests.cxx.o
|
||||
/usr/lib/hardening-wrapper/bin/c++ -std=c++14 -o CMakeFiles/cmTC_e6959.dir/feature_tests.cxx.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.cxx
|
||||
Linking CXX executable cmTC_e6959
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e6959.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/c++ CMakeFiles/cmTC_e6959.dir/feature_tests.cxx.o -o cmTC_e6959 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers
|
||||
Feature record: CXX_FEATURE:1cxx_alias_templates
|
||||
Feature record: CXX_FEATURE:1cxx_alignas
|
||||
Feature record: CXX_FEATURE:1cxx_alignof
|
||||
Feature record: CXX_FEATURE:1cxx_attributes
|
||||
Feature record: CXX_FEATURE:1cxx_attribute_deprecated
|
||||
Feature record: CXX_FEATURE:1cxx_auto_type
|
||||
Feature record: CXX_FEATURE:1cxx_binary_literals
|
||||
Feature record: CXX_FEATURE:1cxx_constexpr
|
||||
Feature record: CXX_FEATURE:1cxx_contextual_conversions
|
||||
Feature record: CXX_FEATURE:1cxx_decltype
|
||||
Feature record: CXX_FEATURE:1cxx_decltype_auto
|
||||
Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types
|
||||
Feature record: CXX_FEATURE:1cxx_default_function_template_args
|
||||
Feature record: CXX_FEATURE:1cxx_defaulted_functions
|
||||
Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers
|
||||
Feature record: CXX_FEATURE:1cxx_delegating_constructors
|
||||
Feature record: CXX_FEATURE:1cxx_deleted_functions
|
||||
Feature record: CXX_FEATURE:1cxx_digit_separators
|
||||
Feature record: CXX_FEATURE:1cxx_enum_forward_declarations
|
||||
Feature record: CXX_FEATURE:1cxx_explicit_conversions
|
||||
Feature record: CXX_FEATURE:1cxx_extended_friend_declarations
|
||||
Feature record: CXX_FEATURE:1cxx_extern_templates
|
||||
Feature record: CXX_FEATURE:1cxx_final
|
||||
Feature record: CXX_FEATURE:1cxx_func_identifier
|
||||
Feature record: CXX_FEATURE:1cxx_generalized_initializers
|
||||
Feature record: CXX_FEATURE:1cxx_generic_lambdas
|
||||
Feature record: CXX_FEATURE:1cxx_inheriting_constructors
|
||||
Feature record: CXX_FEATURE:1cxx_inline_namespaces
|
||||
Feature record: CXX_FEATURE:1cxx_lambdas
|
||||
Feature record: CXX_FEATURE:1cxx_lambda_init_captures
|
||||
Feature record: CXX_FEATURE:1cxx_local_type_template_args
|
||||
Feature record: CXX_FEATURE:1cxx_long_long_type
|
||||
Feature record: CXX_FEATURE:1cxx_noexcept
|
||||
Feature record: CXX_FEATURE:1cxx_nonstatic_member_init
|
||||
Feature record: CXX_FEATURE:1cxx_nullptr
|
||||
Feature record: CXX_FEATURE:1cxx_override
|
||||
Feature record: CXX_FEATURE:1cxx_range_for
|
||||
Feature record: CXX_FEATURE:1cxx_raw_string_literals
|
||||
Feature record: CXX_FEATURE:1cxx_reference_qualified_functions
|
||||
Feature record: CXX_FEATURE:1cxx_relaxed_constexpr
|
||||
Feature record: CXX_FEATURE:1cxx_return_type_deduction
|
||||
Feature record: CXX_FEATURE:1cxx_right_angle_brackets
|
||||
Feature record: CXX_FEATURE:1cxx_rvalue_references
|
||||
Feature record: CXX_FEATURE:1cxx_sizeof_member
|
||||
Feature record: CXX_FEATURE:1cxx_static_assert
|
||||
Feature record: CXX_FEATURE:1cxx_strong_enums
|
||||
Feature record: CXX_FEATURE:1cxx_template_template_parameters
|
||||
Feature record: CXX_FEATURE:1cxx_thread_local
|
||||
Feature record: CXX_FEATURE:1cxx_trailing_return_types
|
||||
Feature record: CXX_FEATURE:1cxx_unicode_literals
|
||||
Feature record: CXX_FEATURE:1cxx_uniform_initialization
|
||||
Feature record: CXX_FEATURE:1cxx_unrestricted_unions
|
||||
Feature record: CXX_FEATURE:1cxx_user_literals
|
||||
Feature record: CXX_FEATURE:1cxx_variable_templates
|
||||
Feature record: CXX_FEATURE:1cxx_variadic_macros
|
||||
Feature record: CXX_FEATURE:1cxx_variadic_templates
|
||||
|
||||
|
||||
Detecting CXX [-std=c++11] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_990df/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_990df.dir/build.make CMakeFiles/cmTC_990df.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building CXX object CMakeFiles/cmTC_990df.dir/feature_tests.cxx.o
|
||||
/usr/lib/hardening-wrapper/bin/c++ -std=c++11 -o CMakeFiles/cmTC_990df.dir/feature_tests.cxx.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.cxx
|
||||
Linking CXX executable cmTC_990df
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_990df.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/c++ CMakeFiles/cmTC_990df.dir/feature_tests.cxx.o -o cmTC_990df -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers
|
||||
Feature record: CXX_FEATURE:1cxx_alias_templates
|
||||
Feature record: CXX_FEATURE:1cxx_alignas
|
||||
Feature record: CXX_FEATURE:1cxx_alignof
|
||||
Feature record: CXX_FEATURE:1cxx_attributes
|
||||
Feature record: CXX_FEATURE:0cxx_attribute_deprecated
|
||||
Feature record: CXX_FEATURE:1cxx_auto_type
|
||||
Feature record: CXX_FEATURE:0cxx_binary_literals
|
||||
Feature record: CXX_FEATURE:1cxx_constexpr
|
||||
Feature record: CXX_FEATURE:0cxx_contextual_conversions
|
||||
Feature record: CXX_FEATURE:1cxx_decltype
|
||||
Feature record: CXX_FEATURE:0cxx_decltype_auto
|
||||
Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types
|
||||
Feature record: CXX_FEATURE:1cxx_default_function_template_args
|
||||
Feature record: CXX_FEATURE:1cxx_defaulted_functions
|
||||
Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers
|
||||
Feature record: CXX_FEATURE:1cxx_delegating_constructors
|
||||
Feature record: CXX_FEATURE:1cxx_deleted_functions
|
||||
Feature record: CXX_FEATURE:0cxx_digit_separators
|
||||
Feature record: CXX_FEATURE:1cxx_enum_forward_declarations
|
||||
Feature record: CXX_FEATURE:1cxx_explicit_conversions
|
||||
Feature record: CXX_FEATURE:1cxx_extended_friend_declarations
|
||||
Feature record: CXX_FEATURE:1cxx_extern_templates
|
||||
Feature record: CXX_FEATURE:1cxx_final
|
||||
Feature record: CXX_FEATURE:1cxx_func_identifier
|
||||
Feature record: CXX_FEATURE:1cxx_generalized_initializers
|
||||
Feature record: CXX_FEATURE:0cxx_generic_lambdas
|
||||
Feature record: CXX_FEATURE:1cxx_inheriting_constructors
|
||||
Feature record: CXX_FEATURE:1cxx_inline_namespaces
|
||||
Feature record: CXX_FEATURE:1cxx_lambdas
|
||||
Feature record: CXX_FEATURE:0cxx_lambda_init_captures
|
||||
Feature record: CXX_FEATURE:1cxx_local_type_template_args
|
||||
Feature record: CXX_FEATURE:1cxx_long_long_type
|
||||
Feature record: CXX_FEATURE:1cxx_noexcept
|
||||
Feature record: CXX_FEATURE:1cxx_nonstatic_member_init
|
||||
Feature record: CXX_FEATURE:1cxx_nullptr
|
||||
Feature record: CXX_FEATURE:1cxx_override
|
||||
Feature record: CXX_FEATURE:1cxx_range_for
|
||||
Feature record: CXX_FEATURE:1cxx_raw_string_literals
|
||||
Feature record: CXX_FEATURE:1cxx_reference_qualified_functions
|
||||
Feature record: CXX_FEATURE:0cxx_relaxed_constexpr
|
||||
Feature record: CXX_FEATURE:0cxx_return_type_deduction
|
||||
Feature record: CXX_FEATURE:1cxx_right_angle_brackets
|
||||
Feature record: CXX_FEATURE:1cxx_rvalue_references
|
||||
Feature record: CXX_FEATURE:1cxx_sizeof_member
|
||||
Feature record: CXX_FEATURE:1cxx_static_assert
|
||||
Feature record: CXX_FEATURE:1cxx_strong_enums
|
||||
Feature record: CXX_FEATURE:1cxx_template_template_parameters
|
||||
Feature record: CXX_FEATURE:1cxx_thread_local
|
||||
Feature record: CXX_FEATURE:1cxx_trailing_return_types
|
||||
Feature record: CXX_FEATURE:1cxx_unicode_literals
|
||||
Feature record: CXX_FEATURE:1cxx_uniform_initialization
|
||||
Feature record: CXX_FEATURE:1cxx_unrestricted_unions
|
||||
Feature record: CXX_FEATURE:1cxx_user_literals
|
||||
Feature record: CXX_FEATURE:0cxx_variable_templates
|
||||
Feature record: CXX_FEATURE:1cxx_variadic_macros
|
||||
Feature record: CXX_FEATURE:1cxx_variadic_templates
|
||||
|
||||
|
||||
Detecting CXX [-std=c++98] compiler features compiled with the following output:
|
||||
Change Dir: /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp
|
||||
|
||||
Run Build Command:"/usr/bin/make" "cmTC_7a266/fast"
|
||||
/usr/bin/make -f CMakeFiles/cmTC_7a266.dir/build.make CMakeFiles/cmTC_7a266.dir/build
|
||||
make[1]: Entering directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
Building CXX object CMakeFiles/cmTC_7a266.dir/feature_tests.cxx.o
|
||||
/usr/lib/hardening-wrapper/bin/c++ -std=c++98 -o CMakeFiles/cmTC_7a266.dir/feature_tests.cxx.o -c /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/feature_tests.cxx
|
||||
Linking CXX executable cmTC_7a266
|
||||
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7a266.dir/link.txt --verbose=1
|
||||
/usr/lib/hardening-wrapper/bin/c++ CMakeFiles/cmTC_7a266.dir/feature_tests.cxx.o -o cmTC_7a266 -rdynamic
|
||||
make[1]: Leaving directory '/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/CMakeTmp'
|
||||
|
||||
|
||||
Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers
|
||||
Feature record: CXX_FEATURE:0cxx_alias_templates
|
||||
Feature record: CXX_FEATURE:0cxx_alignas
|
||||
Feature record: CXX_FEATURE:0cxx_alignof
|
||||
Feature record: CXX_FEATURE:0cxx_attributes
|
||||
Feature record: CXX_FEATURE:0cxx_attribute_deprecated
|
||||
Feature record: CXX_FEATURE:0cxx_auto_type
|
||||
Feature record: CXX_FEATURE:0cxx_binary_literals
|
||||
Feature record: CXX_FEATURE:0cxx_constexpr
|
||||
Feature record: CXX_FEATURE:0cxx_contextual_conversions
|
||||
Feature record: CXX_FEATURE:0cxx_decltype
|
||||
Feature record: CXX_FEATURE:0cxx_decltype_auto
|
||||
Feature record: CXX_FEATURE:0cxx_decltype_incomplete_return_types
|
||||
Feature record: CXX_FEATURE:0cxx_default_function_template_args
|
||||
Feature record: CXX_FEATURE:0cxx_defaulted_functions
|
||||
Feature record: CXX_FEATURE:0cxx_defaulted_move_initializers
|
||||
Feature record: CXX_FEATURE:0cxx_delegating_constructors
|
||||
Feature record: CXX_FEATURE:0cxx_deleted_functions
|
||||
Feature record: CXX_FEATURE:0cxx_digit_separators
|
||||
Feature record: CXX_FEATURE:0cxx_enum_forward_declarations
|
||||
Feature record: CXX_FEATURE:0cxx_explicit_conversions
|
||||
Feature record: CXX_FEATURE:0cxx_extended_friend_declarations
|
||||
Feature record: CXX_FEATURE:0cxx_extern_templates
|
||||
Feature record: CXX_FEATURE:0cxx_final
|
||||
Feature record: CXX_FEATURE:0cxx_func_identifier
|
||||
Feature record: CXX_FEATURE:0cxx_generalized_initializers
|
||||
Feature record: CXX_FEATURE:0cxx_generic_lambdas
|
||||
Feature record: CXX_FEATURE:0cxx_inheriting_constructors
|
||||
Feature record: CXX_FEATURE:0cxx_inline_namespaces
|
||||
Feature record: CXX_FEATURE:0cxx_lambdas
|
||||
Feature record: CXX_FEATURE:0cxx_lambda_init_captures
|
||||
Feature record: CXX_FEATURE:0cxx_local_type_template_args
|
||||
Feature record: CXX_FEATURE:0cxx_long_long_type
|
||||
Feature record: CXX_FEATURE:0cxx_noexcept
|
||||
Feature record: CXX_FEATURE:0cxx_nonstatic_member_init
|
||||
Feature record: CXX_FEATURE:0cxx_nullptr
|
||||
Feature record: CXX_FEATURE:0cxx_override
|
||||
Feature record: CXX_FEATURE:0cxx_range_for
|
||||
Feature record: CXX_FEATURE:0cxx_raw_string_literals
|
||||
Feature record: CXX_FEATURE:0cxx_reference_qualified_functions
|
||||
Feature record: CXX_FEATURE:0cxx_relaxed_constexpr
|
||||
Feature record: CXX_FEATURE:0cxx_return_type_deduction
|
||||
Feature record: CXX_FEATURE:0cxx_right_angle_brackets
|
||||
Feature record: CXX_FEATURE:0cxx_rvalue_references
|
||||
Feature record: CXX_FEATURE:0cxx_sizeof_member
|
||||
Feature record: CXX_FEATURE:0cxx_static_assert
|
||||
Feature record: CXX_FEATURE:0cxx_strong_enums
|
||||
Feature record: CXX_FEATURE:1cxx_template_template_parameters
|
||||
Feature record: CXX_FEATURE:0cxx_thread_local
|
||||
Feature record: CXX_FEATURE:0cxx_trailing_return_types
|
||||
Feature record: CXX_FEATURE:0cxx_unicode_literals
|
||||
Feature record: CXX_FEATURE:0cxx_uniform_initialization
|
||||
Feature record: CXX_FEATURE:0cxx_unrestricted_unions
|
||||
Feature record: CXX_FEATURE:0cxx_user_literals
|
||||
Feature record: CXX_FEATURE:0cxx_variable_templates
|
||||
Feature record: CXX_FEATURE:0cxx_variadic_macros
|
||||
Feature record: CXX_FEATURE:0cxx_variadic_templates
|
52
L02/CMakeFiles/L02.dir/CXX.includecache
Normal file
52
L02/CMakeFiles/L02.dir/CXX.includecache
Normal file
|
@ -0,0 +1,52 @@
|
|||
#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">])
|
||||
|
||||
#IncludeRegexScan: ^.*$
|
||||
|
||||
#IncludeRegexComplain: ^$
|
||||
|
||||
#IncludeRegexTransform:
|
||||
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp
|
||||
iostream
|
||||
-
|
||||
cassert
|
||||
-
|
||||
Image.h
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.h
|
||||
stb_image_write.h
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/stb_image_write.h
|
||||
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.h
|
||||
string
|
||||
-
|
||||
vector
|
||||
-
|
||||
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/main.cpp
|
||||
iostream
|
||||
-
|
||||
string
|
||||
-
|
||||
vector
|
||||
-
|
||||
memory
|
||||
-
|
||||
Image.h
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.h
|
||||
math.h
|
||||
-
|
||||
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/stb_image_write.h
|
||||
stdio.h
|
||||
-
|
||||
stdarg.h
|
||||
-
|
||||
stdlib.h
|
||||
-
|
||||
string.h
|
||||
-
|
||||
math.h
|
||||
-
|
||||
assert.h
|
||||
-
|
||||
|
21
L02/CMakeFiles/L02.dir/DependInfo.cmake
Normal file
21
L02/CMakeFiles/L02.dir/DependInfo.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
# The set of languages for which implicit dependencies are needed:
|
||||
set(CMAKE_DEPENDS_LANGUAGES
|
||||
"CXX"
|
||||
)
|
||||
# The set of files for implicit dependencies of each language:
|
||||
set(CMAKE_DEPENDS_CHECK_CXX
|
||||
"/home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp" "/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/L02.dir/src/Image.cpp.o"
|
||||
"/home/shadow8t4/Documents/CSCE441/L02/src/main.cpp" "/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/L02.dir/src/main.cpp.o"
|
||||
)
|
||||
set(CMAKE_CXX_COMPILER_ID "GNU")
|
||||
|
||||
# The include file search paths:
|
||||
set(CMAKE_CXX_TARGET_INCLUDE_PATH
|
||||
)
|
||||
|
||||
# Targets to which this target links.
|
||||
set(CMAKE_TARGET_LINKED_INFO_FILES
|
||||
)
|
||||
|
||||
# Fortran module output directory.
|
||||
set(CMAKE_Fortran_TARGET_MODULE_DIR "")
|
140
L02/CMakeFiles/L02.dir/build.make
Normal file
140
L02/CMakeFiles/L02.dir/build.make
Normal file
|
@ -0,0 +1,140 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.7
|
||||
|
||||
# Delete rule output on recipe failure.
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
|
||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
||||
SUFFIXES =
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
|
||||
# Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E remove -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/shadow8t4/Documents/CSCE441/L02
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/shadow8t4/Documents/CSCE441/L02/build
|
||||
|
||||
# Include any dependencies generated for this target.
|
||||
include CMakeFiles/L02.dir/depend.make
|
||||
|
||||
# Include the progress variables for this target.
|
||||
include CMakeFiles/L02.dir/progress.make
|
||||
|
||||
# Include the compile flags for this target's objects.
|
||||
include CMakeFiles/L02.dir/flags.make
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o: CMakeFiles/L02.dir/flags.make
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o: ../src/Image.cpp
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/L02.dir/src/Image.cpp.o"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/L02.dir/src/Image.cpp.o -c /home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.i: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/L02.dir/src/Image.cpp.i"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp > CMakeFiles/L02.dir/src/Image.cpp.i
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.s: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/L02.dir/src/Image.cpp.s"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp -o CMakeFiles/L02.dir/src/Image.cpp.s
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o.requires:
|
||||
|
||||
.PHONY : CMakeFiles/L02.dir/src/Image.cpp.o.requires
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o.provides: CMakeFiles/L02.dir/src/Image.cpp.o.requires
|
||||
$(MAKE) -f CMakeFiles/L02.dir/build.make CMakeFiles/L02.dir/src/Image.cpp.o.provides.build
|
||||
.PHONY : CMakeFiles/L02.dir/src/Image.cpp.o.provides
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o.provides.build: CMakeFiles/L02.dir/src/Image.cpp.o
|
||||
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.o: CMakeFiles/L02.dir/flags.make
|
||||
CMakeFiles/L02.dir/src/main.cpp.o: ../src/main.cpp
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/L02.dir/src/main.cpp.o"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/L02.dir/src/main.cpp.o -c /home/shadow8t4/Documents/CSCE441/L02/src/main.cpp
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.i: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/L02.dir/src/main.cpp.i"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/shadow8t4/Documents/CSCE441/L02/src/main.cpp > CMakeFiles/L02.dir/src/main.cpp.i
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.s: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/L02.dir/src/main.cpp.s"
|
||||
/usr/lib/hardening-wrapper/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/shadow8t4/Documents/CSCE441/L02/src/main.cpp -o CMakeFiles/L02.dir/src/main.cpp.s
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.o.requires:
|
||||
|
||||
.PHONY : CMakeFiles/L02.dir/src/main.cpp.o.requires
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.o.provides: CMakeFiles/L02.dir/src/main.cpp.o.requires
|
||||
$(MAKE) -f CMakeFiles/L02.dir/build.make CMakeFiles/L02.dir/src/main.cpp.o.provides.build
|
||||
.PHONY : CMakeFiles/L02.dir/src/main.cpp.o.provides
|
||||
|
||||
CMakeFiles/L02.dir/src/main.cpp.o.provides.build: CMakeFiles/L02.dir/src/main.cpp.o
|
||||
|
||||
|
||||
# Object files for target L02
|
||||
L02_OBJECTS = \
|
||||
"CMakeFiles/L02.dir/src/Image.cpp.o" \
|
||||
"CMakeFiles/L02.dir/src/main.cpp.o"
|
||||
|
||||
# External object files for target L02
|
||||
L02_EXTERNAL_OBJECTS =
|
||||
|
||||
L02: CMakeFiles/L02.dir/src/Image.cpp.o
|
||||
L02: CMakeFiles/L02.dir/src/main.cpp.o
|
||||
L02: CMakeFiles/L02.dir/build.make
|
||||
L02: CMakeFiles/L02.dir/link.txt
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Linking CXX executable L02"
|
||||
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/L02.dir/link.txt --verbose=$(VERBOSE)
|
||||
|
||||
# Rule to build all files generated by this target.
|
||||
CMakeFiles/L02.dir/build: L02
|
||||
|
||||
.PHONY : CMakeFiles/L02.dir/build
|
||||
|
||||
CMakeFiles/L02.dir/requires: CMakeFiles/L02.dir/src/Image.cpp.o.requires
|
||||
CMakeFiles/L02.dir/requires: CMakeFiles/L02.dir/src/main.cpp.o.requires
|
||||
|
||||
.PHONY : CMakeFiles/L02.dir/requires
|
||||
|
||||
CMakeFiles/L02.dir/clean:
|
||||
$(CMAKE_COMMAND) -P CMakeFiles/L02.dir/cmake_clean.cmake
|
||||
.PHONY : CMakeFiles/L02.dir/clean
|
||||
|
||||
CMakeFiles/L02.dir/depend:
|
||||
cd /home/shadow8t4/Documents/CSCE441/L02/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/shadow8t4/Documents/CSCE441/L02 /home/shadow8t4/Documents/CSCE441/L02 /home/shadow8t4/Documents/CSCE441/L02/build /home/shadow8t4/Documents/CSCE441/L02/build /home/shadow8t4/Documents/CSCE441/L02/build/CMakeFiles/L02.dir/DependInfo.cmake --color=$(COLOR)
|
||||
.PHONY : CMakeFiles/L02.dir/depend
|
||||
|
11
L02/CMakeFiles/L02.dir/cmake_clean.cmake
Normal file
11
L02/CMakeFiles/L02.dir/cmake_clean.cmake
Normal file
|
@ -0,0 +1,11 @@
|
|||
file(REMOVE_RECURSE
|
||||
"CMakeFiles/L02.dir/src/Image.cpp.o"
|
||||
"CMakeFiles/L02.dir/src/main.cpp.o"
|
||||
"L02.pdb"
|
||||
"L02"
|
||||
)
|
||||
|
||||
# Per-language clean rules from dependency scanning.
|
||||
foreach(lang CXX)
|
||||
include(CMakeFiles/L02.dir/cmake_clean_${lang}.cmake OPTIONAL)
|
||||
endforeach()
|
10
L02/CMakeFiles/L02.dir/depend.internal
Normal file
10
L02/CMakeFiles/L02.dir/depend.internal
Normal file
|
@ -0,0 +1,10 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.7
|
||||
|
||||
CMakeFiles/L02.dir/src/Image.cpp.o
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.cpp
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.h
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/stb_image_write.h
|
||||
CMakeFiles/L02.dir/src/main.cpp.o
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/Image.h
|
||||
/home/shadow8t4/Documents/CSCE441/L02/src/main.cpp
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue