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:
parent
b9a4ce22ed
commit
e7d5e6eed1
@ -176,8 +176,7 @@ int Engine::setCamera(lua_State * L)
|
|||||||
vector<double> args;
|
vector<double> args;
|
||||||
for (int i = 1; i <= argc; i++)
|
for (int i = 1; i <= argc; i++)
|
||||||
{
|
{
|
||||||
int type = lua_type(L, i);
|
if (lua_isnumber(L, i))
|
||||||
if (type == LUA_TNUMBER || type == LUA_TSTRING)
|
|
||||||
args.push_back(lua_tonumber(L, i));
|
args.push_back(lua_tonumber(L, i));
|
||||||
else
|
else
|
||||||
args.push_back(0);
|
args.push_back(0);
|
||||||
|
27
anaglym.cc
27
anaglym.cc
@ -7,6 +7,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
enum EventType { EVENT_UPDATE };
|
enum EventType { EVENT_UPDATE };
|
||||||
@ -28,6 +30,7 @@ static SDL_Event userEvent;
|
|||||||
static SDL_cond * event_condition;
|
static SDL_cond * event_condition;
|
||||||
static SDL_mutex * event_mutex;
|
static SDL_mutex * event_mutex;
|
||||||
static SDL_mutex * event_queue_mutex;
|
static SDL_mutex * event_queue_mutex;
|
||||||
|
static SDL_mutex * engine_thread_ready_mutex;
|
||||||
static queue<Event> event_queue;
|
static queue<Event> event_queue;
|
||||||
Uint32 g_ticks;
|
Uint32 g_ticks;
|
||||||
|
|
||||||
@ -42,14 +45,24 @@ static int engine_thread(void * param)
|
|||||||
const char * program = (const char *) param;
|
const char * program = (const char *) param;
|
||||||
if (g_engine->load(program))
|
if (g_engine->load(program))
|
||||||
{
|
{
|
||||||
|
SDL_mutexV(engine_thread_ready_mutex);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
SDL_mutexP(event_mutex);
|
Event event;
|
||||||
SDL_CondWait(event_condition, event_mutex);
|
bool moreEvents = false;
|
||||||
bool moreEvents = true;
|
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)
|
while (moreEvents)
|
||||||
{
|
{
|
||||||
Event event;
|
|
||||||
SDL_mutexP(event_queue_mutex);
|
SDL_mutexP(event_queue_mutex);
|
||||||
if (event_queue.size() < 1)
|
if (event_queue.size() < 1)
|
||||||
moreEvents = false;
|
moreEvents = false;
|
||||||
@ -66,6 +79,8 @@ static int engine_thread(void * param)
|
|||||||
{
|
{
|
||||||
case EVENT_UPDATE:
|
case EVENT_UPDATE:
|
||||||
g_engine->update();
|
g_engine->update();
|
||||||
|
GLUquadric * quad = gluNewQuadric();
|
||||||
|
gluSphere(quad, 4.0, 16, 8);
|
||||||
lastUpdateCompleted = true;
|
lastUpdateCompleted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -167,10 +182,10 @@ static void mainloop()
|
|||||||
goto RET;
|
goto RET;
|
||||||
break;
|
break;
|
||||||
case SDL_USEREVENT:
|
case SDL_USEREVENT:
|
||||||
if (lastUpdateCompleted)
|
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
if (event.user.code == 0)
|
if (event.user.code == 0)
|
||||||
{
|
{
|
||||||
|
if (lastUpdateCompleted)
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
function update()
|
function update()
|
||||||
ballx, bally, ballz = ball:getPosition()
|
ballx, bally, ballz = ball:getPosition()
|
||||||
ag.setCamera(7, -6, 15, ballx, bally, ballz, 0, 0, 1)
|
ag.setCamera(7, -6, 15, ballx, bally, ballz, 0, 0, 1)
|
||||||
ag.startFrame()
|
|
||||||
ag.drawObjects()
|
ag.drawObjects()
|
||||||
ag.endFrame()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1)
|
--ag.setCamera(8, -8, 15, -8, 8, 4, 0, 0, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user