I've been switching libraries and linking on this, finding that it needed 64 bit libraries to run and not 32 bit, but now that I changed that, The program is stopping entirely and simply saying that it was unable to start correctly.
I'll include whatever code I can without cluttering the screen too much, and link the tutorial I'm following. Just so you know so you don't have to watch the whole thing, the project has been going fine until I had to link SDL image libraries. Link to tutorial:
https://youtu.be/YrWQsuDT3NE
I really quickly want to clarify that no error code was returned in the compiler, running the program just brings up a pop-up saying it was unable to start correctly.
------------------------------------------
Main.cpp :
#include "Game.h"
Game *game = nullptr;
int main(int argc, char *argv[])
{
game = new Game();
game->init("GameWindow", 800, 600, false);
while (game->running())
{
game->handleEvents();
game->update();
game->render();
}
game->clean();
return 0;
}
-----------------------------------------------------
Game.h :
#pragma once
#include "SDL.h"
#include "SDL_image.h"
#include <iostream>
class Game
{
public:
Game();
~Game();
void init(const char* title, int width, int height, bool fullscreen);
void handleEvents();
void update();
bool running() { return isRunning; }
void render();
void clean();
private:
bool isRunning = false;
int cnt = 0;
SDL_Window *window;
SDL_Renderer *renderer;
};
---------------------------------------------------------------------------
Game.cpp :
#include "Game.h"
SDL_Texture* playerTex;
Game::Game()
{}
Game::~Game()
{}
void Game::init(const char* title, int width, int height, bool fullscreen)
{
int flags = 0;
if (fullscreen)
{
flags = SDL_WINDOW_FULLSCREEN;
}
if (SDL_Init(SDL_INIT_EVERYTHING) == 0)
{
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags);
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer)
{
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
}
isRunning = true;
}
SDL_Surface* tmpSurface = IMG_Load("assets/Player.png");
playerTex = SDL_CreateTextureFromSurface(renderer, tmpSurface);
SDL_FreeSurface(tmpSurface);
}
void Game::handleEvents()
{
SDL_Event event;
SDL_PollEvent(&event);
switch (event.type)
{
case SDL_QUIT :
isRunning = false;
break;
default:
break;
}
}
void Game::update()
{
cnt++;
std::cout << cnt << std::endl;
}
void Game::render()
{
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, playerTex, NULL, NULL);
SDL_RenderPresent(renderer);
}
void Game::clean()
{
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_Quit();
}