Categories
Web Development

Clear cache with Chrome

Go to chrome://net-internals/#dns and clear the browser DNS cache Hard reload while developer tools are open with right-click on the refresh button Clean the local DNS ipconfig /flushdns

Categories
C++

C++ – Singleton Implementation

C++ Singleton Implementation #pragma once //////////////////////////////////////////////////////////// #include <cassert> #ifdef __APPLE__ #define nullptr NULL #endif //////////////////////////////////////////////////////////// template <typename S> class Singleton { public: Singleton() { assert(!s_instance); s_instance = static_cast<S*>(this); } virtual ~Singleton() { assert(s_instance); s_instance = 0; } static S* Instance() { return s_instance; } private: static S* s_instance; }; template <typename S> S* Singleton<S>::s_instance = […]

Categories
C++

C++ – Why make the constructor Explicit

The compiler is allowed to make one implicit conversion to resolve the parameters to a function. What this means is that the compiler can use constructors callable with a single parameter to convert from one type to another in order to get the right type for a parameter. Here’s an example class with a constructor that can […]

Categories
C++

C++ in-class initialization

The two code snippets you posted are not quite equal. class Something { int m_a = 0; }; Here you specify the value with which to initialize, i.e. 0, at compile time. class Something { int m_a; Something(int p_a); }; Something::Something(int p_a):m_a(p_a){ … }; And here you do it at run time (or possibly at run time), with […]

Categories
Dekstop IDEs

Visual Studio – Working with Code

Alt+Enter or Ctrl+. for generating functions for example for declaration F12 go to definition Ctrl+K+O switch between header and source Ctrl+Space autocomplete Ctrl+- go back Ctrl+Shift+- go forward Ctrl+D duplicate line Shift+Del delete line and place it in the clipboard Ctrl+Shift+V clipboard with clipboard history in VS Alt+Up or Down move a code line

Categories
Dekstop IDEs

Visual Studio Back and forth

Use the Ctrl+Shift+- to move forward Ctrl+- to move back.

Categories
Game Development

libSDL – Drawing a BMP Image

#include <iostream> #include <SDL.h> const int WIDTH = 640, HEIGHT = 360; int main(int argc, char* argv[]) { SDL_Surface* imageSurface = NULL; SDL_Surface* windowSurface = NULL; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << “SDL could not initialize! SDL Error: ” << SDL_GetError() << std::endl; } SDL_Window* window = SDL_CreateWindow(“Hello SDL World”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, […]

Categories
Game Development

libSDL – Hello World

#include <iostream> #include <SDL.h> const int WIDTH = 800, HEIGHT = 600; int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window* window = SDL_CreateWindow(“Hello SDL World”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); // Check that the window was successfully created if (NULL == window) { // In the case that the window could not be made… std::cout […]

Categories
Game Development

Simplest libSDL example

Simplest libSDL example #include <iostream> #include <SDL.h> int main(int argc, char* argv[]) { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << “SDL could not initialise! SDL Error: ” << SDL_GetError() << std::endl; } return EXIT_SUCCESS; } See https://dangeorgiev.com/add-include-directories-and-libraries-to-visual-studio/  

Categories
Dekstop IDEs

Add Include Directories and Libraries to Visual Studio

To add Include paths and Libraries     To Link the Library This will fix these errors Copy DLL Files Add XCOPY “$(SolutionDir)SDL2-2.0.12\lib\x86\*.DLL” “$(TargetDir)” /D /K /Y To