Skip to content

Commit

Permalink
Merge pull request #3 from RyanVreeke/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
RyanVreeke authored Jul 21, 2021
2 parents 53c3f44 + 788ff04 commit 48ad015
Show file tree
Hide file tree
Showing 86 changed files with 211 additions and 195 deletions.
5 changes: 4 additions & 1 deletion install-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# install-linux.sh is the installation script for TSGL on Linux.
# install-ubuntu.sh is the installation script for TSGL on Linux Ubuntu.
# Last updated: 06/30/26
#
# -SUBJECT TO CHANGE-
Expand Down Expand Up @@ -241,6 +241,9 @@ sudo rm -rf /usr/lib/libtsgl.*
#Create the following directories (Since they aren't included in github but are needed)
mkdir -p lib bin

#Make clean the library
sudo make clean

#Make the library
make prefix=$PREFIX

Expand Down
Binary file added pics/Car-colors.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Colorful-cars.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/HDR_landscape.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/Messier51.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/R8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/bestpicture.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/color_wheel_730.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/colorful-cars-circle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/colorfulKeyboard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/colorful_cars.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/cow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/ff0000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/launch.bmp
Binary file not shown.
Binary file added pics/lowDimImage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/ship.bmp
Binary file not shown.
Binary file added pics/shiprgb.bmp
Binary file not shown.
Binary file added pics/sky_main.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/spaghet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/spec1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 21 additions & 13 deletions src/TSGL/Canvas.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Canvas.h"
#include <stdlib.h>

// From stb_image.h:
// Do this:
Expand All @@ -16,7 +17,7 @@ namespace tsgl {

// Shader sources

static const GLchar* shapeVertexShader =
static const GLchar* shapeVertexShader =
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;"
"layout (location = 1) in vec4 aColor;"
Expand All @@ -37,7 +38,7 @@ static const GLchar* shapeFragmentShader =
"FragColor = color;"
"}";

static const GLchar* textVertexShader =
static const GLchar* textVertexShader =
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;"
"layout (location = 1) in vec2 aTexCoord;"
Expand All @@ -62,7 +63,7 @@ static const GLchar* textFragmentShader =
"FragColor = textColor * sampled;"
"}";

static const GLchar* textureVertexShader =
static const GLchar* textureVertexShader =
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;"
"layout (location = 1) in vec2 aTexCoord;"
Expand All @@ -75,7 +76,7 @@ static const GLchar* textureVertexShader =
"TexCoords = vec2(aTexCoord.x, aTexCoord.y);"
"}";

static const GLchar* textureFragmentShader =
static const GLchar* textureFragmentShader =
"#version 330 core\n"
"out vec4 FragColor;"
"in vec2 TexCoords;"
Expand Down Expand Up @@ -322,7 +323,7 @@ void Canvas::draw()
screenShot();
captureScreen = false;
}

// Update Screen
glfwSwapBuffers(window);

