Thursday, December 15, 2016

SDL2

cmake_minimum_required(VERSION 3.6)
project(sdl_test)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmingw32")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories(${PROJECT_SOURCE_DIR}/lib)

set(SOURCE_FILES main.cpp)
add_executable(sdl_test ${SOURCE_FILES})

target_link_libraries(sdl_test SDL2main SDL2)

------------------------------------------------------------------------------------------------------------

#include "include/SDL.h"

int main(int argc, char* argv[]) {
    // Start SDL2
    SDL_Init(SDL_INIT_EVERYTHING);

    // Create a Window in the middle of the screen
    SDL_Window *window = 0;

    window = SDL_CreateWindow("Hello xxxWorld!",
                              SDL_WINDOWPOS_CENTERED,
                              SDL_WINDOWPOS_CENTERED,
                              640, 480,
                              SDL_WINDOW_SHOWN);

    // Delay so that we can see the window appear
    SDL_Delay(2000);

    // Cleanup and Quit
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}

Clion + SDL2

SDL2
https://www.libsdl.org/

Files:
https://github.com/tcbrindle/sdl2-cmake-scripts

CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(sdl_test)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp)
add_executable(sdl_test ${SOURCE_FILES})


# SDL2
set(SDL2_PATH "C:\\SDL2-2.0.5\\x86_64-w64-mingw32")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sdl_test_SOURCE_DIR}/cmake")

find_package(SDL2 REQUIRED)
find_package(SDL2_Image REQUIRED)
find_package(SDL2_ttf REQUIRED)

include_directories(${SDL2_INCLUDE_DIR}
                    ${SDL2_IMAGE_INCLUDE_DIR}
                    ${SDL2_TTF_INCLUDE_DIR})

target_link_libraries(sdl_test ${SDL2_LIBRARY}
                             ${SDL2_IMAGE_LIBRARIES}
                             ${SDL2_TTF_LIBRARIES})


main.cpp
#include <SDL.h>

int main(int argc, char* argv[]) {
    // Start SDL2
    SDL_Init(SDL_INIT_EVERYTHING);

    // Create a Window in the middle of the screen
    SDL_Window *window = 0;

    window = SDL_CreateWindow("Hello World!",
                              SDL_WINDOWPOS_CENTERED,
                              SDL_WINDOWPOS_CENTERED,
                              640, 480,
                              SDL_WINDOW_SHOWN);

    // Delay so that we can see the window appear
    SDL_Delay(2000);

    // Cleanup and Quit
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}

Friday, December 2, 2016

Wednesday, November 2, 2016

HUD!




















main.cpp
-----------------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include "FuelBar.h"


using namespace sf;

int main()
{
    RenderWindow window(VideoMode(270, 480), "HUD!", Style::Close);
   
    //////////////////////////////////////////////
    FuelBar mFuelBar;
    mFuelBar.setPos(20.f, 300.f);
   
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
        }

        window.clear();

        /////////////////////////////////////////////
        for (Sprite n : mFuelBar.get()) {
            window.draw(n);
        }

        window.display();
    }

    return 0;
}

BarBackground.cpp
--------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include <string>
#include "BarBackground.h"


BarBackground::BarBackground(string fileName)
{
    mTex.loadFromFile(fileName);
    mSpr.setTexture(mTex);
    mSpr.setPosition(0, 0);
}


BarBackground::~BarBackground()
{
}

void BarBackground::setPos(float x, float y)
{
    mSpr.setPosition(x, y);
}

Sprite& BarBackground::get()
{
   
    return mSpr;
}

BarBackground.h
-----------------------------------------------------------------------------
#pragma once

using namespace std;
using namespace sf;

class BarBackground
{
public:
    BarBackground(string);
    ~BarBackground();

    void setPos(float, float);
    Sprite& get();

private:
    Texture mTex;
    Sprite mSpr;
};

BarIcon.cpp
-------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include <string>
#include "BarIcon.h"


BarIcon::BarIcon(string fileName)
{
    mTex.loadFromFile(fileName);
    mSpr.setTexture(mTex);
    mSpr.setPosition(0, 0);
}


BarIcon::~BarIcon()
{
}

