supposed to be swapping buffers now but only getting a black screen... not a good sign

git-svn-id: svn://anubis/anaglym/trunk@82 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-10-14 02:44:45 +00:00
parent b9a4ce22ed
commit e7d5e6eed1
3 changed files with 22 additions and 10 deletions

View File

@ -176,8 +176,7 @@ int Engine::setCamera(lua_State * L)
vector<double> args;
for (int i = 1; i <= argc; i++)
{
int type = lua_type(L, i);
if (type == LUA_TNUMBER || type == LUA_TSTRING)
if (lua_isnumber(L, i))
args.push_back(lua_tonumber(L, i));
else
args.push_back(0);

View File

@ -7,6 +7,8 @@
#include <iostream>
#include <string>
#include <queue>
#include <GL/gl.h>
#include <GL/glu.h>
using namespace std;
enum EventType { EVENT_UPDATE };
@ -28,6 +30,7 @@ static SDL_Event userEvent;
static SDL_cond * event_condition;
static SDL_mutex * event_mutex;
static SDL_mutex * event_queue_mutex;
static SDL_mutex * engine_thread_ready_mutex;
static queue<Event> event_queue;
Uint32 g_ticks;
@ -42,14 +45,24 @@ static int engine_thread(void * param)
const char * program = (const char *) param;
if (g_engine->load(program))
{
SDL_mutexV(engine_thread_ready_mutex);
for (;;)
{
SDL_mutexP(event_mutex);
SDL_CondWait(event_condition, event_mutex);
bool moreEvents = true;
Event event;
bool moreEvents = false;
SDL_mutexP(event_queue_mutex);
if (event_queue.size() > 0)
moreEvents = true;
SDL_mutexV(event_queue_mutex);
if (!moreEvents)
{
/* wait for an event to be ready */
SDL_mutexP(event_mutex);
SDL_CondWait(event_condition, event_mutex);
}
moreEvents = true;
while (moreEvents)
{
Event event;
SDL_mutexP(event_queue_mutex);
if (event_queue.size() < 1)
moreEvents = false;
@ -66,6 +79,8 @@ static int engine_thread(void * param)
{
case EVENT_UPDATE:
g_engine->update();
GLUquadric * quad = gluNewQuadric();
gluSphere(quad, 4.0, 16, 8);
lastUpdateCompleted = true;
break;
}
@ -167,10 +182,10 @@ static void mainloop()
goto RET;
break;
case SDL_USEREVENT:
if (lastUpdateCompleted)
SDL_GL_SwapBuffers();
if (event.user.code == 0)
{
if (lastUpdateCompleted)
SDL_GL_SwapBuffers();
update();
}
break;

View File

@ -2,9 +2,7 @@
function update()
ballx, bally, ballz = ball:getPosition()
ag.setCamera(7, -6, 15, ballx, bally, ballz, 0, 0, 1)
ag.startFrame()
ag.drawObjects()
ag.endFrame()
end
--ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1)