Skip to content

Commit

Permalink
Fixes for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
daw42 committed May 3, 2018
1 parent ed7488f commit 3d23376
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ set (CMAKE_CXX_STANDARD 11)

project (GLSLCOOKBOOK)

if(MSVC)
add_definitions(/DNOMINMAX)
endif()

find_package( glm CONFIG REQUIRED )
find_package( glfw3 CONFIG REQUIRED )
find_package( OpenGL REQUIRED )
Expand Down
2 changes: 2 additions & 0 deletions chapter01/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "scenebasic_uniform.h"
#include "scenebasic_uniformblock.h"

#include <memory>

static std::map< std::string, std::string > sceneData = {
{"basic", "Basic scene."},
{"basic-attrib", "Prints active attributes."},
Expand Down
2 changes: 1 addition & 1 deletion chapter07/frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void Frustum::render() const

void Frustum::deleteBuffers() {
if( ! buffers.empty() ) {
glDeleteBuffers( buffers.size(), buffers.data() );
glDeleteBuffers( (GLsizei)buffers.size(), buffers.data() );
buffers.clear();
}

Expand Down
2 changes: 2 additions & 0 deletions chapter08/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "scenewood.h"
#include "scenenoise.h"

#include <memory>

std::map<std::string, std::string> sceneInfo = {
{ "noise", "just display the raw noise texture" },
{ "decay", "decay of a teapot" },
Expand Down
2 changes: 2 additions & 0 deletions chapter09/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "scenesmoke.h"
#include "scenewave.h"

#include <memory>

std::map<std::string, std::string> sceneInfo = {
{ "fire", "particles simulating fire" },
{ "particles", "a fountain of particles" },
Expand Down
2 changes: 2 additions & 0 deletions chapter10/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "sceneparticles.h"
#include "sceneedge.h"

#include <memory>

std::map<std::string, std::string> sceneInfo = {
{ "particles", "Simple particle simulation" },
{ "mandelbrot", "Mandelbrot set with compute shader" },
Expand Down
2 changes: 1 addition & 1 deletion ingredients/glslprogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void GLSLProgram::findUniformLocations() {

GLenum properties[] = {GL_NAME_LENGTH, GL_TYPE, GL_LOCATION, GL_BLOCK_INDEX};

for( GLuint i = 0; i < numUniforms; ++i ) {
for( GLint i = 0; i < numUniforms; ++i ) {
GLint results[4];
glGetProgramResourceiv(handle, GL_UNIFORM, i, 4, properties, 4, NULL, results);

Expand Down
4 changes: 2 additions & 2 deletions ingredients/objmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ void ObjMesh::ObjMeshData::toGlMesh(GlMeshData & data) {
data.tangents.push_back( tang.w );
}

data.faces.push_back(vIdx);
vertexMap[vertStr] = vIdx;
data.faces.push_back((GLuint)vIdx);
vertexMap[vertStr] = (GLuint)vIdx;
} else {
data.faces.push_back(it->second);
}
Expand Down
1 change: 1 addition & 0 deletions ingredients/objmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>
#include <glm/glm.hpp>
#include <string>
#include <memory>

class ObjMesh : public TriangleMesh {
private:
Expand Down
6 changes: 3 additions & 3 deletions ingredients/torus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Torus::Torus(GLfloat outerRadius, GLfloat innerRadius, GLuint nsides, GLuint nri
float ringFactor = glm::two_pi<float>() / nrings;
float sideFactor = glm::two_pi<float>() / nsides;
int idx = 0, tidx = 0;
for( int ring = 0; ring <= nrings; ring++ ) {
for( GLuint ring = 0; ring <= nrings; ring++ ) {
float u = ring * ringFactor;
float cu = cos(u);
float su = sin(u);
for( int side = 0; side < nsides; side++ ) {
for( GLuint side = 0; side < nsides; side++ ) {
float v = side * sideFactor;
float cv = cos(v);
float sv = sin(v);
Expand Down Expand Up @@ -55,7 +55,7 @@ Torus::Torus(GLfloat outerRadius, GLfloat innerRadius, GLuint nsides, GLuint nri
for( GLuint ring = 0; ring < nrings; ring++ ) {
GLuint ringStart = ring * nsides;
GLuint nextRingStart = (ring + 1) * nsides;
for( int side = 0; side < nsides; side++ ) {
for( GLuint side = 0; side < nsides; side++ ) {
int nextSide = (side+1) % nsides;
// The quad
el[idx] = (ringStart + side);
Expand Down
4 changes: 2 additions & 2 deletions ingredients/trianglemesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void TriangleMesh::initBuffers(
if( indices == nullptr || points == nullptr || normals == nullptr )
return;

nVerts = indices->size();
nVerts = (GLuint)indices->size();

GLuint indexBuf = 0, posBuf = 0, normBuf = 0, tcBuf = 0, tangentBuf = 0;
glGenBuffers(1, &indexBuf);
Expand Down Expand Up @@ -89,7 +89,7 @@ TriangleMesh::~TriangleMesh() {

void TriangleMesh::deleteBuffers() {
if( buffers.size() > 0 ) {
glDeleteBuffers( buffers.size(), buffers.data() );
glDeleteBuffers( (GLsizei)buffers.size(), buffers.data() );
buffers.clear();
}

Expand Down

0 comments on commit 3d23376

Please sign in to comment.