RenderD7 is now LibRenderD7

This commit is contained in:
tobid7 2022-07-24 00:55:18 +02:00
parent 3c7c12ef39
commit 6af08275e9
37 changed files with 553 additions and 98 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
release/
debug/
lib/
lib/
*.xz

205
Makefile Normal file
View File

@ -0,0 +1,205 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
export renderd7_MAJOR := 0
export renderd7_MINOR := 8
export renderd7_PATCH := 0
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
# If on a tagged commit, use the tag instead of the commit
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
GIT_VER := $(shell git tag -l --points-at HEAD)
else
GIT_VER := $(shell git rev-parse --short HEAD)
endif
TIME_TIME := $(shell date --iso=seconds)
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := renderd7
SOURCES := source external/source external/libnsbmp/source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -Werror -mword-relocations -save-temps\
-DV_STRING=\"$(GIT_VER)\" \
-DV_TIME=\"$(TIME_TIME)\" \
-ffunction-sections -fdata-sections \
$(ARCH) $(BUILD_CFLAGS)
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
ASFLAGS := -g $(ARCH) $(DEFINES)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I.
.PHONY: clean all doc
#---------------------------------------------------------------------------------
all: lib/librenderd7.a lib/librenderd7d.a
doc:
@doxygen Doxyfile
dist-bin: all
@tar --exclude=*~ -cjf $(TARGET)-$(VERSION).tar.bz2 include lib
dist-src:
@tar --exclude=*~ -cjf $(TARGET)-src-$(VERSION).tar.bz2 include source Makefile
dist: dist-src dist-bin
install: dist-bin
mkdir -p $(DEPSDIR)$(DEVKITPRO)/libctru
bzip2 -cd $(TARGET)-$(VERSION).tar.bz2 | tar -xf - -C $(DEPSDIR)$(DEVKITPRO)/libctru
lib:
@[ -d $@ ] || mkdir -p $@
release:
@[ -d $@ ] || mkdir -p $@
debug:
@[ -d $@ ] || mkdir -p $@
lib/librenderd7.a : lib release $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile
lib/librenderd7d.a : lib debug $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DDEBUG=1 -Og" \
DEPSDIR=$(CURDIR)/debug \
--no-print-directory -C debug \
-f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr release debug lib includes
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
$(OFILES_SOURCES) : $(HFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $*.shbin)
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
endef
%.shbin.o %_shbin.h : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o %_shbin.h : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o %_shbin.h : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,3 +1,18 @@
# RenderD7
RenderD7 is now LibRenderD7.
### Installation (Ubuntu)
first run this
`sudo su`
then this
```
git clone https://github.com/NPI-D7/RenderD7.git
cd RenderD7
export DEVKITARM=/opt/devkitpro/devkitARM/
export DEVKITPRO=/opt/devkitpro/
make install
```
Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
# RenderD7 (https://npi-d7.github.io/RenderD7/)
Simple and Easey to use UI and Graphics helper.
Create DOCS

View File

@ -30,9 +30,9 @@
#include <stdlib.h>
#include <stdint.h>
#include <libnsbmp.h>
#include <renderd7/external/libnsbmp/libnsbmp.h>
#include "log.h"
#include <renderd7/external/libnsbmp/log.h>
/* squashes unused variable compiler warnings */
#define UNUSED(x) ((x)=(x))

View File

