Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support request: how can i port this library to embedded systems? #376

Open
XanCraft21 opened this issue Jul 27, 2024 · 8 comments
Open

Comments

@XanCraft21
Copy link

Hello, i was wondering if it would be possible to port this library to embedded systems like microcontrollers, with software like Arduino. I am aware that most microcontrollers will NOT be able to run this, but i would like to try it anyway on a more powerful microcontroller.

I know that such devices have no operating system, but i can provide my own display so long as i have access to the frame buffer.

The reason why I am posting this is because i am having trouble finding or making a 3D renderer for these small devices. I found one that i managed to get working, but the project seems abandoned and i cannot get much help with using the renderer to its fullest potential.

This idea may be impossible and a waste of time, but i feel like trying something new at a smaller scale just for fun.

If anyone can help me achieve my goal i will gladly appreciate it. Thank you for your help and for taking the time to read this.

@Moros1138
Copy link
Collaborator

i was wondering if it would be possible to port this library to embedded systems like microcontrollers

the short answer, yes... but...

PGE uses the C++ STL extensively and whatever development platform you use would need to support them as well, this might be a show stopper in and of itself.

Beyond that, it would require implementations being written for the platform (arduino in your case) and the renderer (in your example the frame buffer to your display). I don't wanna say it would be easy to do, but it should be possible.

@XanCraft21
Copy link
Author

Thank you. If possible could you give me an example of how i can modify the code to work for my platform? I’m not the best at porting libraries.

a few questions: How would i swap out STL for my preferred graphics library, since i cannot find an STL port for Arduino? What parts should be changed or removed (keyboard and mouse controls, window applications, ect.)?

I hope i’m not asking for too much, sorry if i sound like i am.

@Moros1138
Copy link
Collaborator

How would i swap out STL for my preferred graphics library, since i cannot find an STL port for Arduino?

STL isn't a graphics library it's the C++ Standard Template Library ... PGE is written in C++ using C++ STL features, so if your platform doesn't support them, then porting PGE to your arduino is gonna involve rewriting the whole thing from scratch.

Given you have to write it from scratch you get to choose what parts makes sense for your port and which parts don't.

I'm not an expert in writing arduino code so I can't be more help to you.

@XanCraft21
Copy link
Author

If STL is basically the c++ Standard library or stdlib then my platform supports that on most higher end devices.

I can make my own input replacement for keyboard and mouse, i’m just not sure how the library will handle platforms without system specific features. Will i get tons of errors first try or will i be mostly set to go?

@Moros1138
Copy link
Collaborator

I can say, with certainty, that if you try to use PGE on an embedded system that lacks any of a number of features it relies on then you will indeed be presented with loads and loads of errors.

You are wanting to use PGE on a platform it hasn't been ported to which means you're gonna have to implement the bits that will make it work on your platform.

PGE is abstracted such that you can implement your own Platform

https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L959

For example, this is how Windows Platform has been implemented
https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L5639

and your own Renderer

https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L937

For example, this is how OpenGL 1.1 Renderer has been implemented
https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L937

once you've implemented your Platform and Renderer, you tie them into PGE, in this section
https://github.com/OneLoneCoder/olcPixelGameEngine/blob/master/olcPixelGameEngine.h#L5639

@XanCraft21
Copy link
Author

Thank you. I had trouble finding those.

Another question i have, how do i make this work without using OpenGL? I have a software only port i’m trying to implement, but i might need to figure out something else.

@Moros1138
Copy link
Collaborator

Moros1138 commented Jul 28, 2024

No problem. I don't have a good answer to this. I've never ported it to a platform that didn't have opengl, so i never had to consider any other means of rendering. i would start by looking at the way the renderer is abstracted and figure out how those parts work with a software renderer.

@XanCraft21
Copy link
Author

Ok. Hmm, this might be very hard to figure out. Thank you for the help. I might need to come back to this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants