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

SD2 -> SDL1

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