aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-11-02 08:52:36 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-11-02 08:52:36 -0500
commit07d73ea992641198a887f000bf44b874c8e11574 (patch)
treea0d3e80548d4528ae7bf27561d5c94d3a55561f0
parent822d9d5b5ef34c3ec2b5ebaded5744bdba8bade1 (diff)
parentdcefab4d5e9d9cff3bfbc65e45fae9309d426a69 (diff)
Added new project for lighting test
-rw-r--r--Makefile5
-rw-r--r--freetype6.dllbin0 -> 522240 bytes
-rw-r--r--glew32.dllbin0 -> 403968 bytes
-rw-r--r--include/common.h9
-rw-r--r--main.cpp21
5 files changed, 32 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 8ac3b3d..bbeff1e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
LIBS = -lGL -lGLEW -lSDL2main -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
+WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
+
FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2
all:
@@ -8,6 +10,9 @@ all:
@echo " CXX main.cpp"
@g++ $(FLAGS) -o main main.cpp out/*.o $(LIBS)
+win32:
+ @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS)
+
clean:
@echo " RM main"
@-rm -f main
diff --git a/freetype6.dll b/freetype6.dll
new file mode 100644
index 0000000..e35edc6
--- /dev/null
+++ b/freetype6.dll
Binary files differ
diff --git a/glew32.dll b/glew32.dll
new file mode 100644
index 0000000..c9414c2
--- /dev/null
+++ b/glew32.dll
Binary files differ
diff --git a/include/common.h b/include/common.h
index 0e4373b..b0ffec7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -14,6 +14,7 @@
* Include GLEW and the SDL 2 headers
*/
+#define GLEW_STATIC
#include <GL/glew.h>
#include <SDL2/SDL.h>
@@ -23,6 +24,12 @@
#include <string>
#include <fstream>
+
+#ifdef __WIN32__
+typedef unsigned int uint;
+#undef near
+#endif
+
/*
* Include file headers
*/
@@ -32,7 +39,7 @@
* This flag lets the compiler know that we are using shaders
*/
- #define SHADERS
+ #define SHADERSere
/*
* Create a basic 2-point structure for coordinate saving
diff --git a/main.cpp b/main.cpp
index 848d80f..e0d195f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -199,10 +199,15 @@ vec2 offset;
* of milliseconds that have passed sine the epoch.
*
*/
+
+#ifdef __WIN32__
+#define millis() SDL_GetTicks()
+#else
unsigned int millis(void){
std::chrono::system_clock::time_point now=std::chrono::system_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
}
+#endif
typedef enum {
SUNNY = 0,
@@ -237,10 +242,10 @@ int main(int argc, char *argv[]){
// Run SDL_Quit when main returns
atexit(SDL_Quit);
- /*Untitled
+ /*
* (Attempt to) Initialize SDL_image libraries with IMG_INIT_PNG so that we can load PNG
* textures for the entities and stuff.
- * Untitled
+ *
*/
if(!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){
@@ -313,7 +318,9 @@ int main(int argc, char *argv[]){
*/
GLenum err;
+#ifndef __WIN32__
glewExperimental = GL_TRUE;
+#endif
if((err=glewInit()) != GLEW_OK){
std::cout << "GLEW was not able to initialize! Error: " << glewGetErrorString(err) << std::endl;
return -1;
@@ -724,10 +731,18 @@ void render(){
*/
player->near=true; // Draw the player's name
+
+ #ifdef SHADERS
+ glUseProgramObjectARB(shaderProgram);
+ glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 0,100);
+ glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 255,255,255);
+ //glBlendFunc(GL_ONE, GL_ONE);
+ #endif //SHADERS
currentWorld->draw(player);
#ifdef SHADERS
+<<<<<<< Updated upstream
glUseProgramObjectARB(shaderProgram);
glUniform2f(glGetUniformLocation(shaderProgram, "lightLocation"), 640,100);
glUniform3f(glGetUniformLocation(shaderProgram, "lightColor"), 1,1,1);
@@ -740,6 +755,8 @@ void render(){
glRectf(offset.x-SCREEN_WIDTH/2,0,offset.x+SCREEN_WIDTH/2,SCREEN_HEIGHT);
#ifdef SHADERS
+=======
+>>>>>>> Stashed changes
glUseProgramObjectARB(0);
#endif //SHADERS