LIBS = -lGL\r
WIN_LIBS = -lopengl32 -lmingw32\r
\r
-FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2 -lSDL2main -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer\r
+FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2 -lGL -lGLEW -lSDL2main -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer\r
\r
-all:
- @rm -f out/*.o
+all:\r
+ @rm -f out/*.o\r
@cd src; $(MAKE) $(MFLAGS)\r
@echo " CXX main.cpp"\r
@g++ $(FLAGS) -o main main.cpp out/*.o $(LIBS)\r
#include <math.h>
#include <cstdlib>
#include <SDL2/SDL.h>
+#include <GL/glew.h>
+#include <SDL2/SDL_opengl.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
-#include <SDL2/SDL_opengl.h>
typedef struct { float x; float y; }vec2;
<<<<<<< HEAD
|->1 Rabbit
**/
-=======
-|->1 Skirl
-**/
->>>>>>> 58716d5e4f20eb5a30025c88fe5119a0e40c4187
int main(int argc, char *argv[]){
// Initialize SDL
+ if(glewInit() < 0){
+ std::cout << "GLEW was not able to initialize! Error: " << std::endl;
+ return -1;
+ }
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0){
std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
return -1;
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
SDL_ShowCursor(SDL_DISABLE); // Hide mouse cursor so we can draw our own
+ /**
+ * SHADERS
+ **/
+
+ /*GLuint fragShader;
+ GLuint shaderProgram;
+
+ const GLchar *shaderSource = "shader.frag";
+ GLint bufferln = GL_FALSE;
+
+ shaderProgram = glCreateProgram();
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderSource(fragShader, 1, &shaderSource, NULL);
+ glCompileShader(fragShader);
+ glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bufferln);
+ if (bufferln == GL_TRUE){
+ std::cout << "Error compiling shader" << std::endl;
+ }
+ glAttachShader(shaderProgram, fragShader);
+ glLinkProgram(shaderProgram);
+ glValidateProgram(shaderProgram);
+
+ //glEnable(GL_DEPTH_TEST);
+ //glEnable(GL_MULTISAMPLE);*/
+
names = fopen("assets/names_en-us", "r+"); // Open the names file
initEverything(); // Run world maker thing in src/gameplay.cpp
--- /dev/null
+#version 140\r
+\r
+uniform vec2 lightLocation;\r
+uniform vec3 lightColor;\r
+uniform float screenHeight;\r
+\r
+void main(){\r
+ float distance = length(lightLocation - gl_FragCoord.xy);\r
+ float attenuation = 1.0 / distance;\r
+ vec4 color = vec4(attenuation, attenuation, attenuation, pow(attenuation, 3)) * vec4(lightColor, 1);\r
+ \r
+ gl_FragColor = color;\r
+}
\ No newline at end of file
texState-=1;
if(texState==0)up=true;
}
- }if(ground == 0){
- glBindTexture(GL_TEXTURE_2D, texture[1]);
}
- else if(vel.x != 0){
+ if(ground == 0){
+ glBindTexture(GL_TEXTURE_2D, texture[1]);
+ }else if(vel.x != 0){
switch(texState){
case 0:
glBindTexture(GL_TEXTURE_2D,texture[1]);
ui::setFontSize(16);
ui::putText(((SCREEN_WIDTH / 2 ) + loc.x) - 125, SCREEN_HEIGHT - ui::fontSize, "Health: %d/%d",health,maxHealth);
glColor3ub(255,0,0);
- glRectf((SCREEN_WIDTH / 2 + loc.x) - 125, SCREEN_HEIGHT - 32, ((SCREEN_WIDTH / 2 + loc.x) - 125) + (int)((int)(health / maxHealth) * 100), SCREEN_HEIGHT - 32 + 12);
+ glRectf((SCREEN_WIDTH / 2 + loc.x) - 125, SCREEN_HEIGHT - 32, ((SCREEN_WIDTH / 2 + loc.x) - 125) + (((float)health / (float)maxHealth) * 100), SCREEN_HEIGHT - 32 + 12);
}
if(near){
ui::setFontSize(14);
abort();
}
// Load the bitmap with OpenGL
- glActiveTexture(GL_TEXTURE0);
+ //glActiveTexture(GL_TEXTURE0);
glGenTextures(1,&ftex);
glBindTexture(GL_TEXTURE_2D,ftex);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);