Trying to create a background with the above RGB values,however the only success i had till now is by loading jpegs.Is there a way to create the background programmatically?
#include "CImg.h"
using namespace cimg_library;
constexpr int Height = 600;
constexpr int Width = 539;
int main() {
CImgDisplay mainWindow(Height,Width);
CImg<unsigned char> background;
// background. ??? Is there a function to do so or loading a jpeg the only way
while(!mainWindow.is_closed()) {
mainWindow.display(background);
}
return EXIT_SUCCESS;
}
EDIT 1: Defined #define cimg_display 2
#define cimg_display 2
#define BACKGROUND_RGB 73,95,105
#include "CImg.h"
using namespace cimg_library;
constexpr int Height = 600;
constexpr int Width = 540;
int main() {
CImgDisplay mainWindow(Height,Width);
CImg<unsigned char> background(Height,Width,1,3,BACKGROUND_RGB);
while(!mainWindow.is_closed()) {
mainWindow.display(background);
}
return EXIT_SUCCESS;
}
Cmakefiles.txt
cmake_minimum_required(VERSION 3.14)
project(Snake__)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
include_directories("C:\\C++\\External Library\\CImg-2.6.4\\")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -O3")
add_executable(Snake__ main.cpp)
Compiler Output:
Scanning dependencies of target Snake__
[ 50%] Building CXX object CMakeFiles/Snake__.dir/main.cpp.obj
[100%] Linking CXX executable Snake__.exe
[100%] Built target Snake__
Build finished
Like this:
CImg<unsigned char> background(600,539,1,3,73,95,105);