generated from RISC-OS-Community/StandardRepoTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Makefiles and fixed a bunch of issues with code quality
- Loading branch information
Showing
12 changed files
with
581 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
| Generic Library builder for GCC on RISC OS | ||
| by Paolo Fabio Zaino | ||
|
||
echo ++++++++++++++++++++++++ | ||
echo ++ Building using GCC ++ | ||
echo ++++++++++++++++++++++++ | ||
|
||
Set Build$Root <Obey$Dir> | ||
|
||
WimpSlot -min 28672K | ||
|
||
echo --------------------- | ||
echo Building the Library: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.src | ||
IfThere @.UltimaVM.o.* Then wipe @.UltimaVM.o.* ~C ~V | ||
make all THROWBACK=-throwback OS=RISC_OS -f MakeFileGCC | ||
|
||
|IFthere @.o.ezinilib Then copy @.o.libezini @.^.!LibEzINI.a.libezini ~C N | ||
|IFthere @.h.ezini Then copy @.h.ezini @.^.!LibEzINI.h.ezini ~C N | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
echo --------------------- | ||
echo Building Tests: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.tests | ||
make all THROWBACK=-throwback -f MakeFileGCC | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
Dir <Build$Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Dir <Obey$Dir>.src | ||
WimpSlot -min 16384K | ||
make clean -f MakeFileGCC | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# MicroFB - A simple Framebuffer library for RISC OS | ||
# (c) 2024 by Paolo Fabio Zaino, all rights reserved | ||
# Licensed under the CDDL v1.1 License | ||
|
||
CC = g++ | ||
PTHREAD = -pthread | ||
EXT_SYM = . | ||
CFLAGS_BASE = -Wall -Wextra -pedantic -std=gnu++11 -O2 | ||
LDFLAGS_EXTRA = | ||
extras = | ||
server = | ||
client = | ||
|
||
LIB_NAME = MicroFB | ||
LIB_SOURCES = fb.cpp layer.cpp render_strategy.cpp | ||
LIB_OBJECTS = $(LIB_SOURCES:.cpp=.o) | ||
LIB_OUT = lib$(LIB_NAME)$(EXT_SYM)a | ||
LIB_LINK = -L./ -l$(LIB_NAME) | ||
|
||
ifeq ($(OS), RISC_OS) | ||
CC = g++ | ||
# PTHREAD = -lpthread | ||
PTHREAD = | ||
EXT_SYM =. | ||
CFLAGS_BASE = -Wall -Wextra -pedantic -std=gnu++11 | ||
LDFLAGS_EXTRA = -lgcc -lstdlib_extras | ||
#extras = stdlib_extras | ||
LIB_LINK = -l$(LIB_NAME) | ||
endif | ||
ifeq ($(OS), Darwin) | ||
CC = /opt/homebrew/bin/g++-13 | ||
PTHREAD = -pthread | ||
LIB_LINK = $(LIB_OUT) | ||
endif | ||
|
||
CFLAGS = $(CFLAGS_BASE) $(PTHREAD) | ||
|
||
|
||
all: $(LIB_OUT) $(server) $(client) | ||
|
||
# Pre-GCC 4.8.1 compatibility | ||
stdlib_extras: stdlib_extras.cpp | ||
$(CC) $(CFLAGS) -o stdlib_extras.o -c stdlib_extras.cpp | ||
ar rcs libstdlib_extras.a stdlib_extras.o | ||
|
||
# Library compilation | ||
$(LIB_OUT): $(LIB_OBJECTS) | ||
ar rcs $(LIB_OUT) $(LIB_OBJECTS) | ||
|
||
$(LIB_OBJECTS): $(LIB_SOURCES) | ||
$(CC) $(CFLAGS) -c $(LIB_SOURCES) | ||
|
||
# Server executable | ||
#$(server): Server.cpp $(LIB_OUT) $(extras) | ||
# $(CC) $(CFLAGS) -o $(server) Server.cpp $(LIB_LINK) $(LDFLAGS_EXTRA) | ||
|
||
# Client executable | ||
#$(client): Client.cpp $(LIB_OUT) $(extras) | ||
# $(CC) $(CFLAGS) -o $(client) Client.cpp $(LIB_LINK) $(LDFLAGS_EXTRA) | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm -f $(LIB_OBJECTS) $(LIB_OUT) $(server) $(client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,123 @@ | ||
/* | ||
* This file is part of: | ||
* This file is part of: | ||
* MicroFB, a minimal framebuffer library for RISC OS | ||
* | ||
* Description: | ||
* Description: | ||
* This project aims to provide a simple and efficient way to manage | ||
* the framebuffer on RISC OS using C++11. It abstracts the direct | ||
* interaction with the GraphicsV API, offering a higher-level | ||
* the framebuffer on RISC OS using C++11. It abstracts the direct | ||
* interaction with the GraphicsV API, offering a higher-level | ||
* interface for drawing operations and framebuffer manipulation. | ||
* | ||
* Author: | ||
* Paolo Fabio Zaino, all rights reserved. | ||
* Distributed under License: | ||
* CDDL v1.1 (Common Development and Distribution License Version | ||
* 1.1) The use of this project is subject to the terms of the | ||
* CDDL v1.1. This project can be used and distributed according | ||
* to the terms of this license. For details on the CDDL v1.1, | ||
* Distributed under License: | ||
* CDDL v1.1 (Common Development and Distribution License Version | ||
* 1.1) The use of this project is subject to the terms of the | ||
* CDDL v1.1. This project can be used and distributed according | ||
* to the terms of this license. For details on the CDDL v1.1, | ||
* please refer to the official license documentation. | ||
*/ | ||
|
||
#include <memory> // For std::shared_ptr | ||
|
||
#include "mem_manager.hpp" | ||
#include "layer.hpp" | ||
// Include MicroFB libraries | ||
#include "common.h" | ||
#if GCC_VERSION < 50000 | ||
// Include my own C++ STDLib extras for compatibility with older GCC versions | ||
//#include "stdlib_extras.h" | ||
#endif | ||
#include "mem_manager.h" | ||
#include "layer.h" | ||
|
||
// Constructor implementation | ||
Layer::Layer(pixel_t width, pixel_t height, std::shared_ptr<RenderStrategy> strategy) | ||
: width(width), height(height), opacity(1.0f), visible(true), currentRenderStrategy(strategy) { | ||
|
||
Layer::Layer(pixel_t width, pixel_t height, std::shared_ptr<RenderStrategy> strategy, std::shared_ptr<MemoryManager> currMemoryManager) | ||
: currentRenderStrategy(strategy), opacity(1.0f), visible(true), width(width), height(height) { | ||
|
||
if (currentMemoryManager == nullptr) { | ||
currentMemoryManager = currMemoryManager; | ||
} | ||
|
||
// Initialize pixel buffer with default color (0) | ||
pixels = static_cast<color_t*>(memoryManager->allocate(width * height * sizeof(color_t))); | ||
pixels = static_cast<color_t*>(currentMemoryManager->allocate(width * height * sizeof(color_t))); | ||
|
||
} | ||
|
||
// Destructor implementation | ||
Layer::~Layer() { | ||
// Not much for now | ||
} | ||
|
||
// Set the render strategy | ||
void Layer::setRenderStrategy(std::shared_ptr<RenderStrategy> strategy) { | ||
currentRenderStrategy = strategy; // Set the render strategy | ||
} | ||
|
||
// Set the memory manager | ||
void Layer::setMemoryManager(std::shared_ptr<MemoryManager> manager) { | ||
currentMemoryManager = manager; // Set the memory manager | ||
} | ||
|
||
// Clear the layer with a specific color | ||
void Layer::clear(color_t color) { | ||
currentRenderStrategy->clear(pixels, color); // Use the render strategy to clear the layer | ||
currentRenderStrategy->clear(*this, color); // Use the render strategy to clear the layer | ||
} | ||
|
||
// Direct pixel manipulation | ||
void Layer::setPixel(pixel_t x, pixel_t y, color_t color) { | ||
currentRenderStrategy->setPixel(pixels, x, y, color); // Use the render strategy to set the pixel | ||
currentRenderStrategy->setPixel(*this, x, y, color); // Use the render strategy to set the pixel | ||
} | ||
|
||
// Draw a line | ||
void Layer::drawLine(pixel_t x1, pixel_t y1, pixel_t x2, pixel_t y2, color_t color) { | ||
currentRenderStrategy->drawLine(pixels, x1, y1, x2, y2, color); // Use the render strategy to draw the line | ||
currentRenderStrategy->drawLine(*this, x1, y1, x2, y2, color); // Use the render strategy to draw the line | ||
} | ||
|
||
// Draw a rectangle | ||
void Layer::drawRect(pixel_t x, pixel_t y, pixel_t w, pixel_t h, color_t color) { | ||
currentRenderStrategy->drawRect(pixels, x, y, w, h, color); // Use the render strategy to draw the rectangle | ||
currentRenderStrategy->drawRect(*this, x, y, w, h, color); // Use the render strategy to draw the rectangle | ||
} | ||
|
||
// Fill a rectangle | ||
void Layer::fillRect(pixel_t x, pixel_t y, pixel_t w, pixel_t h, color_t color) { | ||
currentRenderStrategy->fillRect(pixels, x, y, w, h, color); // Use the render strategy to fill the rectangle | ||
currentRenderStrategy->fillRect(*this, x, y, w, h, color); // Use the render strategy to fill the rectangle | ||
} | ||
|
||
// Draw a circle | ||
// Draw a circle | ||
void Layer::drawCircle(pixel_t x, pixel_t y, pixel_t r, color_t color) { | ||
currentRenderStrategy->drawCircle(pixels, x, y, r, color); // Use the render strategy to draw the circle | ||
currentRenderStrategy->drawCircle(*this, x, y, r, color); // Use the render strategy to draw the circle | ||
} | ||
|
||
// Fill a circle | ||
// Fill a circle | ||
void Layer::fillCircle(pixel_t x, pixel_t y, pixel_t r, color_t color) { | ||
currentRenderStrategy->fillCircle(pixels, x, y, r, color); // Use the render strategy to fill the circle | ||
currentRenderStrategy->fillCircle(*this, x, y, r, color); // Use the render strategy to fill the circle | ||
} | ||
|
||
// Draw an ellipse | ||
// Draw an ellipse | ||
void Layer::drawEllipse(pixel_t x, pixel_t y, pixel_t rx, pixel_t ry, color_t color) { | ||
currentRenderStrategy->drawEllipse(pixels, x, y, rx, ry, color); // Use the render strategy to draw the ellipse | ||
currentRenderStrategy->drawEllipse(*this, x, y, rx, ry, color); // Use the render strategy to draw the ellipse | ||
} | ||
|
||
// Fill an ellipse | ||
// Fill an ellipse | ||
void Layer::fillEllipse(pixel_t x, pixel_t y, pixel_t rx, pixel_t ry, color_t color) { | ||
currentRenderStrategy->fillEllipse(pixels, x, y, rx, ry, color); // Use the render strategy to fill the ellipse | ||
currentRenderStrategy->fillEllipse(*this, x, y, rx, ry, color); // Use the render strategy to fill the ellipse | ||
} | ||
|
||
// Draw a polygon | ||
// Draw a polygon | ||
void Layer::drawPolygon(const std::vector<pixel_t>& points, color_t color) { | ||
currentRenderStrategy->drawPolygon(pixels, points, color); // Use the render strategy to draw the polygon | ||
currentRenderStrategy->drawPolygon(*this, points, color); // Use the render strategy to draw the polygon | ||
} | ||
|
||
// Fill a polygon | ||
// Fill a polygon | ||
void Layer::fillPolygon(const std::vector<pixel_t>& points, color_t color) { | ||
currentRenderStrategy->fillPolygon(pixels, points, color); // Use the render strategy to fill the polygon | ||
currentRenderStrategy->fillPolygon(*this, points, color); // Use the render strategy to fill the polygon | ||
} | ||
|
||
// Draw text | ||
// Draw text | ||
void Layer::drawText(pixel_t x, pixel_t y, const char* text, color_t color) { | ||
currentRenderStrategy->drawText(pixels, x, y, text, color); // Use the render strategy to draw the text | ||
currentRenderStrategy->drawText(*this, x, y, text, color); // Use the render strategy to draw the text | ||
} | ||
|
||
// Draw an image | ||
// Draw an image | ||
void Layer::drawImage(pixel_t x, pixel_t y, const Layer& image) { | ||
currentRenderStrategy->drawImage(pixels, x, y, image); // Use the render strategy to draw the image | ||
currentRenderStrategy->drawImage(*this, x, y, image); // Use the render strategy to draw the image | ||
} |
Oops, something went wrong.