@ -1,4 +1,4 @@
#include "external/fs.h"
#include <renderd7/external/fs.h>
#include <stdio.h>
#include <string.h>
@ -185,7 +185,7 @@ u64 FS_GetTotalStorage(FS_SystemMediaType media_type) {
}
u64 FS_GetUsedStorage(FS_SystemMediaType media_type) {
return (FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
return 0;//(FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
}
Result FS_RemoveFile(FS_Archive archive, const char *path) {

View File

@ -28,7 +28,7 @@ The manual and changelog are in the header file "lodepng.h"
Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.
*/
#include "lodepng.h"
#include <renderd7/external/lodepng.h>
#ifdef LODEPNG_COMPILE_DISK
#include <limits.h> /* LONG_MAX */

4
include/rd7.hpp Normal file
View File

@ -0,0 +1,4 @@
#pragma once
#include <renderd7/bmp.hpp>
#include <renderd7/renderd7.hpp>

View File

@ -1,5 +1,5 @@
#include <Time.hpp>
#pragma once
#include <renderd7/Time.hpp>
namespace rnd7 {
class Clock {

View File

@ -3,6 +3,8 @@
#include <vector>
#include <stdexcept>
#include <iostream>
#include <iterator>
#include <sstream>
using namespace std;
#pragma pack(push, 1)
@ -52,13 +54,13 @@ struct BMP {
read(fname);
}
void read(const char *fname) {
int read(const char *fname) {
std::ifstream inp{ fname, std::ios_base::binary };
if (inp) {
inp.read((char*)&file_header, sizeof(file_header));
if(file_header.file_type != 0x4D42) {
return;//throw std::runtime_error("Error! Unrecognized file format.");
return 50;//throw std::runtime_error("Error! Unrecognized file format.");
}
inp.read((char*)&bmp_info_header, sizeof(bmp_info_header));
@ -71,7 +73,7 @@ struct BMP {
check_color_header(bmp_color_header);
} else {
//std::cerr << "Error! The file \"" << fname << "\" does not seem to contain bit mask information\n";
return;//throw std::runtime_error("Error! Unrecognized file format.");
return 51;//throw std::runtime_error("Error! Unrecognized file format.");
}
}
@ -90,7 +92,7 @@ struct BMP {
file_header.file_size = file_header.offset_data;
if (bmp_info_header.height < 0) {
return;//throw std::runtime_error("The program can treat only BMP images with the origin in the bottom left corner!");
return 52;//throw std::runtime_error("The program can treat only BMP images with the origin in the bottom left corner!");
}
data.resize(bmp_info_header.width * bmp_info_header.height * bmp_info_header.bit_count / 8);
@ -113,13 +115,82 @@ struct BMP {
}
}
else {
return;//throw std::runtime_error("Unable to open the input image file "+std::string(fname));
return 53;//throw std::runtime_error("Unable to open the input image file "+std::string(fname));
}
return 0;
}
int read_mem(std::vector<unsigned char> buffer) {
std::stringstream inp;
std::copy(buffer.begin(), buffer.end(),std::ostream_iterator<unsigned char>(inp,"\n"));
if (inp) {
inp.read((char*)&file_header, sizeof(file_header));
if(file_header.file_type != 0x4D42) {
return 50;//throw std::runtime_error("Error! Unrecognized file format.");
}
inp.read((char*)&bmp_info_header, sizeof(bmp_info_header));
// The BMPColorHeader is used only for transparent images
if(bmp_info_header.bit_count == 32) {
// Check if the file has bit mask color information
if(bmp_info_header.size >= (sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
inp.read((char*)&bmp_color_header, sizeof(bmp_color_header));
// Check if the pixel data is stored as BGRA and if the color space type is sRGB
check_color_header(bmp_color_header);
} else {
//std::cerr << "Error! The file \"" << fname << "\" does not seem to contain bit mask information\n";
return 51;//throw std::runtime_error("Error! Unrecognized file format.");
}
}
// Jump to the pixel data location
inp.seekg(file_header.offset_data, inp.beg);
// Adjust the header fields for output.
// Some editors will put extra info in the image file, we only save the headers and the data.
if(bmp_info_header.bit_count == 32) {
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
} else {
bmp_info_header.size = sizeof(BMPInfoHeader);
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
}
file_header.file_size = file_header.offset_data;
if (bmp_info_header.height < 0) {
return 52;//throw std::runtime_error("The program can treat only BMP images with the origin in the bottom left corner!");
}
data.resize(bmp_info_header.width * bmp_info_header.height * bmp_info_header.bit_count / 8);
// Here we check if we need to take into account row padding
if (bmp_info_header.width % 4 == 0) {
inp.read((char*)data.data(), data.size());
file_header.file_size += static_cast<uint32_t>(data.size());
}
else {
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
uint32_t new_stride = make_stride_aligned(4);
std::vector<uint8_t> padding_row(new_stride - row_stride);
for (int y = 0; y < bmp_info_header.height; ++y) {
inp.read((char*)(data.data() + row_stride * y), row_stride);
inp.read((char*)padding_row.data(), padding_row.size());
}
file_header.file_size += static_cast<uint32_t>(data.size()) + bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
}
}
else {
return 53;//throw std::runtime_error("Unable to open the input image file "+std::string(fname));
}
return 0;
}
BMP(int32_t width, int32_t height, bool has_alpha = true) {
if (width <= 0 || height <= 0) {
return;//throw std::runtime_error("The image width and height must be positive numbers.");
width = 1;
height = 1;
}
bmp_info_header.width = width;
@ -148,7 +219,7 @@ struct BMP {
}
}
void write(const char *fname) {
unsigned write(const char *fname) {
std::ofstream of{ fname, std::ios_base::binary };
if (of) {
if (bmp_info_header.bit_count == 32) {
@ -171,12 +242,13 @@ struct BMP {
}
}
else {
return;//throw std::runtime_error("The program can treat only 24 or 32 bits per pixel BMP files");
return 54;//throw std::runtime_error("The program can treat only 24 or 32 bits per pixel BMP files");
}
}
else {
return;//throw std::runtime_error("Unable to open the output image file.");
return 55;//throw std::runtime_error("Unable to open the output image file.");
}
return 0;
}
@ -215,9 +287,9 @@ struct BMP {
}
void fill_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
unsigned fill_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
return;//throw std::runtime_error("The region does not fit in the image!");
return 59;
}
uint32_t channels = bmp_info_header.bit_count / 8;
@ -231,6 +303,7 @@ struct BMP {
}
}
}
return 0;
}
void fill_region_df(uint32_t x1, uint32_t y1, uint32_t w, uint32_t h, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
@ -536,9 +609,9 @@ struct BMP {
return intensity;
}
void set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
unsigned set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
if (x0 >= (uint32_t)bmp_info_header.width || y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
return;//throw std::runtime_error("The point is outside the image boundaries!");
return 59;//throw std::runtime_error("The point is outside the image boundaries!");
}
uint32_t channels = bmp_info_header.bit_count / 8;
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
@ -547,6 +620,7 @@ struct BMP {
if (channels == 4) {
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
}
return 0;
}
void set_pixel_df(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
@ -564,16 +638,17 @@ struct BMP {
}
}
void draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
unsigned draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
uint8_t B, uint8_t G, uint8_t R, uint8_t A, uint8_t line_w) {
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
return;//throw std::runtime_error("The rectangle does not fit in the image!");
return 59;//throw std::runtime_error("The rectangle does not fit in the image!");
}
fill_region(x0, y0, w, line_w, B, G, R, A); // top line
fill_region(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
fill_region((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // right line
fill_region(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // left line
return 0;
}
void draw_rectangle_df(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,

View File

@ -0,0 +1,14 @@
#pragma once
#include <renderd7/external/lodepng.h>
#include <iostream>
namespace BitmapConverter{
//returns 0 if all went ok, non-0 if error
//output image is always given in RGBA (with alpha channel), even if it's a BMP without alpha channel
unsigned decodeBMP(std::vector<unsigned char>& image, unsigned& w, unsigned& h, const std::vector<unsigned char>& bmp);
std::vector<unsigned char> ConvertFile(std::string filename);
std::vector<unsigned char> ConvertData(std::vector<unsigned char> data);
}

View File

@ -1,5 +1,4 @@
#ifndef _3D_SHELL_FS_H
#define _3D_SHELL_FS_H
#include <3ds.h>
@ -28,5 +27,3 @@ Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size)
char *FS_GetFileTimestamp(const char *path);
Result makeDirs(const char * path);
Result openFile(Handle* fileHandle, const char * path, bool write);
#endif

View File

@ -1,6 +1,6 @@
#pragma once
#include <string>
#include "json.hpp"
#include <renderd7/external/json.hpp>
/// RenderD7::Lang
namespace RenderD7::Lang

View File

@ -18,25 +18,27 @@
#include <iostream>
#include <filesystem>
#include <locale>
#include "external/lodepng.h"
#include <time.h>
#include <codecvt>
#include "lang.hpp"
#include "parameter.hpp"
#include "thread.hpp"
#include "ini.hpp"
#include "stringtool.hpp"
#include "Clock.hpp"
#include "bmp.hpp"
#include <renderd7/external/lodepng.h>
#include <renderd7/lang.hpp>
#include <renderd7/parameter.hpp>
#include <renderd7/thread.hpp>
#include <renderd7/ini.hpp>
#include <renderd7/stringtool.hpp>
#include <renderd7/Clock.hpp>
#include <renderd7/bmp.hpp>
#include <renderd7/bmpconverter.hpp>
extern "C"
{
#include "external/fs.h"
#include <renderd7/external/fs.h>
}
#define RENDERD7VSTRING "0.7.3"
#define CHANGELOG "0.7.3: Implement Over Render Overlay Framework\n0.7.2: Implement MT to csv file saving. Add RGB2HEX. \n0.7.1: Add the New Overlay Handler. Its Just in code and does nothing yet. \n0.7.0: Made Big Progress In the MT Ovl but it still crashes On a Scnd C3D_FrameEnd(). Implement 800px but doesn't work that good. \n0.6.2: Fix Crash when exiting trouth Home Menu. \n0.6.10: rewrite Threadsystem, Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left Function.\nadd changelog\n0.6.01: add Threading system."
#define RENDERD7VSTRING "0.8.0"
#define CHANGELOG "0.8.0: Implement BitmapPrinter\n0.7.3: Implement Over Render Overlay Framework\n0.7.2: Implement MT to csv file saving. Add RGB2HEX. \n0.7.1: Add the New Overlay Handler. Its Just in code and does nothing yet. \n0.7.0: Made Big Progress In the MT Ovl but it still crashes On a Scnd C3D_FrameEnd(). Implement 800px but doesn't work that good. \n0.6.2: Fix Crash when exiting trouth Home Menu. \n0.6.10: rewrite Threadsystem, Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left Function.\nadd changelog\n0.6.01: add Threading system."
#define DEFAULT_CENTER 0.5f
extern C3D_RenderTarget* Top;
@ -413,4 +415,34 @@ namespace RenderD7
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions);
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
class BitmapPrinter
{
public:
BitmapPrinter(int w, int h);
~BitmapPrinter();
bool DecodeFile(std::string file);
bool DecodeMem(std::vector<unsigned char> buffer);
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
void UsePreMap(BMP map);
void UsePrePrintMap(BitmapPrinter printmap);
BMP GetBitmap(){ return bitmap; }
void SaveBmp(std::string name);
void SavePng(std::string name);
void CreateScreen(C3D_RenderTarget *target);
void DrawScreen(int framerate);
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
void ClearBlank();
RenderD7::Image GetImage();
private:
int frame = 0;
RenderD7::Image renderframe;
bool isscreen = false;
C3D_RenderTarget* targetr;
BMP bitmap = NULL;
BMP blank = NULL;
};
} /// RenderD7

View File

@ -3,7 +3,7 @@
#include <atomic>
#include <functional>
#include <string>
#include "parameter.hpp"
#include <renderd7/parameter.hpp>
using CTRU_Thread = Thread;

View File

@ -1,4 +1,4 @@
#include "Clock.hpp"
#include <renderd7/Clock.hpp>
namespace rnd7{
enum class TweenType : int {Position = 1, Color, Alpha};

View File

@ -1,40 +0,0 @@
#pragma once
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include <memory>
#include <stack>
#include <string>
#include <functional>
#include <vector>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
#include <cstring>
#include <sys/stat.h>
#include <algorithm>
#include <iostream>
#include <codecvt>
#include <map>
#include "lang.hpp"
#include "parameter.hpp"
#include "thread.hpp"
#include "ini.hpp"
#include "stringtool.hpp"
enum EngineType
{
_2D,
_3D
};
namespace Npi
class Game {
public:
Game(EngineType, std::string name);
~Game(){}
private:
std::string g_name;
EngineType g_etype;
};
}

BIN
renderd7-0.8.0.tar.bz2 Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
#include "Clock.hpp"
#include <renderd7/Clock.hpp>
namespace rnd7 {

View File

@ -1,4 +1,4 @@
#include "Time.hpp"
#include <renderd7/Time.hpp>
namespace rnd7 {

View File

@ -1,7 +1,6 @@
#pragma once
#include "lodepng.h"
#include <renderd7/bmpconverter.hpp>
#include <iostream>
namespace BitmapConverter{
//returns 0 if all went ok, non-0 if error
//output image is always given in RGBA (with alpha channel), even if it's a BMP without alpha channel
@ -63,7 +62,7 @@ std::vector<unsigned char> ConvertFile(std::string filename) {
std::vector<unsigned char> image;
unsigned w, h;
unsigned error = decodeBMP(image, w, h, bmp);
unsigned error = BitmapConverter::decodeBMP(image, w, h, bmp);
if(error) {
std::cout << "BMP decoding error " << error << std::endl;
@ -86,7 +85,7 @@ std::vector<unsigned char> ConvertData(std::vector<unsigned char> data) {
std::vector<unsigned char> image;
unsigned w, h;
unsigned error = decodeBMP(image, w, h, data);
unsigned error = BitmapConverter::decodeBMP(image, w, h, data);
if(error) {
std::cout << "BMP decoding error " << error << std::endl;
@ -104,3 +103,4 @@ std::vector<unsigned char> ConvertData(std::vector<unsigned char> data) {
return png;
}
}

View File

@ -1,4 +1,4 @@
#include "lang.hpp"
#include <renderd7/lang.hpp>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

View File

@ -1,4 +1,4 @@
#include "log.hpp"
#include <renderd7/log.hpp>
#include <memory>

View File

@ -1,10 +1,10 @@
#include "renderd7.hpp"
#include "log.hpp"
#include <renderd7/renderd7.hpp>
#include <renderd7/log.hpp>
#include <regex>
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 0) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16) | (((a) & 0xFF) << 24))
#define D7_NOTHING C2D_Color32(0, 0, 0, 0)
#define CFGVER "2"
#define CFGVER "3"
Log renderd7log;
float animtime;
bool isndspinit = false;
@ -698,6 +698,7 @@ Result RenderD7::Init::Main(std::string app_name)
cfgstruct["settings"]["forcetimeoutLB"] = "1";
cfgstruct["settings"]["forceFrameRate"] = "60";
cfgstruct["settings"]["super-reselution"] = "0";
cfgstruct["settings"]["renderer"] = "c3d_c2d";
cfgstruct["metrik-settings"]["enableoverlay"] = "0";
cfgstruct["metrik-settings"]["Screen"] = "0";
cfgstruct["metrik-settings"]["txtColor"] = "#ffffff";
@ -1284,6 +1285,8 @@ void RenderD7::RSettings::Draw(void) const
std::string rd7ver = RENDERD7VSTRING;
std::string rd7cfgver = CFGVER;
std::string citras = is_citra ? "true" : "false";
std::string buildtime = V_TIME;
std::string commit = V_STRING;
RenderD7::OnScreen(Top);
RenderD7::DrawRect(0, 0, 400, 21, RenderD7::Color::Hex("#111111"));
RenderD7::DrawRect(0, 21, 400, 220, RenderD7::Color::Hex("#eeeeee"));
@ -1293,7 +1296,8 @@ void RenderD7::RSettings::Draw(void) const
RenderD7::DrawText(0, 50, 0.7f, DSEVENBLACK, "RenderD7: " + rd7ver);
RenderD7::DrawText(0, 70, 0.7f, DSEVENBLACK, "Config-Version: " + rd7cfgver);
RenderD7::DrawText(0, 90, 0.7f, DSEVENBLACK, "Citra: " + citras);
RenderD7::DrawText(0, 110, 0.7f, DSEVENBLACK, "C2D_MAX_OBJ: " + std::to_string(maxobj__));
RenderD7::DrawText(0, 110, 0.7f, DSEVENBLACK, "RenderD7-Build-Time: \n" + buildtime);
RenderD7::DrawText(0, 150, 0.7f, DSEVENBLACK, "RenderD7-Commit: " + commit);
/*RenderD7::DrawText(0, 130, 0.7f, DSEVENBLACK, "Metrik Text RGB: " + mttxtcolstate);
RenderD7::DrawText(0, 150, 0.7f, DSEVENBLACK, "Metrik Alpha: " + mtcola);
RenderD7::DrawText(0, 170, 0.7f, DSEVENBLACK, "Metrik Text Alpha: " + mttxtcola);*/
@ -1469,7 +1473,7 @@ std::string RenderD7::GetTimeStr(void)
}
extern "C"
{
#include "libnsbmp.h"
#include <renderd7/external/libnsbmp/libnsbmp.h>
}
static const u32 BYTES_PER_PIXEL = 4;
#define MAX_IMAGE_BYTES (48 * 1024 * 1024)
@ -1530,9 +1534,10 @@ unsigned Image_to_C3D(C2D_Image img, const std::vector<unsigned char>& bmpc) {
return 3;
}
}
C2D_Image* texture;
C2D_Image* texture = new C2D_Image();
bool ret = C3DTexToC2DImage(texture, static_cast<u32>(bmp.width), static_cast<u32>(bmp.height), static_cast<u8 *>(bmp.bitmap));
bmp_finalise(&bmp);
delete texture;
if (!ret)
{
return 4;
@ -1575,4 +1580,151 @@ void RenderD7::Toast::Logic()
msgposy++/*=(int)RenderD7::GetDeltaTime*/;
if(msgposy > 400) this->Kill();
}
}
RenderD7::BitmapPrinter::BitmapPrinter(int w, int h)
{
bitmap = BMP(w, h, true);
renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
blank = BMP(w, h, true);
}
RenderD7::BitmapPrinter::~BitmapPrinter()
{
}
bool RenderD7::BitmapPrinter::DecodeFile(std::string file)
{
unsigned error = bitmap.read(file.c_str());
if (error)
{
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter", "Error Code: " + std::to_string(error)));
return false;
}
return true;
}
bool RenderD7::BitmapPrinter::DecodeMem(std::vector<unsigned char> buffer)
{
unsigned error = bitmap.read_mem(buffer);
if (error)
{
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter", "Error Code: " + std::to_string(error)));
return false;
}
return true;
}
void RenderD7::BitmapPrinter::DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a)
{
unsigned error = bitmap.set_pixel(x, bitmap.bmp_info_header.height - y, b, g, r, a);
if (error)
{
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter->Pixel", "Error Code: " + std::to_string(error)));
}
}
void RenderD7::BitmapPrinter::DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a)
{
unsigned error = bitmap.draw_rectangle(x, bitmap.bmp_info_header.height - w - y, w, h, b, g, r, a, line_w);
if (error)
{
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter->Rect", "Error Code: " + std::to_string(error)));
}
}
void RenderD7::BitmapPrinter::DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a)
{
unsigned error = bitmap.fill_region(x, bitmap.bmp_info_header.height - w - y, w, h, b, g, r, a);
if (error)
{
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>("BitmapPrinter->RectF", "Error Code: " + std::to_string(error)));
}
}
void RenderD7::BitmapPrinter::SaveBmp(std::string name)
{
if(!RenderD7::NameIsEndingWith(name, {"bmp"}))
{
name += ".bmp";
}
bitmap.write(name.c_str());
}
void RenderD7::BitmapPrinter::SavePng(std::string name)
{
if(!RenderD7::NameIsEndingWith(name, {"png"}))
{
name += ".png";
}
std::vector<unsigned char> ImageBuffer;
ImageBuffer = BitmapConverter::ConvertData(bitmap.DATA());
lodepng::save_file(ImageBuffer, name);
}
void RenderD7::BitmapPrinter::CreateScreen(C3D_RenderTarget *target)
{
isscreen = true;
targetr = target;
if (target == Top)
{
bitmap = BMP(400, 240, true);
blank = BMP(400, 240, true);
}
if (target == TopRight)
{
bitmap = BMP(400, 240, true);
blank = BMP(400, 240, true);
}
if (target == Bottom)
{
bitmap = BMP(320, 240, true);
blank = BMP(320, 240, true);
}
renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
}
void RenderD7::BitmapPrinter::DrawScreen(int framerate)
{
if (isscreen)
{
if(frame == (60/framerate)){
RenderD7::OnScreen(targetr);
RenderD7::Image *img = new RenderD7::Image();
img->Unload();
//img->LoadFromBitmap(bitmap);
renderframe.Unload();
renderframe.LoadFromBitmap(bitmap);
renderframe.img = img->Get();
img->Unload();
delete img;
}
renderframe.Draw(0, 0);
frame++;
}
}
RenderD7::Image RenderD7::BitmapPrinter::GetImage()
{
RenderD7::Image img;
img.LoadFromBitmap(bitmap);
return img;
}
void RenderD7::BitmapPrinter::UsePreMap(BMP map)
{
bitmap = map;
}
void RenderD7::BitmapPrinter::UsePrePrintMap(BitmapPrinter printmap)
{
bitmap = printmap.GetBitmap();
}
void RenderD7::BitmapPrinter::Clear(u8 b, u8 g, u8 r, u8 a)
{
bitmap.fill_region(0, 0, bitmap.bmp_info_header.width, bitmap.bmp_info_header.height, b, g, r, a);
}
void RenderD7::BitmapPrinter::ClearBlank()
{
bitmap = blank;
}

View File

@ -1,4 +1,4 @@
#include "sound.hpp"
#include <renderd7/sound.hpp>
#include <cstdio>
#include <cstdlib>

View File

@ -1,4 +1,4 @@
#include "thread.hpp"
#include <renderd7/thread.hpp>
namespace RenderD7 {
void Threads::Exit()
{