Expand Down Expand Up @@ -643,7 +644,7 @@ void Canvas::initGlew() {

textShader = new Shader(textVertexShader, textFragmentShader);

shapeShader = new Shader(shapeVertexShader, shapeFragmentShader);
shapeShader = new Shader(shapeVertexShader, shapeFragmentShader);

textureShader = new Shader(textureVertexShader, textureFragmentShader);

Expand Down Expand Up @@ -739,7 +740,7 @@ void Canvas::initWindow() {
screenBuffer[i] = 0;
}
screenBufferMutex.unlock();

// Get info of GPU and supported OpenGL version
// printf("Renderer: %s\n", glGetString(GL_RENDERER));
// printf("OpenGL version supported %s\n", glGetString(GL_VERSION));
Expand Down Expand Up @@ -789,8 +790,11 @@ void Canvas::pauseDrawing() {
* \details The function automatically terminates after num_frames cycles have completed.
* \param num_frames The number of frames to dump screenshots for.
*/
void Canvas::recordForNumFrames(unsigned int num_frames) {
void Canvas::recordForNumFrames(unsigned int num_frames, const std::string& newCapturePrefix) {
toRecord = num_frames;
if(newCapturePrefix != "") {
capturePrefix = newCapturePrefix;
}
}

/*!
Expand Down Expand Up @@ -945,8 +949,9 @@ void Canvas::run(void (*myFunction)(Canvas&, int, char**), int argc, char* argv[
}

void Canvas::screenShot() {
char filename[25];
sprintf(filename, "Image%06d.png", frameCounter); // TODO: Make this save somewhere not in root
char sufix[20];
sprintf(sufix, "%06d.png", frameCounter);
std::string filename = capturePrefix + sufix;

screenBufferMutex.lock();
// loader.saveImageToFile(filename, screenBuffer, framebufferWidth, winHeight);
Expand All @@ -959,7 +964,7 @@ void Canvas::screenShot() {
screenBuffer[s2] = tmp;
}
}
stbi_write_png(filename, framebufferWidth, framebufferHeight, 3, screenBuffer, 0);
stbi_write_png(filename.c_str(), framebufferWidth, framebufferHeight, 3, screenBuffer, 0);
screenBufferMutex.unlock();
}

Expand Down Expand Up @@ -1099,8 +1104,11 @@ void Canvas::stopRecording() {
* \details Images are saved as ImageXXXXXX.png, where XXXXXX is the current frame number.
* \bug Multiple calls to this function in rapid succession render the FPS counter inaccurate.
*/
void Canvas::takeScreenShot() {
void Canvas::takeScreenShot(const std::string& newCapturePrefix) {
if (toRecord == 0) toRecord = 1;
if(newCapturePrefix != "") {
capturePrefix = newCapturePrefix;
}
}

void Canvas::selectShaders(unsigned int sType) {
Expand Down Expand Up @@ -1140,7 +1148,7 @@ void Canvas::selectShaders(unsigned int sType) {
glVertexAttribPointer(texAttrib, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
program->use();
}

// Recompute the camera matrices
uniModel = glGetUniformLocation(program->ID, "model");
uniView = glGetUniformLocation(program->ID, "view");
Expand Down
15 changes: 8 additions & 7 deletions src/TSGL/Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class Canvas {
GLint framebufferHeight;
int frameCounter; // Counter for the number of frames that have elapsed in the current session (for animations)
bool isFinished; // If the rendering is done, which will signal the window to close
bool keyDown; // If a key is being pressed. Prevents an action from happening twice
bool keyDown;
std::string capturePrefix = "Image"; // If a key is being pressed. Prevents an action from happening twice
int monitorX, monitorY; // Monitor position for upper left corner
double mouseX, mouseY; // Location of the mouse once HandleIO() has been called
Background * myBackground; // Pointer to the Background drawn each frame
Expand Down Expand Up @@ -150,10 +151,10 @@ class Canvas {
static void errorCallback(int error, const char* string); // Display where an error is coming from
void glDestroy(); // Destroys the GL and GLFW things that are specific for this canvas
void init(int xx,int yy,int ww,int hh,
std::string title,
ColorFloat backgroundColor, Background * background,
std::string title,
ColorFloat backgroundColor, Background * background,
double timerLength); // Method for initializing the canvas
void initBackground(Background * background,
void initBackground(Background * background,
ColorFloat bgcolor); // Initializes myBackground
void initGl(); // Initializes the GL things specific to the Canvas
void initGlew(); // Initialized the GLEW things specific to the Canvas
Expand Down Expand Up @@ -231,7 +232,7 @@ class Canvas {

void pauseDrawing();

void recordForNumFrames(unsigned int num_frames);
void recordForNumFrames(unsigned int num_frames, const std::string& newCaputurePrefix = "");

void remove(Drawable * shapePtr);

Expand All @@ -246,7 +247,7 @@ class Canvas {
virtual void run(void (*myFunction)(Canvas&, unsigned), unsigned u);

virtual void run(void (*myFunction)(Canvas&, int, int), int i1, int i2);

virtual void run(void (*myFunction)(Canvas&, int, int, int), int i1, int i2, int i3);

virtual void run(void (*myFunction)(Canvas&, unsigned, unsigned), unsigned u1, unsigned u2);
Expand Down Expand Up @@ -279,7 +280,7 @@ class Canvas {

void stopRecording();

void takeScreenShot();
void takeScreenShot(const std::string& newCapturePrefix = "");

int wait();
};
Expand Down
6 changes: 3 additions & 3 deletions src/tests/test2Dvs3D/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/test3DRotation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testAlphaRectangle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testArrows/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testAura/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testBackground/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testBlurImage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testCalcPi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testCamera/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testCircle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testColorWheel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testConcavePolygon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
6 changes: 3 additions & 3 deletions src/tests/testCone/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ BREW := -lomp -I"$(brew --prefix libomp)/include"
endif

CXXFLAGS = -O3 -g3 -ggdb3 \
-I/usr/include/TSGL \
-I/usr/include/freetype2 \
-I$(TSGL_HOME)/include/TSGL \
-I$(TSGL_HOME)/include/freetype2 \

LFLAGS = -g -ltsgl -lfreetype -lGLEW -lglfw $(GL_FLAGS) -fopenmp \
$(BREW) -L/usr/lib \
$(BREW) -L$(TSGL_HOME)/lib \


# ****************************************************
Expand Down
Loading

0 comments on commit 48ad015

Please sign in to comment.