Hey guys!
Following my last post on me trying to build a console GUI with SDL_2. I'm running into a bit of an issue, by running I should rather say faceplanting a wall :).
I've built the console, and it works fine. Only, before starting to code I hadn't thought about one thing. I can cout things to the console, I can cin and all the test I've tried to do worked fine.
The thing Is that my console is running on a loop which roughly goes like this:
while (console is running)
-> run at 30 fps
-> handle console events (like user input, cin, cout, exiting...)
-> render console
loop
The whole console is wrapped in a class and therefore my main function looks like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include "SDL_console.h"
using namespace std;
int main(int argc, char* args[])
{
SDL_Console console;
console.runWithCappedFrames(); //this is the loop function
console.close(); //this closes console and destroys all allocated memory
return 0;
}
|
The thing is, I'd like to be able to call the console functions from an object like in this example where console is a SDL_Console. However I'd like to be able to pass arguments to that object from outside said object's loop. As you understand, there is no passing
console.runWithCappedFrames();
in the main function until you close the console..
I'd like to use that console now, with a regular program, and I guess what it should lool like is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include "SDL_Console.h"
#include <iostream>
using namespace std;
int main()
{
SDL_Console console;
int number;
console.console_cout("Please enter a number between 1 and 10: ");
number = console.console_cin();
console.console_cout("\nThe number you chose is: ");
console.console_cout(number);
return(0);
}
|
Hopefully you see what I mean and the issue I'm having. I'm aware it may be a HUGE design flaw on my part, if so please point it out and suggest me a way of doing it, for I'm clueless.
Thanks in advance for all insight and help.
Regards,
Hugo.