- Defined keys translation for SDL config
- Added boost thread files, that fixes all the threading/compiling/linking problems on Android ... - Added opengles 1.1 code, there are still some bugs I need to tackle ... and I should realy split this file now !!! - Added Android debug traces - Hardcoded resources to "/sdcard/Wagic/Res" for the moment on Android - Added a wagic SDL project for desktop, and the related SDL frontend used for Android. This frontend is currently mostly desktop based, it needs some work to be fully useable with touch and gesture on Android.
This commit is contained in:
51
Boost/lib/pthread/once.cpp
Normal file
51
Boost/lib/pthread/once.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (C) 2007 Anthony Williams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <boost/thread/once.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
BOOST_THREAD_DECL boost::uintmax_t once_global_epoch=UINTMAX_C(~0);
|
||||
BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
namespace
|
||||
{
|
||||
pthread_key_t epoch_tss_key;
|
||||
pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT;
|
||||
|
||||
extern "C" void delete_epoch_tss_data(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
|
||||
extern "C" void create_epoch_tss_key()
|
||||
{
|
||||
BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boost::uintmax_t& get_once_per_thread_epoch()
|
||||
{
|
||||
BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key));
|
||||
void* data=pthread_getspecific(epoch_tss_key);
|
||||
if(!data)
|
||||
{
|
||||
data=malloc(sizeof(boost::uintmax_t));
|
||||
BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data));
|
||||
*static_cast<boost::uintmax_t*>(data)=UINTMAX_C(~0);
|
||||
}
|
||||
return *static_cast<boost::uintmax_t*>(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
601
Boost/lib/pthread/thread.cpp
Normal file
601
Boost/lib/pthread/thread.cpp
Normal file
@@ -0,0 +1,601 @@
|
||||
// Copyright (C) 2001-2003
|
||||
// William E. Kempf
|
||||
// Copyright (C) 2007-8 Anthony Williams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/xtime.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/once.hpp>
|
||||
#include <boost/thread/tss.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#ifdef __linux__
|
||||
#include <sys/sysinfo.h>
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#elif defined BOOST_HAS_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "timeconv.inl"
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
thread_data_base::~thread_data_base()
|
||||
{}
|
||||
|
||||
struct thread_exit_callback_node
|
||||
{
|
||||
boost::detail::thread_exit_function_base* func;
|
||||
thread_exit_callback_node* next;
|
||||
|
||||
thread_exit_callback_node(boost::detail::thread_exit_function_base* func_,
|
||||
thread_exit_callback_node* next_):
|
||||
func(func_),next(next_)
|
||||
{}
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT;
|
||||
pthread_key_t current_thread_tls_key;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void tls_destructor(void* data)
|
||||
{
|
||||
boost::detail::thread_data_base* thread_info=static_cast<boost::detail::thread_data_base*>(data);
|
||||
if(thread_info)
|
||||
{
|
||||
while(!thread_info->tss_data.empty() || thread_info->thread_exit_callbacks)
|
||||
{
|
||||
while(thread_info->thread_exit_callbacks)
|
||||
{
|
||||
detail::thread_exit_callback_node* const current_node=thread_info->thread_exit_callbacks;
|
||||
thread_info->thread_exit_callbacks=current_node->next;
|
||||
if(current_node->func)
|
||||
{
|
||||
(*current_node->func)();
|
||||
delete current_node->func;
|
||||
}
|
||||
delete current_node;
|
||||
}
|
||||
for(std::map<void const*,tss_data_node>::iterator next=thread_info->tss_data.begin(),
|
||||
current,
|
||||
end=thread_info->tss_data.end();
|
||||
next!=end;)
|
||||
{
|
||||
current=next;
|
||||
++next;
|
||||
if(current->second.func && (current->second.value!=0))
|
||||
{
|
||||
(*current->second.func)(current->second.value);
|
||||
}
|
||||
thread_info->tss_data.erase(current);
|
||||
}
|
||||
}
|
||||
thread_info->self.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void create_current_thread_tls_key()
|
||||
{
|
||||
BOOST_VERIFY(!pthread_key_create(¤t_thread_tls_key,&tls_destructor));
|
||||
}
|
||||
}
|
||||
|
||||
boost::detail::thread_data_base* get_current_thread_data()
|
||||
{
|
||||
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
|
||||
return (boost::detail::thread_data_base*)pthread_getspecific(current_thread_tls_key);
|
||||
}
|
||||
|
||||
void set_current_thread_data(detail::thread_data_base* new_data)
|
||||
{
|
||||
boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
|
||||
BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data));
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
extern "C"
|
||||
{
|
||||
void* thread_proxy(void* param)
|
||||
{
|
||||
boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self;
|
||||
thread_info->self.reset();
|
||||
detail::set_current_thread_data(thread_info.get());
|
||||
try
|
||||
{
|
||||
thread_info->run();
|
||||
}
|
||||
catch(thread_interrupted const&)
|
||||
{
|
||||
}
|
||||
// Removed as it stops the debugger identifying the cause of the exception
|
||||
// Unhandled exceptions still cause the application to terminate
|
||||
// catch(...)
|
||||
// {
|
||||
// std::terminate();
|
||||
// }
|
||||
|
||||
detail::tls_destructor(thread_info.get());
|
||||
detail::set_current_thread_data(0);
|
||||
boost::lock_guard<boost::mutex> lock(thread_info->data_mutex);
|
||||
thread_info->done=true;
|
||||
thread_info->done_condition.notify_all();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
struct externally_launched_thread:
|
||||
detail::thread_data_base
|
||||
{
|
||||
externally_launched_thread()
|
||||
{
|
||||
interrupt_enabled=false;
|
||||
}
|
||||
|
||||
void run()
|
||||
{}
|
||||
|
||||
private:
|
||||
externally_launched_thread(externally_launched_thread&);
|
||||
void operator=(externally_launched_thread&);
|
||||
};
|
||||
|
||||
detail::thread_data_base* make_external_thread_data()
|
||||
{
|
||||
detail::thread_data_base* const me(new externally_launched_thread());
|
||||
me->self.reset(me);
|
||||
set_current_thread_data(me);
|
||||
return me;
|
||||
}
|
||||
|
||||
|
||||
detail::thread_data_base* get_or_make_current_thread_data()
|
||||
{
|
||||
detail::thread_data_base* current_thread_data(detail::get_current_thread_data());
|
||||
if(!current_thread_data)
|
||||
{
|
||||
current_thread_data=make_external_thread_data();
|
||||
}
|
||||
return current_thread_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
thread::thread()
|
||||
{}
|
||||
|
||||
void thread::start_thread()
|
||||
{
|
||||
thread_info->self=thread_info;
|
||||
int const res = pthread_create(&thread_info->thread_handle, 0, &thread_proxy, thread_info.get());
|
||||
if (res != 0)
|
||||
{
|
||||
thread_info->self.reset();
|
||||
boost::throw_exception(thread_resource_error());
|
||||
}
|
||||
}
|
||||
|
||||
thread::~thread()
|
||||
{
|
||||
detach();
|
||||
}
|
||||
|
||||
detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const
|
||||
{
|
||||
return thread_info;
|
||||
}
|
||||
|
||||
void thread::join()
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
bool do_join=false;
|
||||
|
||||
{
|
||||
unique_lock<mutex> lock(local_thread_info->data_mutex);
|
||||
while(!local_thread_info->done)
|
||||
{
|
||||
local_thread_info->done_condition.wait(lock);
|
||||
}
|
||||
do_join=!local_thread_info->join_started;
|
||||
|
||||
if(do_join)
|
||||
{
|
||||
local_thread_info->join_started=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(!local_thread_info->joined)
|
||||
{
|
||||
local_thread_info->done_condition.wait(lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(do_join)
|
||||
{
|
||||
void* result=0;
|
||||
BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
|
||||
lock_guard<mutex> lock(local_thread_info->data_mutex);
|
||||
local_thread_info->joined=true;
|
||||
local_thread_info->done_condition.notify_all();
|
||||
}
|
||||
|
||||
if(thread_info==local_thread_info)
|
||||
{
|
||||
thread_info.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool thread::timed_join(system_time const& wait_until)
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
bool do_join=false;
|
||||
|
||||
{
|
||||
unique_lock<mutex> lock(local_thread_info->data_mutex);
|
||||
while(!local_thread_info->done)
|
||||
{
|
||||
if(!local_thread_info->done_condition.timed_wait(lock,wait_until))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
do_join=!local_thread_info->join_started;
|
||||
|
||||
if(do_join)
|
||||
{
|
||||
local_thread_info->join_started=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(!local_thread_info->joined)
|
||||
{
|
||||
local_thread_info->done_condition.wait(lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(do_join)
|
||||
{
|
||||
void* result=0;
|
||||
BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result));
|
||||
lock_guard<mutex> lock(local_thread_info->data_mutex);
|
||||
local_thread_info->joined=true;
|
||||
local_thread_info->done_condition.notify_all();
|
||||
}
|
||||
|
||||
if(thread_info==local_thread_info)
|
||||
{
|
||||
thread_info.reset();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool thread::joinable() const
|
||||
{
|
||||
return (get_thread_info)();
|
||||
}
|
||||
|
||||
|
||||
void thread::detach()
|
||||
{
|
||||
detail::thread_data_ptr local_thread_info;
|
||||
thread_info.swap(local_thread_info);
|
||||
|
||||
if(local_thread_info)
|
||||
{
|
||||
lock_guard<mutex> lock(local_thread_info->data_mutex);
|
||||
if(!local_thread_info->join_started)
|
||||
{
|
||||
BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle));
|
||||
local_thread_info->join_started=true;
|
||||
local_thread_info->joined=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
|
||||
void sleep(const system_time& st)
|
||||
{
|
||||
detail::thread_data_base* const thread_info=detail::get_current_thread_data();
|
||||
|
||||
if(thread_info)
|
||||
{
|
||||
unique_lock<mutex> lk(thread_info->sleep_mutex);
|
||||
while(thread_info->sleep_condition.timed_wait(lk,st));
|
||||
}
|
||||
else
|
||||
{
|
||||
xtime const xt=get_xtime(st);
|
||||
|
||||
for (int foo=0; foo < 5; ++foo)
|
||||
{
|
||||
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
|
||||
timespec ts;
|
||||
to_timespec_duration(xt, ts);
|
||||
BOOST_VERIFY(!pthread_delay_np(&ts));
|
||||
# elif defined(BOOST_HAS_NANOSLEEP)
|
||||
timespec ts;
|
||||
to_timespec_duration(xt, ts);
|
||||
|
||||
// nanosleep takes a timespec that is an offset, not
|
||||
// an absolute time.
|
||||
nanosleep(&ts, 0);
|
||||
# else
|
||||
mutex mx;
|
||||
mutex::scoped_lock lock(mx);
|
||||
condition cond;
|
||||
cond.timed_wait(lock, xt);
|
||||
# endif
|
||||
xtime cur;
|
||||
xtime_get(&cur, TIME_UTC);
|
||||
if (xtime_cmp(xt, cur) <= 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void yield()
|
||||
{
|
||||
# if defined(BOOST_HAS_SCHED_YIELD)
|
||||
BOOST_VERIFY(!sched_yield());
|
||||
# elif defined(BOOST_HAS_PTHREAD_YIELD)
|
||||
BOOST_VERIFY(!pthread_yield());
|
||||
# else
|
||||
xtime xt;
|
||||
xtime_get(&xt, TIME_UTC);
|
||||
sleep(xt);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
unsigned thread::hardware_concurrency()
|
||||
{
|
||||
#if defined(PTW32_VERSION) || defined(__hpux)
|
||||
return pthread_num_processors_np();
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
int count;
|
||||
size_t size=sizeof(count);
|
||||
return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
|
||||
#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
|
||||
int const count=sysconf(_SC_NPROCESSORS_ONLN);
|
||||
return (count>0)?count:0;
|
||||
#elif defined(_GNU_SOURCE)
|
||||
return get_nprocs();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
thread::id thread::get_id() const
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
return id(local_thread_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
return id();
|
||||
}
|
||||
}
|
||||
|
||||
void thread::interrupt()
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
lock_guard<mutex> lk(local_thread_info->data_mutex);
|
||||
local_thread_info->interrupt_requested=true;
|
||||
if(local_thread_info->current_cond)
|
||||
{
|
||||
BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool thread::interruption_requested() const
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
lock_guard<mutex> lk(local_thread_info->data_mutex);
|
||||
return local_thread_info->interrupt_requested;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
thread::native_handle_type thread::native_handle()
|
||||
{
|
||||
detail::thread_data_ptr const local_thread_info=(get_thread_info)();
|
||||
if(local_thread_info)
|
||||
{
|
||||
lock_guard<mutex> lk(local_thread_info->data_mutex);
|
||||
return local_thread_info->thread_handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pthread_t();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
thread::id get_id()
|
||||
{
|
||||
boost::detail::thread_data_base* const thread_info=get_or_make_current_thread_data();
|
||||
return thread::id(thread_info?thread_info->shared_from_this():detail::thread_data_ptr());
|
||||
}
|
||||
|
||||
void interruption_point()
|
||||
{
|
||||
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
|
||||
if(thread_info && thread_info->interrupt_enabled)
|
||||
{
|
||||
lock_guard<mutex> lg(thread_info->data_mutex);
|
||||
if(thread_info->interrupt_requested)
|
||||
{
|
||||
thread_info->interrupt_requested=false;
|
||||
throw thread_interrupted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool interruption_enabled()
|
||||
{
|
||||
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
|
||||
return thread_info && thread_info->interrupt_enabled;
|
||||
}
|
||||
|
||||
bool interruption_requested()
|
||||
{
|
||||
boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data();
|
||||
if(!thread_info)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock_guard<mutex> lg(thread_info->data_mutex);
|
||||
return thread_info->interrupt_requested;
|
||||
}
|
||||
}
|
||||
|
||||
disable_interruption::disable_interruption():
|
||||
interruption_was_enabled(interruption_enabled())
|
||||
{
|
||||
if(interruption_was_enabled)
|
||||
{
|
||||
detail::get_current_thread_data()->interrupt_enabled=false;
|
||||
}
|
||||
}
|
||||
|
||||
disable_interruption::~disable_interruption()
|
||||
{
|
||||
if(detail::get_current_thread_data())
|
||||
{
|
||||
detail::get_current_thread_data()->interrupt_enabled=interruption_was_enabled;
|
||||
}
|
||||
}
|
||||
|
||||
restore_interruption::restore_interruption(disable_interruption& d)
|
||||
{
|
||||
if(d.interruption_was_enabled)
|
||||
{
|
||||
detail::get_current_thread_data()->interrupt_enabled=true;
|
||||
}
|
||||
}
|
||||
|
||||
restore_interruption::~restore_interruption()
|
||||
{
|
||||
if(detail::get_current_thread_data())
|
||||
{
|
||||
detail::get_current_thread_data()->interrupt_enabled=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void add_thread_exit_function(thread_exit_function_base* func)
|
||||
{
|
||||
detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
|
||||
thread_exit_callback_node* const new_node=
|
||||
new thread_exit_callback_node(func,current_thread_data->thread_exit_callbacks);
|
||||
current_thread_data->thread_exit_callbacks=new_node;
|
||||
}
|
||||
|
||||
tss_data_node* find_tss_data(void const* key)
|
||||
{
|
||||
detail::thread_data_base* const current_thread_data(get_current_thread_data());
|
||||
if(current_thread_data)
|
||||
{
|
||||
std::map<void const*,tss_data_node>::iterator current_node=
|
||||
current_thread_data->tss_data.find(key);
|
||||
if(current_node!=current_thread_data->tss_data.end())
|
||||
{
|
||||
return ¤t_node->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* get_tss_data(void const* key)
|
||||
{
|
||||
if(tss_data_node* const current_node=find_tss_data(key))
|
||||
{
|
||||
return current_node->value;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_new_tss_node(void const* key,
|
||||
boost::shared_ptr<tss_cleanup_function> func,
|
||||
void* tss_data)
|
||||
{
|
||||
detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
|
||||
current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data)));
|
||||
}
|
||||
|
||||
void erase_tss_node(void const* key)
|
||||
{
|
||||
detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
|
||||
current_thread_data->tss_data.erase(key);
|
||||
}
|
||||
|
||||
void set_tss_data(void const* key,
|
||||
boost::shared_ptr<tss_cleanup_function> func,
|
||||
void* tss_data,bool cleanup_existing)
|
||||
{
|
||||
if(tss_data_node* const current_node=find_tss_data(key))
|
||||
{
|
||||
if(cleanup_existing && current_node->func && (current_node->value!=0))
|
||||
{
|
||||
(*current_node->func)(current_node->value);
|
||||
}
|
||||
if(func || (tss_data!=0))
|
||||
{
|
||||
current_node->func=func;
|
||||
current_node->value=tss_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
erase_tss_node(key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add_new_tss_node(key,func,tss_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
133
Boost/lib/pthread/timeconv.inl
Normal file
133
Boost/lib/pthread/timeconv.inl
Normal file
@@ -0,0 +1,133 @@
|
||||
// Copyright (C) 2001-2003
|
||||
// William E. Kempf
|
||||
// Copyright (C) 2009 Anthony Williams
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// boostinspect:nounnamed
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace {
|
||||
const int MILLISECONDS_PER_SECOND = 1000;
|
||||
const int NANOSECONDS_PER_SECOND = 1000000000;
|
||||
const int NANOSECONDS_PER_MILLISECOND = 1000000;
|
||||
|
||||
const int MICROSECONDS_PER_SECOND = 1000000;
|
||||
const int NANOSECONDS_PER_MICROSECOND = 1000;
|
||||
|
||||
inline void to_time(int milliseconds, boost::xtime& xt)
|
||||
{
|
||||
int res = 0;
|
||||
res = boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||
|
||||
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
|
||||
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
|
||||
NANOSECONDS_PER_MILLISECOND);
|
||||
|
||||
if (xt.nsec >= NANOSECONDS_PER_SECOND)
|
||||
{
|
||||
++xt.sec;
|
||||
xt.nsec -= NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS)
|
||||
inline void to_timespec(const boost::xtime& xt, timespec& ts)
|
||||
{
|
||||
ts.tv_sec = static_cast<int>(xt.sec);
|
||||
ts.tv_nsec = static_cast<int>(xt.nsec);
|
||||
if(ts.tv_nsec >= NANOSECONDS_PER_SECOND)
|
||||
{
|
||||
ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND;
|
||||
ts.tv_nsec %= NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
inline void to_time(int milliseconds, timespec& ts)
|
||||
{
|
||||
boost::xtime xt;
|
||||
to_time(milliseconds, xt);
|
||||
to_timespec(xt, ts);
|
||||
}
|
||||
|
||||
inline void to_timespec_duration(const boost::xtime& xt, timespec& ts)
|
||||
{
|
||||
boost::xtime cur;
|
||||
int res = 0;
|
||||
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||
|
||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||
{
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ts.tv_sec = xt.sec - cur.sec;
|
||||
ts.tv_nsec = xt.nsec - cur.nsec;
|
||||
|
||||
if( ts.tv_nsec < 0 )
|
||||
{
|
||||
ts.tv_sec -= 1;
|
||||
ts.tv_nsec += NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
if(ts.tv_nsec >= NANOSECONDS_PER_SECOND)
|
||||
{
|
||||
ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND;
|
||||
ts.tv_nsec %= NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void to_duration(boost::xtime xt, int& milliseconds)
|
||||
{
|
||||
boost::xtime cur;
|
||||
int res = 0;
|
||||
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||
|
||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||
milliseconds = 0;
|
||||
else
|
||||
{
|
||||
if (cur.nsec > xt.nsec)
|
||||
{
|
||||
xt.nsec += NANOSECONDS_PER_SECOND;
|
||||
--xt.sec;
|
||||
}
|
||||
milliseconds = (int)((xt.sec - cur.sec) * MILLISECONDS_PER_SECOND) +
|
||||
(((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MILLISECOND/2)) /
|
||||
NANOSECONDS_PER_MILLISECOND);
|
||||
}
|
||||
}
|
||||
|
||||
inline void to_microduration(boost::xtime xt, int& microseconds)
|
||||
{
|
||||
boost::xtime cur;
|
||||
int res = 0;
|
||||
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||
|
||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||
microseconds = 0;
|
||||
else
|
||||
{
|
||||
if (cur.nsec > xt.nsec)
|
||||
{
|
||||
xt.nsec += NANOSECONDS_PER_SECOND;
|
||||
--xt.sec;
|
||||
}
|
||||
microseconds = (int)((xt.sec - cur.sec) * MICROSECONDS_PER_SECOND) +
|
||||
(((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MICROSECOND/2)) /
|
||||
NANOSECONDS_PER_MICROSECOND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change Log:
|
||||
// 1 Jun 01 Initial creation.
|
||||
@@ -25,27 +25,34 @@ std::string ToHex(T* pointer)
|
||||
#define OutputDebugString(val) (std::cerr << val);
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#ifdef _DEBUG
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
#ifndef QT_CONFIG
|
||||
#ifdef QT_CONFIG
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
OutputDebugString(stream.str().c_str()); \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
qDebug(stream.str().c_str()); \
|
||||
}
|
||||
#elif defined (ANDROID)
|
||||
#include <android/log.h>
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString; \
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "Wagic", stream.str().c_str());\
|
||||
}
|
||||
#else
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString << std::endl; \
|
||||
qDebug(stream.str().c_str()); \
|
||||
OutputDebugString(stream.str().c_str()); \
|
||||
}
|
||||
#endif //QT_CONFIG
|
||||
|
||||
#endif //#ifdef _DEBUG
|
||||
#endif // QT_CONFIG
|
||||
#endif // Win32, Linux
|
||||
#endif //#ifdef _DEBUG
|
||||
|
||||
#if defined (DEBUG)
|
||||
#ifndef DebugTrace
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
typedef u32 LocalKeySym;
|
||||
#define LOCAL_KEY_NONE Qt::Key_unknown
|
||||
|
||||
#elif defined(SDL_CONFIG)
|
||||
#include <SDL.h>
|
||||
typedef SDLKey LocalKeySym;
|
||||
#define LOCAL_KEY_NONE SDLK_UNKNOWN
|
||||
|
||||
#elif defined(WIN32)
|
||||
#include <windows.h>
|
||||
typedef WPARAM LocalKeySym;
|
||||
@@ -50,7 +55,6 @@ typedef u32 LocalKeySym;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
bool JGEGetButtonState(const JButton button);
|
||||
bool JGEGetButtonClick(const JButton button);
|
||||
void JGECreateDefaultBindings();
|
||||
|
||||
@@ -101,22 +101,13 @@ enum {
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
# import <OpenGLES/ES1/glext.h>
|
||||
# import <OpenGLES/ES1/glext.h>
|
||||
#elif defined (ANDROID)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#elif defined (WIN32) || defined (LINUX)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
//Android GL1 support TODO
|
||||
/*
|
||||
#elif defined (ANDROID)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
*/
|
||||
//Android GL2 support
|
||||
#elif defined (ANDROID)
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#endif
|
||||
#else
|
||||
# include <QtOpenGL>
|
||||
|
||||
@@ -269,6 +269,8 @@ void JFileSystem::SetResourceRoot(const string& resourceRoot)
|
||||
NSString *fullpath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathUTF8];
|
||||
mResourceRoot = [fullpath cStringUsingEncoding:1];
|
||||
mResourceRoot += "/";
|
||||
#elif defined (ANDROID)
|
||||
mResourceRoot = "/sdcard/Wagic/Res/";
|
||||
#else
|
||||
mResourceRoot = resourceRoot;
|
||||
#endif
|
||||
|
||||
448
JGE/src/SDLmain.cpp
Normal file
448
JGE/src/SDLmain.cpp
Normal file
@@ -0,0 +1,448 @@
|
||||
#include <SDL.h>
|
||||
#ifndef ANDROID
|
||||
#include <SDL_opengl.h>
|
||||
#else
|
||||
#include <SDL_opengles.h>
|
||||
#endif
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JTypes.h"
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JRenderer.h"
|
||||
#include "../include/JGameLauncher.h"
|
||||
#include "DebugRoutines.h"
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#undef GL_VERSION_2_0
|
||||
|
||||
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
|
||||
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
|
||||
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
|
||||
|
||||
#define WAGIC_UPDATE_EVENT (SDL_USEREVENT + 1)
|
||||
|
||||
class SdlApp {
|
||||
private:
|
||||
bool Running;
|
||||
SDL_Surface* Surf_Display;
|
||||
SDL_Rect viewPort;
|
||||
|
||||
public:
|
||||
SdlApp() {
|
||||
Surf_Display = NULL;
|
||||
|
||||
Running = true;
|
||||
};
|
||||
|
||||
int OnExecute() {
|
||||
if(OnInit() == false) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_Event Event;
|
||||
|
||||
while(Running) {
|
||||
while(SDL_PollEvent(&Event)) {
|
||||
OnEvent(&Event);
|
||||
}
|
||||
|
||||
OnLoop();
|
||||
// OnRender();
|
||||
}
|
||||
|
||||
OnCleanup();
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
public:
|
||||
bool OnInit();
|
||||
|
||||
void OnResize(int width, int height) {
|
||||
if ((GLfloat)width / (GLfloat)height <= ACTUAL_RATIO)
|
||||
{
|
||||
viewPort.x = 0;
|
||||
viewPort.y = -((width/ACTUAL_RATIO)-height)/2;
|
||||
viewPort.w = width;
|
||||
viewPort.h = width / ACTUAL_RATIO;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewPort.x = -(height*ACTUAL_RATIO-width)/2;
|
||||
viewPort.y = 0;
|
||||
viewPort.w = height * ACTUAL_RATIO;
|
||||
viewPort.h = height;
|
||||
}
|
||||
|
||||
glViewport(viewPort.x, viewPort.y, viewPort.w, viewPort.h);
|
||||
|
||||
JRenderer::GetInstance()->SetActualWidth(viewPort.w);
|
||||
JRenderer::GetInstance()->SetActualHeight(viewPort.h);
|
||||
glScissor(0, 0, width, height);
|
||||
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
|
||||
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
|
||||
glLoadIdentity (); // Reset The Projection Matrix
|
||||
|
||||
//gluOrtho2D(0.0f, (float) (viewPort.w)-1.0f, 0.0f, (float) (viewPort.h)-1.0f);
|
||||
|
||||
#if (defined GL_VERSION_ES_CM_1_1)
|
||||
glOrthof(0.0f, (float) (viewPort.w)-1.0f, 0.0f, (float) (viewPort.h)-1.0f, -1.0f, 1.0f);
|
||||
#else
|
||||
gluOrtho2D(0.0f, (float) (viewPort.w)-1.0f, 0.0f, (float) (viewPort.h)-1.0f);
|
||||
#endif
|
||||
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
|
||||
glLoadIdentity (); // Reset The Modelview Matrix
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
|
||||
#endif
|
||||
};
|
||||
void OnKeyPressed(const SDL_KeyboardEvent& event);
|
||||
void OnMouseClicked(const SDL_MouseButtonEvent& event);
|
||||
void OnMouseMoved(const SDL_MouseMotionEvent& event);
|
||||
void OnEvent(SDL_Event* Event) {
|
||||
switch(Event->type){
|
||||
case SDL_QUIT:
|
||||
Running = false;
|
||||
break;
|
||||
case SDL_VIDEORESIZE:
|
||||
OnResize(Event->resize.w, Event->resize.h);
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
OnKeyPressed(Event->key);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
OnMouseMoved(Event->motion);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
OnMouseClicked(Event->button);
|
||||
break;
|
||||
case WAGIC_UPDATE_EVENT:
|
||||
OnUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
void OnLoop() {
|
||||
};
|
||||
|
||||
void OnCleanup() {
|
||||
SDL_FreeSurface(Surf_Display);
|
||||
SDL_Quit();
|
||||
}
|
||||
};
|
||||
|
||||
uint64_t lastTickCount;
|
||||
JGE* g_engine = NULL;
|
||||
JApp* g_app = NULL;
|
||||
JGameLauncher* g_launcher = NULL;
|
||||
SdlApp *g_SdlApp = NULL;
|
||||
|
||||
|
||||
|
||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||
{
|
||||
{ SDLK_RETURN, JGE_BTN_MENU },
|
||||
{ SDLK_KP_ENTER, JGE_BTN_MENU },
|
||||
{ SDLK_ESCAPE, JGE_BTN_MENU },
|
||||
{ SDLK_BACKSPACE, JGE_BTN_CTRL },
|
||||
{ SDLK_UP, JGE_BTN_UP },
|
||||
{ SDLK_DOWN, JGE_BTN_DOWN },
|
||||
{ SDLK_LEFT, JGE_BTN_LEFT },
|
||||
{ SDLK_RIGHT, JGE_BTN_RIGHT },
|
||||
{ SDLK_SPACE, JGE_BTN_OK },
|
||||
{ SDLK_TAB, JGE_BTN_CANCEL },
|
||||
{ SDLK_j, JGE_BTN_PRI },
|
||||
{ SDLK_k, JGE_BTN_SEC },
|
||||
{ SDLK_q, JGE_BTN_PREV },
|
||||
{ SDLK_a, JGE_BTN_NEXT },
|
||||
// fullscreen management seems somehow broken in JGE, it works fine with Qt directly
|
||||
// { Qt::Key_F, JGE_BTN_FULLSCREEN },
|
||||
};
|
||||
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
|
||||
int JGEGetTime()
|
||||
{
|
||||
return (int)SDL_GetTicks();
|
||||
}
|
||||
|
||||
bool JGEToggleFullscreen()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InitGame(void)
|
||||
{
|
||||
g_engine = JGE::GetInstance();
|
||||
g_app = g_launcher->GetGameApp();
|
||||
g_app->Create();
|
||||
g_engine->SetApp(g_app);
|
||||
|
||||
JRenderer::GetInstance()->Enable2D();
|
||||
lastTickCount = JGEGetTime();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DestroyGame(void)
|
||||
{
|
||||
g_engine->SetApp(NULL);
|
||||
if (g_app)
|
||||
{
|
||||
g_app->Destroy();
|
||||
delete g_app;
|
||||
g_app = NULL;
|
||||
}
|
||||
|
||||
JGE::Destroy();
|
||||
|
||||
g_engine = NULL;
|
||||
}
|
||||
|
||||
Uint32 OnTimer( Uint32 interval )
|
||||
{
|
||||
SDL_Event event;
|
||||
event.user.type = WAGIC_UPDATE_EVENT;
|
||||
SDL_PushEvent(&event);
|
||||
return 30;
|
||||
}
|
||||
|
||||
void SdlApp::OnUpdate() {
|
||||
static int tickCount;
|
||||
Uint32 dt;
|
||||
tickCount = JGEGetTime();
|
||||
dt = (tickCount - lastTickCount);
|
||||
lastTickCount = tickCount;
|
||||
|
||||
if(g_engine->IsDone()) {
|
||||
SDL_Event event;
|
||||
event.user.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
try {
|
||||
g_engine->SetDelta((float)dt / 1000.0f);
|
||||
g_engine->Update((float)dt / 1000.0f);
|
||||
} catch(out_of_range& oor) {
|
||||
cerr << oor.what();
|
||||
}
|
||||
|
||||
OnRender();
|
||||
}
|
||||
|
||||
void SdlApp::OnKeyPressed(const SDL_KeyboardEvent& event)
|
||||
{
|
||||
if(event.type == SDL_KEYDOWN) {
|
||||
g_engine->HoldKey_NoRepeat((LocalKeySym)event.keysym.sym);
|
||||
} else if(event.type == SDL_KEYUP) {
|
||||
g_engine->ReleaseKey((LocalKeySym)event.keysym.sym);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlApp::OnMouseMoved(const SDL_MouseMotionEvent& event)
|
||||
{
|
||||
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
|
||||
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
|
||||
|
||||
if (event.y >= viewPort.y &&
|
||||
event.y <= viewPort.y + viewPort.h &&
|
||||
event.x >= viewPort.x &&
|
||||
event.x <= viewPort.x + viewPort.w) {
|
||||
g_engine->LeftClicked(
|
||||
((event.x-viewPort.x)*SCREEN_WIDTH)/actualWidth,
|
||||
((event.y-viewPort.y)*SCREEN_HEIGHT)/actualHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlApp::OnMouseClicked(const SDL_MouseButtonEvent& event)
|
||||
{
|
||||
if(event.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
if(event.button == SDL_BUTTON_LEFT) /* Left button */
|
||||
{
|
||||
// this is intended to convert window coordinate into game coordinate.
|
||||
// this is correct only if the game and window have the same aspect ratio, otherwise, it's just wrong
|
||||
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
|
||||
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight();
|
||||
|
||||
if (event.y >= viewPort.y &&
|
||||
event.y <= viewPort.y + viewPort.h &&
|
||||
event.x >= viewPort.x &&
|
||||
event.x <= viewPort.x + viewPort.w) {
|
||||
g_engine->LeftClicked(
|
||||
((event.x-viewPort.x)*SCREEN_WIDTH)/actualWidth,
|
||||
((event.y-viewPort.y)*SCREEN_HEIGHT)/actualHeight);
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||
} else if(event.y < viewPort.y) {
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_MENU);
|
||||
} else if(event.y > viewPort.y + viewPort.h) {
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_NEXT);
|
||||
}
|
||||
}
|
||||
else if(event.button == SDL_BUTTON_RIGHT) /* Right button */
|
||||
{ /* next phase please */
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_PREV);
|
||||
}
|
||||
else if(event.button == SDL_BUTTON_MIDDLE) /* Middle button */
|
||||
{ /* interrupt please */
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
||||
}
|
||||
} else if (event.type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
if(event.button == SDL_BUTTON_LEFT)
|
||||
{
|
||||
if (event.y >= viewPort.y &&
|
||||
event.y <= viewPort.y + viewPort.h &&
|
||||
event.x >= viewPort.x &&
|
||||
event.x <= viewPort.x + viewPort.w) {
|
||||
g_engine->ReleaseKey(JGE_BTN_OK);
|
||||
} else if(event.y < viewPort.y) {
|
||||
g_engine->ReleaseKey(JGE_BTN_MENU);
|
||||
} else if(event.y > viewPort.y + viewPort.h) {
|
||||
g_engine->ReleaseKey(JGE_BTN_NEXT);
|
||||
}
|
||||
}
|
||||
else if(event.button == SDL_BUTTON_RIGHT)
|
||||
{ /* next phase please */
|
||||
g_engine->ReleaseKey(JGE_BTN_PREV);
|
||||
}
|
||||
else if(event.button == SDL_BUTTON_MIDDLE)
|
||||
{ /* interrupt please */
|
||||
g_engine->ReleaseKey(JGE_BTN_SEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SdlApp::OnInit() {
|
||||
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
|
||||
|
||||
if((Surf_Display = SDL_SetVideoMode(ACTUAL_SCREEN_WIDTH, ACTUAL_SCREEN_HEIGHT, 32, /*SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER |*/ SDL_OPENGL | SDL_RESIZABLE)) == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption(g_launcher->GetName(), "");
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
#if (defined GL_ES_VERSION_2_0)
|
||||
glClearDepthf(1.0f); // Depth Buffer Setup
|
||||
#else
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
#endif// (defined GL_ES_VERSION_2_0)
|
||||
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
|
||||
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
|
||||
|
||||
#else
|
||||
#if (defined GL_VERSION_ES_CM_1_1)
|
||||
glClearDepthf(1.0f); // Depth Buffer Setup
|
||||
#else
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
#endif
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
|
||||
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
|
||||
glShadeModel(GL_SMOOTH); // Select Smooth Shading
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most Accurate
|
||||
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Set Line Antialiasing
|
||||
glEnable(GL_LINE_SMOOTH); // Enable it!
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
#endif
|
||||
|
||||
glEnable(GL_CULL_FACE); // do not calculate inside of poly's
|
||||
glFrontFace(GL_CCW); // counter clock-wise polygons are out
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST); // Enable Clipping
|
||||
|
||||
|
||||
OnResize(ACTUAL_SCREEN_WIDTH, ACTUAL_SCREEN_HEIGHT);
|
||||
|
||||
/* opengl needs to be fully initialized before starting the game */
|
||||
if (!InitGame())
|
||||
{
|
||||
cerr << "Could not init the game\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
JGECreateDefaultBindings();
|
||||
|
||||
SDL_SetTimer(5, OnTimer);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
void SdlApp::OnRender() {
|
||||
|
||||
if(g_engine)
|
||||
g_engine->Render();
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
};
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
int SDL_main(int argc, char * argv[])
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
#endif //ANDROID
|
||||
{
|
||||
DebugTrace("I R in da native");
|
||||
|
||||
g_launcher = new JGameLauncher();
|
||||
|
||||
u32 flags = g_launcher->GetInitFlags();
|
||||
|
||||
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
|
||||
{
|
||||
JRenderer::Set3DFlag(true);
|
||||
}
|
||||
|
||||
g_SdlApp = new SdlApp();
|
||||
|
||||
int result = g_SdlApp->OnExecute();
|
||||
|
||||
if (g_launcher)
|
||||
delete g_launcher;
|
||||
|
||||
if(g_SdlApp)
|
||||
delete g_SdlApp;
|
||||
|
||||
// Shutdown
|
||||
DestroyGame();
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#if (!defined IOS)
|
||||
#if (!defined IOS) && (!defined QT_CONFIG)
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable : 4786)
|
||||
#pragma comment( lib, "giflib.lib" )
|
||||
@@ -42,12 +42,18 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define checkGlError() \
|
||||
void checkGlError()
|
||||
{
|
||||
GLenum glError = glGetError();
|
||||
if(glError != 0)
|
||||
printf("%s : %u : GLerror is %u\n", __FUNCTION__, __LINE__, glError);
|
||||
}
|
||||
/*#define checkGlError() \
|
||||
{ \
|
||||
GLenum glError = glGetError(); \
|
||||
if(glError != 0) \
|
||||
printf("%s : %u : GLerror is %u\n", __FUNCTION__, __LINE__, glError); \
|
||||
}
|
||||
}/*/
|
||||
#else
|
||||
#define checkGlError() (void(0))
|
||||
#endif
|
||||
@@ -955,32 +961,44 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( prog2 );
|
||||
checkGlError();
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( prog2_positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), vVertices );
|
||||
checkGlError();
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( prog2_texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
|
||||
checkGlError();
|
||||
// Load the colors
|
||||
glVertexAttribPointer ( prog2_colorLoc, 4, GL_UNSIGNED_BYTE,
|
||||
GL_TRUE, 4 * sizeof(GLubyte), colorCoords );
|
||||
checkGlError();
|
||||
|
||||
glEnableVertexAttribArray ( prog2_positionLoc );
|
||||
checkGlError();
|
||||
glEnableVertexAttribArray ( prog2_texCoordLoc );
|
||||
checkGlError();
|
||||
glEnableVertexAttribArray ( prog2_colorLoc );
|
||||
checkGlError();
|
||||
|
||||
// Load the MVP matrix
|
||||
glUniformMatrix4fv( prog2_mvpLoc, 1, GL_FALSE, (GLfloat*) &mvpMatrix.m[0][0] );
|
||||
checkGlError();
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
checkGlError();
|
||||
glBindTexture ( GL_TEXTURE_2D, mCurrentTex );
|
||||
checkGlError();
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( prog2_samplerLoc, 0 );
|
||||
checkGlError();
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
checkGlError();
|
||||
|
||||
#else
|
||||
glPushMatrix();
|
||||
@@ -988,7 +1006,7 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
glRotatef(-angle*RAD2DEG, 0.0f, 0.0f, 1.0f);
|
||||
glScalef(xScale, yScale, 1.0f);
|
||||
|
||||
#if (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
#if (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
@@ -1121,6 +1139,41 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* pt)
|
||||
|
||||
//glDrawElements ( GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_SHORT, indices );
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat vertCoords[] = {
|
||||
pt[0].x, pt[0].y,
|
||||
pt[1].x, pt[1].y,
|
||||
pt[3].x, pt[3].y,
|
||||
pt[2].x, pt[2].y,
|
||||
};
|
||||
|
||||
GLfloat texCoords[] = {
|
||||
uv[0].x, uv[0].y,
|
||||
uv[1].x, uv[1].y,
|
||||
uv[3].x, uv[3].y,
|
||||
uv[2].x, uv[2].y,
|
||||
};
|
||||
|
||||
GLubyte colorCoords[] = {
|
||||
quad->mColor[0].r, quad->mColor[0].g, quad->mColor[0].b, quad->mColor[0].a,
|
||||
quad->mColor[1].r, quad->mColor[1].g, quad->mColor[1].b, quad->mColor[1].a,
|
||||
quad->mColor[3].r, quad->mColor[3].g, quad->mColor[3].b, quad->mColor[3].a,
|
||||
quad->mColor[2].r, quad->mColor[2].g, quad->mColor[2].b, quad->mColor[2].a,
|
||||
};
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,0,vertCoords);
|
||||
glTexCoordPointer(2,GL_FLOAT,0, texCoords);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorCoords );
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glRasterPos2f(pt[0].x, pt[0].y);
|
||||
|
||||
@@ -1195,7 +1248,33 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat vVertices[] = {
|
||||
x, y+height,
|
||||
x, y,
|
||||
x+width, y+height,
|
||||
x+width, y,
|
||||
};
|
||||
|
||||
GLubyte colors[] = {
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
};
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,0,vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
|
||||
@@ -1264,6 +1343,31 @@ void JRenderer::DrawRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_LINE_LOOP,0,4);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat vertCoords[] = {
|
||||
x, y,
|
||||
x, y+height,
|
||||
x+width, y+height,
|
||||
x+width, y,
|
||||
};
|
||||
|
||||
GLubyte colorCoords[] = {
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
};
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,0,vertCoords);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorCoords );
|
||||
glDrawArrays(GL_LINE_LOOP,0,4);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -1301,7 +1405,6 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
FillRect(x, y, width, height, col);
|
||||
}
|
||||
|
||||
|
||||
void JRenderer::FillRect(float x, float y, float width, float height, JColor* colors)
|
||||
{
|
||||
checkGlError();
|
||||
@@ -1339,6 +1442,30 @@ void JRenderer::FillRect(float x, float y, float width, float height, JColor* co
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat vVertices[] = {
|
||||
x, y+height,
|
||||
x, y,
|
||||
x+width, y+height,
|
||||
x+width, y,
|
||||
};
|
||||
|
||||
GLubyte cols[] = {
|
||||
colors[0].r, colors[0].g, colors[0].b, colors[0].a,
|
||||
colors[2].r, colors[2].g, colors[2].b, colors[2].a,
|
||||
colors[1].r, colors[1].g, colors[1].b, colors[1].a,
|
||||
colors[3].r, colors[3].g, colors[3].b, colors[3].a,
|
||||
};
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,0,vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cols );
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
@@ -1404,6 +1531,28 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat vVertices[] = {
|
||||
x1, SCREEN_HEIGHT_F-y1, 0.0f,
|
||||
x2, SCREEN_HEIGHT_F-y2, 0.0f,
|
||||
};
|
||||
|
||||
GLubyte cols[] = {
|
||||
col.r, col.g, col.b, col.a,
|
||||
col.r, col.g, col.b, col.a,
|
||||
};
|
||||
|
||||
glVertexPointer(2,GL_FLOAT,0,vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cols );
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -1424,7 +1573,7 @@ void JRenderer::Plot(float x, float y, PIXEL_TYPE color)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
JColor col;
|
||||
col.color = color;
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) && (!defined GL_VERSION_ES_CM_1_1)
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2f(x, SCREEN_HEIGHT_F-y);
|
||||
@@ -1444,7 +1593,7 @@ void JRenderer::PlotArray(float *x, float *y, int count, PIXEL_TYPE color)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
JColor col;
|
||||
col.color = color;
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) && (!defined GL_VERSION_ES_CM_1_1)
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_POINTS);
|
||||
for (int i=0;i<count;i++)
|
||||
@@ -1477,7 +1626,7 @@ static int getNextPower2(int width)
|
||||
}
|
||||
|
||||
|
||||
#if (!defined IOS)
|
||||
#if (!defined IOS) && (!defined QT_CONFIG)
|
||||
static void jpg_null(j_decompress_ptr cinfo __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
@@ -1665,8 +1814,10 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
||||
|
||||
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
|
||||
LoadJPG(textureInfo, filename);
|
||||
#if (!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
||||
else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL)
|
||||
LoadGIF(textureInfo,filename);
|
||||
#endif
|
||||
else if(strstr(filename, ".png")!=NULL || strstr(filename, ".PNG")!=NULL)
|
||||
LoadPNG(textureInfo, filename);
|
||||
|
||||
@@ -1710,7 +1861,8 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
DWORD* line;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
||||
if (!fileSystem->OpenFile(filename))
|
||||
return JGE_ERR_CANT_OPEN_FILE;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL)
|
||||
@@ -1781,8 +1933,8 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
int g = (color32 >> 8) & 0xff;
|
||||
int b = (color32 >> 16) & 0xff;
|
||||
|
||||
color32 = r | (g << 8) | (b << 16) | (a << 24);
|
||||
*(p32+x) = color32;
|
||||
color32 = r | (g << 8) | (b << 16) | (a << 24);
|
||||
*(p32+x) = color32;
|
||||
|
||||
}
|
||||
p32 += tw;
|
||||
@@ -1821,7 +1973,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
// }
|
||||
|
||||
|
||||
|
||||
#if (!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// GIF Support
|
||||
int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc, int mode __attribute__((unused)), int TextureFormat __attribute__((unused)))
|
||||
@@ -1983,6 +2135,7 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
||||
fileSys->CloseFile();
|
||||
return ;//*/
|
||||
}
|
||||
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
||||
|
||||
#elif (defined IOS)
|
||||
|
||||
@@ -2316,7 +2469,11 @@ void JRenderer::Enable2D()
|
||||
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
|
||||
glLoadIdentity (); // Reset The Projection Matrix
|
||||
|
||||
gluOrtho2D(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f);
|
||||
#if (defined GL_VERSION_ES_CM_1_1)
|
||||
glOrthof(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f, -1.0f, 1.0f);
|
||||
#else
|
||||
gluOrtho2D(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f);
|
||||
#endif
|
||||
|
||||
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
|
||||
glLoadIdentity (); // Reset The Modelview Matrix
|
||||
@@ -2439,6 +2596,26 @@ void JRenderer::RenderTriangles(JTexture* texture, Vertex3D *vertices, int start
|
||||
glDrawArrays(GL_TRIANGLES,0,count*3);
|
||||
|
||||
delete[] colorCoords;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLubyte* colorCoords = new GLubyte[count*3*4];
|
||||
memset(colorCoords, 255, count*3*4);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), &vertices[index].x);
|
||||
glTexCoordPointer(2,GL_FLOAT,5 * sizeof(GLfloat), &vertices[index].u);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colorCoords );
|
||||
glDrawArrays(GL_TRIANGLES,0,count*3);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] colorCoords;
|
||||
|
||||
#else
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -2478,9 +2655,9 @@ void JRenderer::FillPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
checkGlError();
|
||||
JColor col;
|
||||
col.color = color;
|
||||
int i;
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
int i;
|
||||
GLubyte* colors = new GLubyte[count*4];
|
||||
GLfloat* vVertices = new GLfloat[count*3];
|
||||
|
||||
@@ -2520,12 +2697,44 @@ void JRenderer::FillPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLubyte* colors = new GLubyte[count*4];
|
||||
GLfloat* vVertices = new GLfloat[count*3];
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
for(i=0; i < count;i++)
|
||||
{
|
||||
vVertices[3*i+0] = x[i];
|
||||
vVertices[3*i+1] = SCREEN_HEIGHT_F-y[i];
|
||||
vVertices[3*i+2] = 0.0f;
|
||||
}
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,count);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
||||
for(int i=0; i<count;i++)
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
glVertex2f(x[i],SCREEN_HEIGHT_F-y[i]);
|
||||
}
|
||||
@@ -2545,9 +2754,9 @@ void JRenderer::DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
checkGlError();
|
||||
JColor col;
|
||||
col.color = color;
|
||||
int i;
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
int i;
|
||||
int number = count+1;
|
||||
GLfloat* vVertices = new GLfloat[3*number];
|
||||
GLubyte* colors = new GLubyte[4*number];
|
||||
@@ -2591,12 +2800,52 @@ void JRenderer::DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
int number = count+1;
|
||||
GLfloat* vVertices = new GLfloat[3*number];
|
||||
GLubyte* colors = new GLubyte[4*number];
|
||||
|
||||
for(i = 0; i < number; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
for(i=0; i < count;i++)
|
||||
{
|
||||
vVertices[3*i+0] = x[i];
|
||||
vVertices[3*i+1] = SCREEN_HEIGHT_F-y[i];
|
||||
vVertices[3*i+2] = 0.0f;
|
||||
}
|
||||
|
||||
vVertices[3*(number-1)+0] = x[0];
|
||||
vVertices[3*(number-1)+1] = SCREEN_HEIGHT_F-y[0];
|
||||
vVertices[3*(number-1)+2] = 0.0f;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_LINE_STRIP,0,number);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
for(int i=0; i<count;i++)
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
glVertex2f(x[i],SCREEN_HEIGHT_F-y[i]);
|
||||
}
|
||||
@@ -2691,6 +2940,44 @@ void JRenderer::DrawCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_LINE_STRIP,0,number);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
int i, index;
|
||||
const int number = 181;
|
||||
GLfloat vVertices[number][3];
|
||||
GLubyte colors[number][4];
|
||||
|
||||
for(i = 0; i < number; i++)
|
||||
{
|
||||
colors[i][0]= col.r;
|
||||
colors[i][1]= col.g;
|
||||
colors[i][2]= col.b;
|
||||
colors[i][3]= col.a;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
for(i=0; i < 360;i+=2, index++)
|
||||
{
|
||||
vVertices[index][0] = x+radius*COSF(i);
|
||||
vVertices[index][1] = SCREEN_HEIGHT_F-y+radius*SINF(i);
|
||||
vVertices[index][2] = 0.0f;
|
||||
}
|
||||
|
||||
vVertices[number-1][0] = x+radius*COSF(0);
|
||||
vVertices[number-1][1] = SCREEN_HEIGHT_F-y+radius*SINF(0);
|
||||
vVertices[number-1][2] = 0.0f;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_LINE_STRIP,0,number);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -2765,6 +3052,48 @@ void JRenderer::FillCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
glUniformMatrix4fv( prog1_mvpLoc, 1, GL_FALSE, (GLfloat*) &theMvpMatrix.m[0][0] );
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,number);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
int i, index;
|
||||
const int number = 182;
|
||||
GLfloat vVertices[number][3];
|
||||
GLubyte colors[number][4];
|
||||
|
||||
for(i = 0; i < number; i++)
|
||||
{
|
||||
colors[i][0]= col.r;
|
||||
colors[i][1]= col.g;
|
||||
colors[i][2]= col.b;
|
||||
colors[i][3]= col.a;
|
||||
}
|
||||
|
||||
vVertices[0][0] = x;
|
||||
vVertices[0][1] = SCREEN_HEIGHT_F-y;
|
||||
vVertices[0][2] = 0.0f;
|
||||
|
||||
index = 1;
|
||||
for(i=0; i < 360;i+=2, index++)
|
||||
{
|
||||
vVertices[index][0] = x+radius*COSF(i);
|
||||
vVertices[index][1] = SCREEN_HEIGHT_F-y+radius*SINF(i);
|
||||
vVertices[index][2] = 0.0f;
|
||||
}
|
||||
|
||||
vVertices[number-1][0] = x+radius*COSF(0);
|
||||
vVertices[number-1][1] = SCREEN_HEIGHT_F-y+radius*SINF(0);
|
||||
vVertices[number-1][2] = 0.0f;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,number);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -2799,9 +3128,9 @@ void JRenderer::DrawPolygon(float x, float y, float size, int count, float start
|
||||
float angle = startingAngle*RAD2DEG;
|
||||
float steps = 360.0f/count;
|
||||
size /= 2;
|
||||
int i;
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
int i;
|
||||
GLfloat* vVertices = new GLfloat[3*count];
|
||||
GLubyte* colors = new GLubyte[4*count];
|
||||
|
||||
@@ -2843,12 +3172,49 @@ void JRenderer::DrawPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat* vVertices = new GLfloat[3*count];
|
||||
GLubyte* colors = new GLubyte[4*count];
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
vVertices[3*i+0] = x+size*COSF((int)angle);
|
||||
vVertices[3*i+1] = SCREEN_HEIGHT_F-(y+size*SINF((int)angle));
|
||||
vVertices[3*i+2] = 0.0f;
|
||||
angle += steps;
|
||||
if (angle >= 360.0f)
|
||||
angle -= 360.0f;
|
||||
}
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_LINE_LOOP,0,count);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
||||
for(int i=0; i<count;i++)
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
glVertex2f(x+size*COSF((int)angle), SCREEN_HEIGHT_F-(y+size*SINF((int)angle)));
|
||||
|
||||
@@ -2877,9 +3243,9 @@ void JRenderer::FillPolygon(float x, float y, float size, int count, float start
|
||||
float firstAngle = angle;
|
||||
float steps = 360.0f/count;
|
||||
size /= 2;
|
||||
int i;
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
int i;
|
||||
GLfloat* vVertices = new GLfloat[3*(count+2)];
|
||||
GLubyte* colors = new GLubyte[4*(count+2)];
|
||||
|
||||
@@ -2929,6 +3295,51 @@ void JRenderer::FillPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
GLfloat* vVertices = new GLfloat[3*(count+2)];
|
||||
GLubyte* colors = new GLubyte[4*(count+2)];
|
||||
|
||||
for(i = 0; i < count+2; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
vVertices[0] = x;
|
||||
vVertices[1] = SCREEN_HEIGHT_F-y;
|
||||
vVertices[2] = 0.0f;
|
||||
|
||||
for(i=1; i<count+1;i++)
|
||||
{
|
||||
vVertices[3*i+0] = x+size*COSF((int)angle);
|
||||
vVertices[3*i+1] = SCREEN_HEIGHT_F-y+size*SINF((int)angle);
|
||||
vVertices[3*i+2] = 0.0f;
|
||||
angle += steps;
|
||||
if (angle >= 360.0f)
|
||||
angle -= 360.0f;
|
||||
}
|
||||
|
||||
vVertices[3*(1+count)+0] = x+size*COSF((int)firstAngle);
|
||||
vVertices[3*(1+count)+1] = SCREEN_HEIGHT_F-y+size*SINF((int)firstAngle);
|
||||
vVertices[3*(1+count)+2] = 0.0f;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,count+2);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -2936,7 +3347,7 @@ void JRenderer::FillPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
glVertex2f(x, SCREEN_HEIGHT_F-y);
|
||||
|
||||
for(int i=0; i<count;i++)
|
||||
for(i=0; i<count;i++)
|
||||
{
|
||||
glVertex2f(x+size*COSF((int)angle), SCREEN_HEIGHT_F-y+size*SINF((int)angle));
|
||||
angle += steps;
|
||||
@@ -2971,9 +3382,9 @@ void JRenderer::DrawRoundRect(float x, float y, float w, float h, float radius,
|
||||
y+=h+radius;
|
||||
JColor col;
|
||||
col.color = color;
|
||||
int i;
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
int i;
|
||||
int number = 360;
|
||||
GLfloat* vVertices = new GLfloat[3*number];
|
||||
GLubyte* colors = new GLubyte[4*number];
|
||||
@@ -3036,11 +3447,69 @@ void JRenderer::DrawRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
int number = 360;
|
||||
GLfloat* vVertices = new GLfloat[3*number];
|
||||
GLubyte* colors = new GLubyte[4*number];
|
||||
|
||||
for(i = 0; i < number; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
|
||||
for(i=0; i<90;i++) {
|
||||
vVertices[3 * i + 0] = x+radius*COSF(i);
|
||||
vVertices[3 * i + 1] = SCREEN_HEIGHT_F-(y+radius*SINF(i));
|
||||
vVertices[3 * i + 2] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
for(i=90; i<180;i++)
|
||||
{
|
||||
vVertices[3 * i + 0] = x+radius*COSF(i)-w;
|
||||
vVertices[3 * i + 1] = SCREEN_HEIGHT_F-(y+radius*SINF(i));
|
||||
vVertices[3 * i + 2] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
for(i=180; i<270;i++)
|
||||
{
|
||||
vVertices[3 * i + 0] = x+radius*COSF(i)-w;
|
||||
vVertices[3 * i + 1] = SCREEN_HEIGHT_F-(y+radius*SINF(i)-h);
|
||||
vVertices[3 * i + 2] = 0.0f;
|
||||
}
|
||||
|
||||
for(i=270; i<360;i++)
|
||||
{
|
||||
vVertices[3 * i + 0] = x+radius*COSF(i);
|
||||
vVertices[3 * i + 1] = SCREEN_HEIGHT_F-(y+radius*SINF(i)-h);
|
||||
vVertices[3 * i + 2] = 0.0f;
|
||||
}
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_LINE_LOOP,0,number);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
int i;
|
||||
|
||||
for(i=0; i<90;i++)
|
||||
{
|
||||
glVertex2f(x+radius*COSF(i), SCREEN_HEIGHT_F-(y+radius*SINF(i)));
|
||||
@@ -3165,6 +3634,70 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
int i, offset;
|
||||
int number = 2+360;
|
||||
GLfloat* vVertices = new GLfloat[3*number];
|
||||
GLubyte* colors = new GLubyte[4*number];
|
||||
|
||||
for(i = 0; i < number; i++)
|
||||
{
|
||||
colors[4*i+0]= col.r;
|
||||
colors[4*i+1]= col.g;
|
||||
colors[4*i+2]= col.b;
|
||||
colors[4*i+3]= col.a;
|
||||
}
|
||||
|
||||
vVertices[0] = x-5; vVertices[1] = SCREEN_HEIGHT_F-y; vVertices[2] = 0.0f;
|
||||
offset = 1;
|
||||
for(i=0; i<90;i++) {
|
||||
vVertices[3*(offset+i)+0] = x+radius*COSF(i);
|
||||
vVertices[3*(offset+i)+1] = SCREEN_HEIGHT_F-y+radius*SINF(i);
|
||||
vVertices[3*(offset+i)+2] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
for(i=90; i<180;i++)
|
||||
{
|
||||
vVertices[3*(offset+i)+0] = x+radius*COSF(i)-w;
|
||||
vVertices[3*(offset+i)+1] = SCREEN_HEIGHT_F-y+radius*SINF(i);
|
||||
vVertices[3*(offset+i)+2] = 0.0f;
|
||||
}
|
||||
|
||||
for(i=180; i<270;i++)
|
||||
{
|
||||
vVertices[3*(offset+i)+0] = x+radius*COSF(i)-w;
|
||||
vVertices[3*(offset+i)+1] = SCREEN_HEIGHT_F-y+radius*SINF(i)-h;
|
||||
vVertices[3*(offset+i)+2] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
for(i=270; i<360;i++)
|
||||
{
|
||||
vVertices[3*(offset+i)+0] = x+radius*COSF(i);
|
||||
vVertices[3*(offset+i)+1] = SCREEN_HEIGHT_F-y+radius*SINF(i)-h;
|
||||
vVertices[3*(offset+i)+2] = 0.0f;
|
||||
}
|
||||
|
||||
vVertices[3*(361)+0] = x+radius*COSF(0);
|
||||
vVertices[3*(361)+1] = SCREEN_HEIGHT_F-y+radius*SINF(0);
|
||||
vVertices[3*(361)+2] = 0.0f;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, vVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors );
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,number);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
@@ -166,7 +166,9 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
|
||||
$(JGE_PATH)/src/pc/JSfx.cpp \
|
||||
$(JGE_PATH)/src/pc/JGfx.cpp \
|
||||
$(JGE_PATH)/src/JNetwork.cpp \
|
||||
$(JGE_PATH)/src/pc/JSocket.cpp
|
||||
$(JGE_PATH)/src/pc/JSocket.cpp \
|
||||
$(BOOST_PATH)/lib/pthread/thread.cpp \
|
||||
$(BOOST_PATH)/lib/pthread/once.cpp
|
||||
|
||||
LOCAL_LDLIBS := -lGLESv1_CM -llog -lz
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include "Translate.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "TranslateKeys.h"
|
||||
|
||||
#ifdef SDL_CONFIG
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
@@ -20,9 +22,12 @@ const KeyRep& translateKey(LocalKeySym key)
|
||||
}
|
||||
|
||||
char* str = NULL;
|
||||
#if !defined(QT_CONFIG) && !defined(IOS) && !defined(ANDROID)
|
||||
|
||||
#if !defined(QT_CONFIG) && !defined(IOS) && !defined (SDL_CONFIG)
|
||||
str = XKeysymToString(key);
|
||||
#endif // QT_CONFIG
|
||||
#elif defined (SDL_CONFIG)
|
||||
str = (char*)SDL_GetKeyName(key);
|
||||
#endif
|
||||
if (!str)
|
||||
{
|
||||
str = NEW char[11];
|
||||
|
||||
389
projects/mtg/wagic-SDL.pro
Normal file
389
projects/mtg/wagic-SDL.pro
Normal file
@@ -0,0 +1,389 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2010-06-30T19:48:30
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
#QT += core gui opengl network
|
||||
macx:QT += phonon
|
||||
#CONFIG += warn_off precompile_header // causes some massives errors on mac.
|
||||
VERSION = 0.14.1
|
||||
TARGET = wagic
|
||||
TEMPLATE = app
|
||||
unix|macx:QMAKE_CXXFLAGS += -Wno-unused-parameter
|
||||
windows:DEFINES += WIN32
|
||||
windows:DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||
unix|macx:DEFINES += LINUX
|
||||
CONFIG(debug, debug|release):DEFINES += _DEBUG
|
||||
#DEFINES += QT_CONFIG
|
||||
#DEFINES += NETWORK_SUPPORT
|
||||
DEFINES += SDL_CONFIG
|
||||
macx:DEFINES += USE_PHONON
|
||||
maemo5: {
|
||||
DEFINES += USE_PHONON
|
||||
QT += phonon dbus
|
||||
}
|
||||
windows:INCLUDEPATH += ../../JGE/Dependencies/include
|
||||
windows:INCLUDEPATH += extra
|
||||
unix:INCLUDEPATH += /usr/include/GL
|
||||
unix:INCLUDEPATH += /usr/local/include/SDL
|
||||
macx:INCLUDEPATH += /opt/include
|
||||
INCLUDEPATH += ../../JGE/include
|
||||
INCLUDEPATH += ../../JGE/include/unzip
|
||||
INCLUDEPATH += ../../Boost
|
||||
INCLUDEPATH += include
|
||||
OBJECTS_DIR = objs
|
||||
MOC_DIR = objs
|
||||
DESTDIR = bin
|
||||
|
||||
macx|unix:LIBS += -lz -lboost_thread-mt
|
||||
unix:LIBS += -ljpeg -lgif -lpng12 -L/usr/local/lib -lGL -lGLU -lSDL
|
||||
windows:LIBS += -L../../JGE/Dependencies/lib -L../../Boost/lib -llibjpeg-static-mt-debug -lgiflib -llibpng -lfmodvc
|
||||
|
||||
PRECOMPILED_HEADER = include/PrecompiledHeader.h
|
||||
|
||||
# MGT
|
||||
SOURCES += \
|
||||
src/ActionElement.cpp\
|
||||
src/ActionLayer.cpp\
|
||||
src/ActionStack.cpp\
|
||||
src/AIMomirPlayer.cpp\
|
||||
src/AIPlayer.cpp\
|
||||
src/AIStats.cpp\
|
||||
src/AllAbilities.cpp\
|
||||
src/CardDescriptor.cpp\
|
||||
src/CardDisplay.cpp\
|
||||
src/CardEffect.cpp\
|
||||
src/CardGui.cpp\
|
||||
src/CardPrimitive.cpp\
|
||||
src/CardSelector.cpp\
|
||||
src/CardSelectorSingleton.cpp\
|
||||
src/Closest.cpp\
|
||||
src/Counters.cpp\
|
||||
src/Credits.cpp\
|
||||
src/Damage.cpp\
|
||||
src/DamagerDamaged.cpp\
|
||||
src/DeckDataWrapper.cpp\
|
||||
src/DeckEditorMenu.cpp\
|
||||
src/DeckManager.cpp\
|
||||
src/DeckMenu.cpp\
|
||||
src/DeckMenuItem.cpp\
|
||||
src/DeckMetaData.cpp\
|
||||
src/DeckStats.cpp\
|
||||
src/DuelLayers.cpp\
|
||||
src/Effects.cpp\
|
||||
src/ExtraCost.cpp\
|
||||
src/GameApp.cpp\
|
||||
src/GameLauncher.cpp\
|
||||
src/GameObserver.cpp\
|
||||
src/GameOptions.cpp\
|
||||
src/GameStateAwards.cpp\
|
||||
src/GameState.cpp\
|
||||
src/GameStateDeckViewer.cpp\
|
||||
src/GameStateDuel.cpp\
|
||||
src/GameStateMenu.cpp\
|
||||
src/GameStateOptions.cpp\
|
||||
src/GameStateShop.cpp\
|
||||
src/GameStateStory.cpp\
|
||||
src/GameStateTransitions.cpp\
|
||||
src/GuiAvatars.cpp\
|
||||
src/GuiBackground.cpp\
|
||||
src/GuiCardsController.cpp\
|
||||
src/GuiCombat.cpp\
|
||||
src/GuiFrame.cpp\
|
||||
src/GuiHand.cpp\
|
||||
src/GuiLayers.cpp\
|
||||
src/GuiMana.cpp\
|
||||
src/GuiPhaseBar.cpp\
|
||||
src/GuiPlay.cpp\
|
||||
src/GuiStatic.cpp\
|
||||
src/ManaCost.cpp\
|
||||
src/ManaCostHybrid.cpp\
|
||||
src/MenuItem.cpp\
|
||||
src/MTGAbility.cpp\
|
||||
src/MTGCard.cpp\
|
||||
src/MTGCardInstance.cpp\
|
||||
src/MTGDeck.cpp\
|
||||
src/MTGDefinitions.cpp\
|
||||
src/MTGGamePhase.cpp\
|
||||
src/MTGGameZones.cpp\
|
||||
src/MTGPack.cpp\
|
||||
src/MTGRules.cpp\
|
||||
src/ObjectAnalytics.cpp\
|
||||
src/OptionItem.cpp\
|
||||
src/PhaseRing.cpp\
|
||||
src/Player.cpp\
|
||||
src/PlayerData.cpp\
|
||||
src/PlayGuiObject.cpp\
|
||||
src/PlayGuiObjectController.cpp\
|
||||
src/PlayRestrictions.cpp\
|
||||
src/Pos.cpp\
|
||||
src/PriceList.cpp\
|
||||
src/ReplacementEffects.cpp\
|
||||
src/Rules.cpp\
|
||||
src/SimpleMenu.cpp\
|
||||
src/SimpleMenuItem.cpp\
|
||||
src/SimplePad.cpp\
|
||||
src/SimplePopup.cpp\
|
||||
src/StoryFlow.cpp\
|
||||
src/Subtypes.cpp\
|
||||
src/StyleManager.cpp\
|
||||
src/TargetChooser.cpp\
|
||||
src/TargetsList.cpp\
|
||||
src/Tasks.cpp\
|
||||
src/TextScroller.cpp\
|
||||
src/ThisDescriptor.cpp\
|
||||
src/Token.cpp\
|
||||
src/Translate.cpp\
|
||||
src/TranslateKeys.cpp\
|
||||
src/Trash.cpp\
|
||||
src/utils.cpp\
|
||||
src/WCachedResource.cpp\
|
||||
src/WDataSrc.cpp\
|
||||
src/WEvent.cpp\
|
||||
src/WFilter.cpp\
|
||||
src/WFont.cpp\
|
||||
src/WGui.cpp\
|
||||
src/WResourceManager.cpp\
|
||||
src/NetworkPlayer.cpp
|
||||
|
||||
CONFIG(debug, debug|release):SOURCES += src/TestSuiteAI.cpp
|
||||
|
||||
HEADERS += \
|
||||
include/AllAbilities.h\
|
||||
include/DeckMenu.h\
|
||||
include/DeckMenuItem.h\
|
||||
include/ExtraCost.h\
|
||||
include/ManaCost.h\
|
||||
include/SimpleMenuItem.h\
|
||||
include/GameApp.h\
|
||||
include/ManaCostHybrid.h\
|
||||
include/SimplePad.h\
|
||||
include/ActionElement.h\
|
||||
include/GameObserver.h\
|
||||
include/MenuItem.h\
|
||||
include/StoryFlow.h\
|
||||
include/ActionLayer.h\
|
||||
include/GameOptions.h\
|
||||
include/MTGAbility.h\
|
||||
include/Subtypes.h\
|
||||
include/ActionStack.h\
|
||||
include/GameStateAwards.h\
|
||||
include/MTGCard.h\
|
||||
include/AIMomirPlayer.h\
|
||||
include/GameStateDeckViewer.h\
|
||||
include/MTGCardInstance.h\
|
||||
include/Targetable.h\
|
||||
include/AIPlayer.h\
|
||||
include/GameStateDuel.h\
|
||||
include/MTGDeck.h\
|
||||
include/TargetChooser.h\
|
||||
include/AIStats.h\
|
||||
include/GameState.h\
|
||||
include/MTGDefinitions.h\
|
||||
include/TargetsList.h\
|
||||
include/AllAbilities.h\
|
||||
include/GameStateMenu.h\
|
||||
include/MTGGamePhase.h\
|
||||
include/Tasks.h\
|
||||
include/CardDescriptor.h\
|
||||
include/GameStateOptions.h\
|
||||
include/MTGGameZones.h\
|
||||
include/TestSuiteAI.h\
|
||||
include/CardDisplay.h\
|
||||
include/GameStateShop.h\
|
||||
include/MTGPack.h\
|
||||
include/TextScroller.h\
|
||||
include/CardEffect.h\
|
||||
include/GameStateStory.h\
|
||||
include/MTGRules.h\
|
||||
include/ThisDescriptor.h\
|
||||
include/CardGui.h\
|
||||
include/GameStateTransitions.h\
|
||||
include/OptionItem.h\
|
||||
include/Token.h\
|
||||
include/CardPrimitive.h\
|
||||
include/GuiAvatars.h\
|
||||
include/OSD.h\
|
||||
include/Translate.h\
|
||||
include/CardSelector.h\
|
||||
include/CardSelectorSingleton.h\
|
||||
include/GuiBackground.h\
|
||||
include/PhaseRing.h\
|
||||
include/TranslateKeys.h\
|
||||
include/config.h\
|
||||
include/GuiCardsController.h\
|
||||
include/PlayerData.h\
|
||||
include/Trash.h\
|
||||
include/Counters.h\
|
||||
include/GuiCombat.h\
|
||||
include/Player.h\
|
||||
include/utils.h\
|
||||
include/Credits.h\
|
||||
include/GuiFrame.h\
|
||||
include/PlayGuiObjectController.h\
|
||||
include/WCachedResource.h\
|
||||
include/Damage.h\
|
||||
include/GuiHand.h\
|
||||
include/PlayGuiObject.h\
|
||||
include/WDataSrc.h\
|
||||
include/DamagerDamaged.h\
|
||||
include/GuiLayers.h\
|
||||
include/Pos.h\
|
||||
include/WEvent.h\
|
||||
include/DeckDataWrapper.h\
|
||||
include/GuiMana.h\
|
||||
include/PriceList.h\
|
||||
include/WFilter.h\
|
||||
include/DeckMetaData.h\
|
||||
include/GuiPhaseBar.h\
|
||||
include/ReplacementEffects.h\
|
||||
include/WGui.h\
|
||||
include/DeckStats.h\
|
||||
include/GuiPlay.h\
|
||||
include/Rules.h\
|
||||
include/WResourceManager.h\
|
||||
include/DuelLayers.h\
|
||||
include/GuiStatic.h\
|
||||
include/Effects.h\
|
||||
include/StyleManager.h\
|
||||
include/WFont.h\
|
||||
include/DeckManager.h\
|
||||
include/SimplePopup.h\
|
||||
include/SimpleMenu.h\
|
||||
include/PrecompiledHeader.h\
|
||||
include/Navigator.h\
|
||||
include/DeckEditorMenu.h\
|
||||
include/PlayRestrictions.h\
|
||||
include/NetworkPlayer.h
|
||||
|
||||
# JGE, could probably be moved outside
|
||||
SOURCES += \
|
||||
../../JGE/src/SDLmain.cpp\
|
||||
../../JGE/src/Encoding.cpp\
|
||||
../../JGE/src/JAnimator.cpp\
|
||||
../../JGE/src/JApp.cpp\
|
||||
../../JGE/src/JDistortionMesh.cpp\
|
||||
../../JGE/src/JFileSystem.cpp\
|
||||
../../JGE/src/JGameObject.cpp\
|
||||
../../JGE/src/JGE.cpp\
|
||||
../../JGE/src/JGui.cpp\
|
||||
../../JGE/src/JLogger.cpp\
|
||||
../../JGE/src/JLBFont.cpp\
|
||||
../../JGE/src/JMD2Model.cpp\
|
||||
../../JGE/src/JOBJModel.cpp\
|
||||
../../JGE/src/JParticle.cpp\
|
||||
../../JGE/src/JParticleEffect.cpp\
|
||||
../../JGE/src/JParticleEmitter.cpp\
|
||||
../../JGE/src/JParticleSystem.cpp\
|
||||
../../JGE/src/JResourceManager.cpp\
|
||||
../../JGE/src/JSpline.cpp\
|
||||
../../JGE/src/JSprite.cpp\
|
||||
../../JGE/src/Vector2D.cpp\
|
||||
../../JGE/src/tinyxml/tinystr.cpp\
|
||||
../../JGE/src/tinyxml/tinyxml.cpp\
|
||||
../../JGE/src/tinyxml/tinyxmlerror.cpp\
|
||||
../../JGE/src/tinyxml/tinyxmlparser.cpp\
|
||||
../../JGE/src/hge/hgecolor.cpp\
|
||||
../../JGE/src/hge/hgedistort.cpp\
|
||||
../../JGE/src/hge/hgefont.cpp\
|
||||
../../JGE/src/hge/hgeparticle.cpp\
|
||||
../../JGE/src/hge/hgerect.cpp\
|
||||
../../JGE/src/hge/hgevector.cpp\
|
||||
../../JGE/src/unzip/ioapi.c\
|
||||
../../JGE/src/unzip/mztools.c\
|
||||
../../JGE/src/unzip/unzip.c\
|
||||
../../JGE/src/pc/JSfx.cpp\
|
||||
../../JGE/src/pc/JGfx.cpp\
|
||||
../../JGE/src/JNetwork.cpp\
|
||||
../../JGE/src/pc/JSocket.cpp
|
||||
|
||||
HEADERS += \
|
||||
../../JGE/include/decoder_prx.h\
|
||||
../../JGE/include/DebugRoutines.h\
|
||||
../../JGE/include/Encoding.h\
|
||||
../../JGE/include/JAnimator.h\
|
||||
../../JGE/include/JApp.h\
|
||||
../../JGE/include/JAssert.h\
|
||||
../../JGE/include/JCooleyesMP3.h\
|
||||
../../JGE/include/JDistortionMesh.h\
|
||||
../../JGE/include/JFileSystem.h\
|
||||
../../JGE/include/JGameLauncher.h\
|
||||
../../JGE/include/JGameObject.h\
|
||||
../../JGE/include/JGE.h\
|
||||
../../JGE/include/JGui.h\
|
||||
../../JGE/include/JLBFont.h\
|
||||
../../JGE/include/JLogger.h\
|
||||
../../JGE/include/JMD2Model.h\
|
||||
../../JGE/include/JMP3.h\
|
||||
../../JGE/include/JNetwork.h\
|
||||
../../JGE/include/JOBJModel.h\
|
||||
../../JGE/include/JParticleEffect.h\
|
||||
../../JGE/include/JParticleEmitter.h\
|
||||
../../JGE/include/JParticle.h\
|
||||
../../JGE/include/JParticleSystem.h\
|
||||
../../JGE/include/JRenderer.h\
|
||||
../../JGE/include/JResourceManager.h\
|
||||
../../JGE/include/JSocket.h\
|
||||
../../JGE/include/JSoundSystem.h\
|
||||
../../JGE/include/JSpline.h\
|
||||
../../JGE/include/JSprite.h\
|
||||
../../JGE/include/JTypes.h\
|
||||
../../JGE/include/Vector2D.h\
|
||||
../../JGE/include/Vector3D.h\
|
||||
../../JGE/include/vram.h\
|
||||
../../JGE/include/Threading.h\
|
||||
../../JGE/src/tinyxml/tinystr.h\
|
||||
../../JGE/src/tinyxml/tinyxml.h\
|
||||
../../JGE/include/vram.h\
|
||||
../../JGE/include/hge/hgecolor.h\
|
||||
../../JGE/include/hge/hgedistort.h\
|
||||
../../JGE/include/hge/hgefont.h\
|
||||
../../JGE/include/hge/hgerect.h\
|
||||
../../JGE/include/hge/hgevector.h\
|
||||
../../JGE/include/hge/hgeparticle.h\
|
||||
../../JGE/include/unzip/ioapi.h\
|
||||
../../JGE/include/unzip/mztools.h\
|
||||
../../JGE/include/unzip/unzip.h\
|
||||
../../JGE/include/JNetwork.h\
|
||||
../../JGE/include/JSocket.h
|
||||
|
||||
INSTALLS += target \
|
||||
res \
|
||||
|
||||
res.path = /usr/local/bin/Res
|
||||
res.files += bin/Res/*
|
||||
target.path = /usr/local/bin
|
||||
|
||||
maemo5: {
|
||||
# Variables
|
||||
BINDIR = /opt/wagic
|
||||
RESDIR = /home/user/wagic/Res
|
||||
ICONDIR = /usr/share
|
||||
DEFINES += RESDIR=\\\"$$RESDIR\\\"
|
||||
|
||||
INSTALLS += target \
|
||||
desktop \
|
||||
icon \
|
||||
res \
|
||||
restxt \
|
||||
launcher \
|
||||
|
||||
target.path = $$BINDIR
|
||||
|
||||
desktop.path = $$ICONDIR/applications/hildon
|
||||
desktop.files += wagic.desktop
|
||||
|
||||
icon.path = $$ICONDIR/icons/hicolor/64x64/apps
|
||||
icon.files += wagic-64x64.png
|
||||
|
||||
res.path = $$RESDIR
|
||||
res.files += bin/Res/*
|
||||
# res.extra = tar -C ../../../../src/projects/mtg/bin -czf Res.tgz Res
|
||||
|
||||
restxt.path = $$BINDIR
|
||||
restxt.files += debian/Res.txt
|
||||
|
||||
launcher.path = $$BINDIR
|
||||
launcher.files += debian/launcher
|
||||
}
|
||||
Reference in New Issue
Block a user