void BarIcon::setPos(float x, float y)
{
    mSpr.setPosition(x, y);
}

Sprite& BarIcon::get()
{

    return mSpr;
}








BarIcon.h
-------------------------------------------------------------------
#pragma once

using namespace std;
using namespace sf;

class BarIcon
{
public:
    BarIcon(string);
    ~BarIcon();

    void setPos(float, float);
    Sprite& get();

private:
    Texture mTex;
    Sprite mSpr;
};

BarFuel.cpp
--------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include "FuelBar.h"
#include <string>


FuelBar::FuelBar() : mBarBackground("graphics/hud.png"), mBarIcon("graphics/fuel.png")
{
    fuel = 100.f;

}


FuelBar::~FuelBar()
{
}

void FuelBar::setPos(float x, float y)
{
    // Background
    mBarBackground.setPos(x, y);

    // Status


    // lIcon
    mBarIcon.setPos(x + 5, y + 5);
}

vector<Sprite>& FuelBar::get()
{

    mFuelSprites.push_back(mBarBackground.get());
    mFuelSprites.push_back(mBarIcon.get());

    return mFuelSprites;
       
}

void FuelBar::updateFuelBar()
{

}

BarFuel.h
-----------------------------------------------------------------------------
#include "BarBackground.h"
#include "BarIcon.h"
#pragma once


using namespace std;
using namespace sf;

class FuelBar
{
public:
    FuelBar();
    ~FuelBar();

    void setPos(float, float);
    vector<Sprite>& get();

    void updateFuelBar();

private:
    float fuel;
    vector<Sprite> mFuelSprites;

    BarBackground mBarBackground;
    BarIcon mBarIcon;

};



Friday, October 28, 2016

xcars first test


Wednesday, October 12, 2016

VS Code + SFML

VS Code
https://code.visualstudio.com

c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Linux",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Win32",
            "includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
            "C:/SFML-2.4.1/include",
            "C:/mingw32/include"
            ],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        }
    ]
}

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "args": [
                "-g", "-o", "main.exe",
                "-std=c++11",
                "main.cpp",
                "-IC:/SFML-2.4.1/include",
                "-LC:/SFML-2.4.1/lib",
                "-lsfml-graphics-d",
                "-lsfml-window-d",
                "-lsfml-system-d"
            ],
    "showOutput": "always"
}

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/main.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "c:/mingw32/bin/gdb.exe"
            }
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceRoot}/main.exe",
            "processId": "${command.pickProcess}",
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}


Tuesday, October 11, 2016

Atom + SFML


Atom
https://atom.io/

Packages:
minimap
minimap-hightlight-selected
hightlight-selected
hightlight-line
find-and-replace
file-icons


linter-gcc

GCC Include path: C:/mingw64/include, C:/SFML-2.4.0/include

gpp-compiler
C++ Compiler options: -IC:/SFML-2.4.0/include -LC:/SFML-2.4.0/lib -lsfml-graphics -lsfml-window -lsfml-system


atom-beautify
C,C++: clang-format

(win7x64, x32: mingw64 - 6.1, clang - 3.9, sfml - 2.4).

Saturday, July 2, 2016

LinuxMint 18

Qt 5.7
--------------
hxxps://www.qt.io

sudo apt-get install build-essential libgl1-mesa-dev

sudo apt-get install cmake

sudo apt-get install valgrind 

..download
chmod +x qt-linux-opensource-XXX-x86-offline.run
./qt-linux-opensource-XXX-x86-offline.run 

Clang 3.8
-----------
hxxp://llvm.org

ppa: deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main
 
key: wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
 
sudo apt-get install clang-3.8 clang-3.8-doc libclang-common-3.8-dev 
libclang-3.8-dev libclang1-3.8 libclang1-3.8-dbg libllvm-3.8-ocaml-dev 
libllvm3.8 libllvm3.8-dbg lldb-3.8 llvm-3.8 llvm-3.8-dev llvm-3.8-doc 
llvm-3.8-examples llvm-3.8-runtime clang-format-3.8 python-clang-3.8 
lldb-3.8-dev liblldb-3.8-dbg 
 
sudo apt-get install clang 
 
BOOST
----------- 
hxxp://www.boost.org


