Commit 6d429186 authored by Nicolas LIENART's avatar Nicolas LIENART

SD2 -> SDL1

parent 43998f42
...@@ -51,10 +51,10 @@ else() ...@@ -51,10 +51,10 @@ else()
target_link_libraries( target_link_libraries(
${PROJECT_NAME} ${PROJECT_NAME}
m m
SDL2 SDL
SDL2_image SDL_image
SDL2_mixer SDL_mixer
SDL2_ttf SDL_ttf
GL GL
GLU GLU
) )
......
...@@ -8,12 +8,13 @@ void sdlConfig_initSDL() { ...@@ -8,12 +8,13 @@ void sdlConfig_initSDL() {
} }
} }
void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned int width, unsigned int height) void sdlConfig_reshape(SDL_Surface** surface, unsigned int width, unsigned int height)
{ {
SDL_Window* surface_temp = SDL_CreateWindow(WINDOW_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL); SDL_Surface* surface_temp = SDL_SetVideoMode(width, height, 8, SDL_OPENGL);
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
if(NULL == surface_temp) if(NULL == surface_temp)
{ {
fprintf( stderr, "Erreur lors du redimensionnement de la fenetre.\n"); fprintf( stderr, "Erreur lors du redimensionnement de la fenetre.\n");
...@@ -21,12 +22,13 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned ...@@ -21,12 +22,13 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned
} }
*surface = surface_temp; *surface = surface_temp;
int window_width, window_height; /*
SDL_GetWindowSize(*surface, &window_width, &window_height);
if (*GLcontext == NULL) { if (*GLcontext == NULL) {
*GLcontext = SDL_GL_CreateContext(*surface); *GLcontext = SDL_GL_CreateContext(*surface);
} }
*/
SDL_WM_SetCaption(WINDOW_TITLE, NULL);
#ifdef _WIN32 #ifdef _WIN32
if(glewInit() != 0) if(glewInit() != 0)
...@@ -36,8 +38,8 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned ...@@ -36,8 +38,8 @@ void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned
} }
#endif #endif
glViewport(0, 0, window_width, window_height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluOrtho2D(1, window_width, window_height, 1); gluOrtho2D(1, width, height, 1);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include "cases.h" #include "cases.h"
#include "structures.h" #include "structures.h"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
/* Dimensions initiales et titre de la fenetre */ /* Dimensions initiales et titre de la fenetre */
static const unsigned int WINDOW_WIDTH = 800; static const unsigned int WINDOW_WIDTH = 800;
static const unsigned int WINDOW_HEIGHT = 800; static const unsigned int WINDOW_HEIGHT = 800;
static const char WINDOW_TITLE[] = "test"; static const char WINDOW_TITLE[] = "Insect Tower";
/* Espace fenetre virtuelle */ /* Espace fenetre virtuelle */
static const float GL_VIEW_WIDTH = 200.; static const float GL_VIEW_WIDTH = 200.;
...@@ -32,6 +32,6 @@ static const unsigned int BIT_PER_PIXEL = 32; ...@@ -32,6 +32,6 @@ static const unsigned int BIT_PER_PIXEL = 32;
static const Uint32 FRAMERATE_MILLISECONDS = 1000 / 60; static const Uint32 FRAMERATE_MILLISECONDS = 1000 / 60;
void sdlConfig_initSDL(); void sdlConfig_initSDL();
void sdlConfig_reshape(SDL_Window** surface, SDL_GLContext *GLcontext, unsigned int width, unsigned int height); void sdlConfig_reshape(SDL_Surface** surface, unsigned int width, unsigned int height);
#endif //SDLCONFIG_H_ #endif //SDLCONFIG_H_
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include <SDL2/SDL_image.h> #include <SDL/SDL_image.h>
#include <SDL2/SDL_ttf.h> #include <SDL/SDL_ttf.h>
#ifdef _WIN32 #ifdef _WIN32
#include <GL/glew.h> #include <GL/glew.h>
...@@ -42,9 +42,8 @@ int main(int argc, char *argv[]) ...@@ -42,9 +42,8 @@ int main(int argc, char *argv[])
/* Définition de l'environnement SDL*/ /* Définition de l'environnement SDL*/
sdlConfig_initSDL(); sdlConfig_initSDL();
SDL_Window* surface; SDL_Surface* surface;
SDL_GLContext GLcontext = NULL; sdlConfig_reshape(&surface, WINDOW_WIDTH, WINDOW_HEIGHT);
sdlConfig_reshape(&surface, &GLcontext, WINDOW_WIDTH, WINDOW_HEIGHT);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
...@@ -95,7 +94,7 @@ int main(int argc, char *argv[]) ...@@ -95,7 +94,7 @@ int main(int argc, char *argv[])
display_showCursor(); display_showCursor();
/* Echange du front et du back buffer : mise a jour de la fenetre */ /* Echange du front et du back buffer : mise a jour de la fenetre */
SDL_GL_SwapWindow(surface); SDL_GL_SwapBuffers();
SDL_Event e; SDL_Event e;
while(SDL_PollEvent(&e)) { while(SDL_PollEvent(&e)) {
...@@ -124,12 +123,6 @@ int main(int argc, char *argv[]) ...@@ -124,12 +123,6 @@ int main(int argc, char *argv[])
mouse_handleClick(); mouse_handleClick();
break; break;
case SDL_WINDOWEVENT:
if (e.window.event == SDL_WINDOWEVENT_RESIZED) {
sdlConfig_reshape(&surface, &GLcontext, e.window.data1, e.window.data2);
}
break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
keyboard_handleKeypress(&e); keyboard_handleKeypress(&e);
default: default:
...@@ -157,6 +150,7 @@ int main(int argc, char *argv[]) ...@@ -157,6 +150,7 @@ int main(int argc, char *argv[])
} }
/* Liberation des ressources associees a la SDL */ /* Liberation des ressources associees a la SDL */
SDL_FreeSurface(surface);
Mix_CloseAudio(); Mix_CloseAudio();
SDL_Quit(); SDL_Quit();
return EXIT_SUCCESS; return EXIT_SUCCESS;
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <SDL2/SDL_ttf.h> #include <SDL/SDL_ttf.h>
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include "gui.h" #include "gui.h"
#include "structures.h" #include "structures.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
void keyboard_handleKeypress(SDL_Event *event) void keyboard_handleKeypress(SDL_Event *event)
{ {
SDL_Keycode key = event->key.keysym.sym; SDLKey key = event->key.keysym.sym;
if(gameData->gameState == LEVELPLAY) { if(gameData->gameState == LEVELPLAY) {
Etat *joueur = plateau->joueur; Etat *joueur = plateau->joueur;
......
#ifndef KEYBAORD_H_ #ifndef KEYBAORD_H_
#define KEYBAORD_H_ #define KEYBAORD_H_
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include "structures.h" #include "structures.h"
#include "player.h" #include "player.h"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include "structures.h" #include "structures.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include "structures.h" #include "structures.h"
#include "cases.h" #include "cases.h"
......
#ifndef PROJECTILE_H_ #ifndef PROJECTILE_H_
#define PROJECTILE_H_ #define PROJECTILE_H_
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include "structures.h" #include "structures.h"
#include "monster.h" #include "monster.h"
......
#ifndef SOUND_H_ #ifndef SOUND_H_
#define SOUND_H_ #define SOUND_H_
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include <stdio.h> #include <stdio.h>
#include "structures.h" #include "structures.h"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <SDL2/SDL_image.h> #include <SDL/SDL_image.h>
#include <string.h> #include <string.h>
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include <SDL2/SDL_ttf.h> #include <SDL/SDL_ttf.h>
typedef enum MapDataContent { typedef enum MapDataContent {
MDATA_IMG = 1, MDATA_IMG = 1,
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
#define TOUR_H_ #define TOUR_H_
#pragma once #pragma once
#include <SDL2/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <SDL2/SDL.h> #include <SDL/SDL.h>
#include "structures.h" #include "structures.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment