I need to know how to open a window to draw into and the fastest way to draw pixels. Ideally this would in the terminal just to gain a bit more speed but not essential.
Any help appreciated.
Noob... be gentle
Dave.
SDL will either open an X window that you can poke pixels into, or use the consoel framebuffer, so you get the best of both worlds.davef21370 wrote:It's a long time since I used C, been messing with Python since I got the Pi and that's been okay but now I need some speed so C is the answer.
I need to know how to open a window to draw into and the fastest way to draw pixels. Ideally this would in the terminal just to gain a bit more speed but not essential.
Any help appreciated.
Noob... be gentle![]()
Dave.
Code: Select all
#include "CApp.h"
#include "CApp_OnInit.cpp"
#include "CApp_OnEvent.cpp"
#include "CApp_OnLoop.cpp"
#include "CApp_OnRender.cpp"
#include "CApp_OnCleanup.cpp"
CApp::CApp() {
Running = true;
}
int CApp::OnExecute() {
if (OnInit() == false) {
return -1;
}
SDL_Event Event;
while (Running) {
while (SDL_PollEvent(&Event)) {
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanup();
return 0;
}
int main(int argc, char* argv[]) {
CApp theApp;
return theApp.OnExecute();
}
Looks a bit c++ey to me... All my SDL stuff has been in pure C.davef21370 wrote:Thanks all, I've gone down the SDL route and fallen at the first hurdle while following the tutorial at http://www.sdltutorials.com/sdl-tutorial-basics
I'm getting the error:
undefined reference to 'SDL_PollEvent'
and here's the code (checked and rechecked)again, any help much appreciated.Code: Select all
#include "CApp.h" #include "CApp_OnInit.cpp" #include "CApp_OnEvent.cpp" #include "CApp_OnLoop.cpp" #include "CApp_OnRender.cpp" #include "CApp_OnCleanup.cpp" CApp::CApp() { Running = true; } int CApp::OnExecute() { if (OnInit() == false) { return -1; } SDL_Event Event; while (Running) { while (SDL_PollEvent(&Event)) { OnEvent(&Event); } OnLoop(); OnRender(); } OnCleanup(); return 0; } int main(int argc, char* argv[]) { CApp theApp; return theApp.OnExecute(); }
Dave.
edit.. I'm using Geany and not sure about where it looks for libs and stuff.