From 72fedd4f3c0969e370e0a3be78ed646fc513150e Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 6 Aug 2024 00:49:50 +0800 Subject: [PATCH] fixed few bug in BitmapLoad/DrawGeometry --- inc/hgl/2d/BitmapLoad.h | 2 +- inc/hgl/2d/DrawGeometry.h | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/inc/hgl/2d/BitmapLoad.h b/inc/hgl/2d/BitmapLoad.h index dc8eb31..10674c5 100644 --- a/inc/hgl/2d/BitmapLoad.h +++ b/inc/hgl/2d/BitmapLoad.h @@ -79,7 +79,7 @@ namespace hgl io::OpenFileInputStream fis(filename); if(!fis) - return(false); + return(nullptr); return LoadBitmapFromTGA(&fis); } diff --git a/inc/hgl/2d/DrawGeometry.h b/inc/hgl/2d/DrawGeometry.h index 9899593..3766a92 100644 --- a/inc/hgl/2d/DrawGeometry.h +++ b/inc/hgl/2d/DrawGeometry.h @@ -54,9 +54,9 @@ namespace hgl bool GetPixel(int x,int y,T &color) { - if(!data)return(false); + if(!bitmap)return(false); - T *p=GetData(x,y); + T *p=bitmap->GetData(x,y); if(!p)return(false); @@ -78,6 +78,11 @@ namespace hgl return(true); } + bool PutPixel(const Vector2i &v) + { + return PutPixel(v.x,v.y); + } + bool DrawHLine(int x,int y,int length) { if(!bitmap)return(false); @@ -117,7 +122,7 @@ namespace hgl if(w<=0||h<=0)return(false); - T *p=bitmap->GetData(x,y); + T *p=bitmap->GetData(l,t); for(int y=t;y