Hello,
I'm considering to use Agar for GUI on top of my SDL/OpenGL
application. I've been playing around with it for couple of days and
it looks neat overly but I exeprienced some quirks.
Below is a minimal code example that compiles on windows with VC 2008.
The problem is that menu sub-item doesn't show up when I click on the
main menu item. However, the same menu setup works as intended when
using default event loop via AG_EventLoop() and without any SDL or GL
code.
I'm not sure I'm doing everything right as there are no code examples
for the case of custom loop with GL+SDL
If anybody has had experience with this, please shed some light.
Thanks,
Nenad
#include <windows.h>
#include <gl/gl.h>
#include "SDL.h"
#include <agar/core.h>
#include <agar/gui.h>
int main(int argc, char **argv){
// init sdl
if( SDL_Init(SDL_INIT_EVERYTHING) < 0 ){
exit(1);
}
if( ! SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF |
SDL_OPENGL ) ){
exit(1);
}
// init agar
if( AG_InitCore( "SDL+OGL+AGAR", 0) == -1 ){
exit(1);
}
AG_InitVideoSDL( SDL_GetVideoSurface(), AG_VIDEO_OVERLAY);
// create agar window
AG_Window * win = AG_WindowNew( 0 );
AG_LabelNew( win, 0, "Hello, world!");
AG_WindowShow( win );
// crate a menu with one sub-node
AG_Menu *menu = AG_MenuNew(win, 0);
AG_MenuItem *item = AG_MenuNode(menu->root, "Menu", NULL);
AG_MenuNode(item, "Node", NULL);
// main loop
bool loop = true;
SDL_Event e;
while( loop ){
while( SDL_PollEvent( &e )){
// pass the events to agar
AG_DriverEvent dev;
AG_SDL_TranslateEvent( agDriverSw, & e, &dev );
AG_ProcessEvent(NULL, &dev);
}
// some opengl code
glClearColor(0.4, 0.5, 0.4, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw the agar window
if (agDriverSw){
AG_BeginRendering(agDriverSw);
AG_WindowDraw(win);
AG_EndRendering(agDriverSw);
}
SDL_GL_SwapBuffers();
}
return 0;
}
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html