sudo apt-get install libboost-all-dev 

 
Clion SFML
-----------

cmake_minimum_required(VERSION 3.5)
project(untitled)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# Define sources and executable
set(EXECUTABLE_NAME "untitled")
add_executable(${EXECUTABLE_NAME} main.cpp)

# Detect and add SFML
set(CMAKE_MODULE_PATH "/usr/share/SFML/cmake/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2 REQUIRED system window graphics network audio)
if(SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
endif() 

Tuesday, April 26, 2016

Ubuntu 16.04 LTS

Ubuntu 16.04 LTS
----------------
sudo apt-get install build-essential libgl1-mesa-dev

Qt, Clion, ...

SFML 2.3.2
----------------
sudo apt-get install libsfml-dev

test code: hxxp://www.sfml-dev.org/tutorials/2.3/start-linux.php

g++ -std=c++11 -c main.cpp

g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

./sfml-app

GLFW 3.1.2
----------------
sudo apt-get install libglfw3-dev

test code: hxxp://www.glfw.org/docs/latest/quick.html

g++ -std=c++11 -c main.cpp

g++ main.o -o glfw-app -lGL -lGLU -lglfw -lX11 -lXxf86vm -lXrandr -lpthread -lXi
?(-lXinerama -lXcursor -ldl)

./glfw-app

Friday, March 4, 2016

CLion + SFML (+ MSYS2)



SFML 2.3.2 (GCC 4.9.2 MinGW (DW2) - 32-bit)

///////////////////////////////////////////////////////
///if with MSYS22
/////////////////////////////////////////////////////// 
Install MSYS2.
it’s installed in C:\msys64 on 64-bit systems 
 
C:\> SET LIBRARY_PATH=C:\msys64\mingw64\lib
C:\> SET PATH=%PATH%;C:\msys64\mingw64\bin 
C:\> SET INCLUDE=C:\msys64\mingw64\include  
 
pacman -S mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-sfml


main.cpp (test)
#include <SFML/Graphics.hpp> 
 
int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Application"); 
    sf::CircleShape shape; 
    shape.setRadius(40.f); 
    shape.setPosition(100.f, 100.f); 
    shape.setFillColor(sf::Color::Cyan); 
    while (window.isOpen())
    {
        sf::Event event; 
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close(); 
        }
         window.clear(); 
         window.draw(shape); 
         window.display(); 
    }
}


CMakeLists.txt

cmake_minimum_required(VERSION 3.14)
project(untitled10)

set(CMAKE_CXX_STANDARD 11)

set(EXECUTABLE_NAME "untitled10")
add_executable(${EXECUTABLE_NAME} main.cpp)

find_package(SFML 2 COMPONENTS system window graphics network audio)

target_link_libraries(${EXECUTABLE_NAME}         
libsfml-audio 
libsfml-graphics 
libsfml-network 
libsfml-system 
libsfml-window  
 
 

Monday, January 11, 2016

Linux + Clion + GLFW


underconstraction
 
Lenovo G510
(uefi, wi-fi, ati)
Linux Mint 17.3 Mate
GCC 4.9.3
Clang 3.7
CMake 3.4.1
GLFW 3.1.2
GLEW 1.13
GLM 0.9.7.2
CLion 1.2.4
Assimp 3.1.1
SOIL

CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(untitled3)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")

set(CMAKE_MODULE_PATH /usr/local/lib/cmake /usr/local/lib/x86_64-linux-gnu/cmake)
set(CMAKE_PREFIX_PATH /usr/local/lib/cmake/glfw)

find_package (PkgConfig REQUIRED)
find_package (OpenGL REQUIRED)
find_package (glfw3 REQUIRED)
find_package (glm REQUIRED)
find_package (GLEW REQUIRED STATIC)
find_package (assimp REQUIRED)



set(SOURCE_FILES main.cpp Camera.h Shader.h Model.h Mesh.h )
add_executable(untitled3 ${SOURCE_FILES})
target_link_libraries (untitled3 ${OPENGL_LIBRARIES} ${GLFW3_LIBRARY} 
${GLEW_LIBRARY} SOIL assimp Xxf86vm pthread Xrandr Xinerama Xi X11 Xcursor)