git pushing to find where it changed and why tf TBB is being called

This commit is contained in:
kin fuyuki 2025-12-25 17:04:13 -03:00
commit 64332cc93e
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
8 changed files with 118 additions and 36 deletions

View file

@ -6,6 +6,7 @@ if(WIN32)
else()
set(PLATFORM_DIR "linux")
endif()
add_subdirectory(engine)
add_subdirectory(games/forespend)
add_subdirectory(games/endlauncher)

View file

@ -35,6 +35,7 @@ namespace enginend {
int framedelay;
int framecounter;
unsigned int nextframeoffset;
int prevframe;
animated() : frames(0), currentframe(0), framedelay(6), framecounter(0), nextframeoffset(0) {
animimage.data = nullptr;
@ -60,10 +61,14 @@ namespace enginend {
currentframe++;
if (currentframe >= frames) currentframe = 0;
nextframeoffset = animimage.width * animimage.height * 4 * currentframe;
UpdateTexture(*texture, ((unsigned char*)animimage.data) + nextframeoffset);
}
}
void draw() override {
if (prevframe!=currentframe){
prevframe=currentframe;
UpdateTexture(*this->texture,((unsigned char*)animimage.data)+nextframeoffset);
}
textured::draw();
}
void exit() override {

View file

@ -1,5 +1,4 @@
#pragma once
#pragma once
#include <string>
#include "nodes.h"
@ -23,6 +22,8 @@ namespace enginend{
Texture2D* texture;
textured(){texture=nullptr;}
textured(Texture2D* texture,double x,double y,double w,double h):texture(texture),rect(x,y,w,h){}
void boot() override{}
void tick() override{}
void draw()override{
if(texture==nullptr)return;
float sw=GetScreenWidth();
@ -31,11 +32,16 @@ namespace enginend{
float ay=y*sh;
float aw=w*sw;
float ah=h*sh;
tiny::echo("og: %f %f %f %f", x,y,w,h);
tiny::echo("transformed: %f %f %f %f", ax, ay, aw, ah);
DrawTexturePro(*texture,{0,0,(float)texture->width,(float)texture->height},{ax,ay,aw,ah},{0,0},0,WHITE);
}
void exit()override {
UnloadTexture(*texture);
delete texture;
if(texture){
UnloadTexture(*texture);
delete texture;
texture=nullptr;
}
}
};
struct animated :virtual public textured{
@ -44,14 +50,17 @@ namespace enginend{
int currentframe;
int framedelay;
int framecounter;
int prevframe;
unsigned int nextframeoffset;
animated():frames(0),currentframe(0),framedelay(6),framecounter(0),nextframeoffset(0){
animated():frames(0),currentframe(1),framedelay(6),framecounter(0),nextframeoffset(0){
animimage.data=nullptr;
prevframe=currentframe;
}
void boot()override{}
animated(const char* gifpath,double x,double y,double w,double h,int delay=6):
textured(nullptr,x,y,w,h),framedelay(delay),currentframe(0),framecounter(0),frames(0),nextframeoffset(0)
textured(nullptr,x,y,w,h),framedelay(delay),currentframe(1),framecounter(0),frames(0),nextframeoffset(0)
{
prevframe=currentframe;
this->x=x; this->y=y; this->w=w; this->h=h;
animimage=LoadImageAnim(gifpath,&frames);
if(frames>0){
texture=new Texture2D(LoadTextureFromImage(animimage));
@ -65,13 +74,18 @@ namespace enginend{
currentframe++;
if(currentframe>=frames)currentframe=0;
nextframeoffset=animimage.width*animimage.height*4*currentframe;
UpdateTexture(*texture,((unsigned char*)animimage.data)+nextframeoffset);
tiny::echo("updating node\nframes: %i\n current frame: %i",frames,currentframe);
tiny::echo("%i",nextframeoffset);
}
}
void draw()override {
if (prevframe!=currentframe){
prevframe=currentframe;
UpdateTexture(*this->texture,((unsigned char*)animimage.data)+nextframeoffset);
}
textured::draw();
}
void exit(){
void exit()override{
if(animimage.data)UnloadImage(animimage);
textured::exit();
}
@ -80,6 +94,8 @@ namespace enginend{
Color c;
colored(){}
colored(Color color,double x,double y,double w,double h):c(color),rect(x,y,w,h){}
void boot()override{}
void tick()override{}
void draw()override{
float sw=GetScreenWidth();
float sh=GetScreenHeight();
@ -89,15 +105,18 @@ namespace enginend{
float ah=h*sh;
DrawRectangle(ax,ay,aw,ah,c);
}
void exit()override{}
};
struct tinted :virtual public colored,virtual public textured{
tinted(){}
tinted(Texture2D* texture,Color color,double x,double y,double w,double h):
node2d(x,y,w,h),
rect(x,y,w,h),
colored(color,x,y,w,h),
textured(texture,x,y,w,h)
node2d(x,y,w,h),
rect(x,y,w,h),
colored(color,x,y,w,h),
textured(texture,x,y,w,h)
{}
void boot()override{}
void tick()override{}
void draw()override{
if(texture==nullptr)return;
float sw=GetScreenWidth();
@ -108,6 +127,9 @@ namespace enginend{
float ah=h*sh;
DrawTexturePro(*texture,{0,0,(float)texture->width,(float)texture->height},{ax,ay,aw,ah},{0,0},0,c);
}
void exit()override{
textured::exit();
}
};
struct text :public tinted {
protected:
@ -119,8 +141,8 @@ namespace enginend{
std::string content;
text(){fs=20;}
text(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize,std::string txt):
tinted(texture,color,x,y,w,h),
font(f),fs(fsize),content(txt),txc(txcol)
tinted(texture,color,x,y,w,h),
font(f),fs(fsize),content(txt),txc(txcol)
{
result=content;
size_t initp=0;
@ -129,8 +151,8 @@ namespace enginend{
initp+=2;
}
}
void boot()override{}
void tick()override {
tinted::tick();
if(result!=content){
result=content;
size_t initp=0;
@ -156,15 +178,18 @@ namespace enginend{
DrawRectangle(ax-charsize.x,ay-charsize.y,minw+p,minh+p,c);
DrawTextEx(font,content.c_str(),{ax,ay},fs,1,txc);
}
void exit()override{
tinted::exit();
}
};
struct button :virtual public tinted{
void(*func)();
bool pressed;
bool hover;
button():func(nullptr),pressed(false){}
button(Texture2D* texture,Color color,double x,double y,double w,double h,void(*f)()):func(f),pressed(false),tinted(texture,color,x,y,w,h){}
button():func(nullptr),pressed(false),hover(false){}
button(Texture2D* texture,Color color,double x,double y,double w,double h,void(*f)()):func(f),pressed(false),hover(false),tinted(texture,color,x,y,w,h){}
void boot()override{}
void tick()override{
tinted::tick();
Vector2 mouse=GetMousePosition();
float sw=GetScreenWidth();
float sh=GetScreenHeight();
@ -178,11 +203,15 @@ namespace enginend{
}
}else{
hover=false;
pressed=false;
}
}
void draw()override {
tinted::draw();
}
void exit()override{
tinted::exit();
}
};
struct labeledbutton :virtual public button {
std::string label;
@ -190,10 +219,14 @@ namespace enginend{
int fs;
Color txc;
labeledbutton(std::string name,Texture2D* texture,Color color,Color text,
double x,double y,double w,double h,void(*f)(),
Font fnt,int size):font(fnt),fs(size),txc(text),label(name),
button(texture,color,x,y,w,h,f)
double x,double y,double w,double h,void(*f)(),
Font fnt,int size):font(fnt),fs(size),txc(text),label(name),
button(texture,color,x,y,w,h,f)
{}
void boot()override{}
void tick()override{
button::tick();
}
void draw()override{
button::draw();
float sw=GetScreenWidth();
@ -209,6 +242,9 @@ namespace enginend{
};
DrawTextEx(font,label.c_str(),tpos,fs,1,txc);
}
void exit()override{
button::exit();
}
};
struct slider :virtual public tinted{
float val;
@ -216,8 +252,8 @@ namespace enginend{
float maxv;
slider():val(0),minv(0),maxv(1){}
slider(Texture2D* texture,Color color,double x,double y,double w,double h,float min,float max,float v):val(v),minv(min),maxv(max),tinted(texture,color,x,y,w,h){}
void boot()override{}
void tick()override{
tinted::tick();
Vector2 mouse=GetMousePosition();
float sw=GetScreenWidth();
float sh=GetScreenHeight();
@ -240,11 +276,18 @@ namespace enginend{
float t=(val-minv)/(maxv-minv);
DrawRectangle(ax,ay,aw*t,ah,c);
}
void exit()override{
tinted::exit();
}
};
struct textfield :public text{
textfield(){}
textfield(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize,std::string txt):
text(texture,txcol,color,x,y,w,h,f,fsize,txt){}
text(texture,txcol,color,x,y,w,h,f,fsize,txt){}
void boot()override{}
void tick()override{
text::tick();
}
void draw()override{
float sw=GetScreenWidth();
float sh=GetScreenHeight();
@ -260,13 +303,17 @@ namespace enginend{
DrawRectangle(ax-(po/2),ay-(po/2),minw+(po*1.1),minh+(po*1.1),c);
DrawTextEx(font,content.c_str(),{ax,ay},fs,charsize.x/2,txc);
}
void exit()override{
text::exit();
}
};
struct textinput :public text{
bool active;
int cpos;
textinput():active(false),cpos(0){}
textinput(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize):active(false),cpos(0),
text(texture,txcol,color,x,y,w,h,f,fsize,""){}
text(texture,txcol,color,x,y,w,h,f,fsize,""){}
void boot()override{}
void tick()override{
text::tick();
Vector2 mouse=GetMousePosition();
@ -301,13 +348,17 @@ namespace enginend{
DrawRectangle(ax+MeasureTextEx(font,content.c_str(),fs,1).x,ay,2,fs,{0,0,0,127});
}
}
void exit()override{
text::exit();
}
};
struct textinputfield :public textfield{
bool active;
int cpos;
textinputfield():active(false),cpos(0){}
textinputfield(Texture2D* texture,Color txcol,Color color,double x,double y,double w,double h,Font f,float fsize):active(false),cpos(0),
textfield(texture,txcol,color,x,y,w,h,f,fsize,""){}
textfield(texture,txcol,color,x,y,w,h,f,fsize,""){}
void boot()override{}
void tick()override{
textfield::tick();
Vector2 mouse=GetMousePosition();
@ -357,6 +408,10 @@ namespace enginend{
DrawRectangle(p.x+MeasureTextEx(font,line.c_str(),fs,1).x,p.y,2,fs,BLACK);
}
}
void exit()override{
textfield::exit();
}
};
}
}}
}
}

View file

@ -1,4 +1,6 @@
#pragma once
#include <oneapi/tbb/partitioner.h>
#include "../gr.h"
#include "../aud.h"
#include "../net.h"
@ -6,13 +8,19 @@
namespace enginend {
namespace nodes {
struct node{
struct node{
public:
virtual void boot()=0;
virtual void tick()=0;
virtual void draw()=0;
virtual void exit()=0;
};
}
struct group : public virtual enginend::nodes::node {
std::vector<node*> children;
void boot(){for (node* n: children){n->boot();}}
void tick(){for (node* n: children){n->tick();}}
void draw(){for (node* n: children){n->draw();}}
void exit(){for (node* n: children){n->exit();}}
};
}

View file

@ -7,6 +7,7 @@ add_executable(forespend ${FORESPEND_SOURCES})
set_target_properties(forespend PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built/forespend/${PLATFORM_DIR}/bin"
)
target_link_directories(
forespend PUBLIC
"${CMAKE_SOURCE_DIR}/link")

View file

@ -15,12 +15,9 @@ void client::boot() {
target=LoadRenderTexture(380,240);
}
void client::draw() {
BeginTextureMode(target);
this->currentscene->draw();
EndTextureMode();
BeginDrawing();
ClearBackground(WHITE);
DrawTexturePro(target.texture, {0, 0, 380,240}, {0, 0, (float)GetScreenWidth(), (float)GetScreenHeight()}, {0, 0}, 0, WHITE);
this->currentscene->draw();
EndDrawing();
}
void client::exit() {

View file

@ -0,0 +1,6 @@
#pragma once
#include <vector>
#include <enginend/scenes/node2drelative.h>
std::vector<enginend::nodes::group> config{};

View file

@ -1,20 +1,29 @@
#pragma once
#include <incmgr.h>
#include <enginend/scenes/node2drelative.h>
#include <enginend/scenes/node2d.h>
class mainmenu :public virtual enginend::scene{
private:
Texture2D bg= LoadTexture(AT("res/images/tilesheet.png"));
public:
void boot() override {
this->nodes=std::list<enginend::nodes::node*>{
new enginend::nodes::relative::animated(AT("res/images/sky.gif"),0,0,10,10,5)
new enginend::nodes::relative::animated(AT("res/images/sky.gif"),0,0,1,1,2),
};
enginend::scene::boot();
}
void tick() override {
enginend::scene::tick();
for (enginend::nodes::node* n : this->nodes) {
n->tick();
}
}
void draw() override {
enginend::scene::draw();
for (enginend::nodes::node* n : this->nodes) {
n->draw();
}
}
void exit() override {
enginend::scene::exit();