ソースを参照

core: port all code to NativeClient. Nothing runs for now, but it builds.

legacy
Sam Hocevar sam 13年前
コミット
2edb8115e6
13個のファイルの変更189行の追加28行の削除
  1. +1
    -0
      .gitignore
  2. +10
    -0
      build-nacl
  3. +7
    -0
      build/lol-build
  4. +4
    -0
      configure.ac
  5. +5
    -1
      src/Makefile.am
  6. +4
    -0
      src/application/application.cpp
  7. +18
    -18
      src/debug/quad.cpp
  8. +82
    -0
      src/platform/nacl/naclapp.cpp
  9. +42
    -0
      src/platform/nacl/naclapp.h
  10. +3
    -0
      src/real.h
  11. +5
    -5
      src/timer.cpp
  12. +4
    -4
      test/benchmark/trig.cpp
  13. +4
    -0
      test/tutorial/tut03.cpp

+ 1
- 0
.gitignore ファイルの表示

@@ -6,6 +6,7 @@
*.exe
*.elf
*.self
*.nexe
*.userprefs
*.usertasks
*.pidb


+ 10
- 0
build-nacl ファイルの表示

@@ -0,0 +1,10 @@
#!/bin/sh

# This can't hurt
make distclean

set -e
./build/lol-build bootstrap nacl-amd64
./build/lol-build configure nacl-amd64
./build/lol-build build nacl-amd64


+ 7
- 0
build/lol-build ファイルの表示

@@ -15,6 +15,7 @@
# And <platform> is one of:
# - linux-i386
# - linux-amd64
# - nacl-amd64
# - ios-arm
# - osx-amd64
# - android-arm
@@ -118,6 +119,10 @@ configure()
cd monsterz/android
android update project --path .
;;
nacl-amd64)
# no need for "-u _ZN2pp12CreateModuleEv" but it could be helpful
./configure CXX=x86_64-nacl-g++ CC=x86_64-nacl-gcc ac_cv_exeext=.nexe --host=none LOL_LIBS="-lppapi -lppapi_gles2 -lppapi_cpp"
;;
ps3-ppu)
PATH="$PATH" ./configure CXX=ppu-lv2-g++ CC=ppu-lv2-gcc ac_cv_exeext=.elf --host=none
;;
@@ -178,6 +183,8 @@ check()
;;
ps3-ppu)
;;
nacl-*)
;;
windows-i386)
# If neither $MSYSTEM or $DISPLAY are set, and xvfb-run
# exists, use it to run the test suite.


+ 4
- 0
configure.ac ファイルの表示

@@ -128,6 +128,9 @@ PKG_CHECK_MODULES(GLES2, glesv2,
GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
[:])
AC_CHECK_HEADER(GLES2/gl2.h,
[AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
ac_cv_my_have_gl="yes"])

PKG_CHECK_MODULES(GL, gl,
[ac_cv_my_have_gl="yes"
@@ -152,6 +155,7 @@ AC_CHECK_HEADER(GL/gl.h,
LIBS="$LIBS_save"])
AC_CHECK_HEADER(PSGL/psgl.h,
[ac_cv_my_have_gl="yes"])

if test "${ac_cv_my_have_gl}" = "no"; then
AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
fi


+ 5
- 1
src/Makefile.am ファイルの表示

@@ -19,6 +19,7 @@ liblol_a_SOURCES = \
eglapp.cpp eglapp.h \
\
$(ps3_sources) \
$(nacl_sources) \
$(sdl_sources) \
\
shader/shader.cpp shader/shader.h \
@@ -38,10 +39,13 @@ liblol_a_SOURCES = \
debug/quad.cpp debug/quad.h
liblol_a_CPPFLAGS = @LOL_CFLAGS@

sdl_sources = \
sdl_sources = \
platform/sdl/sdlapp.cpp platform/sdl/sdlapp.h \
platform/sdl/sdlinput.cpp platform/sdl/sdlinput.h

nacl_sources = \
platform/nacl/naclapp.cpp platform/nacl/naclapp.h

if HAVE_PS3
ps3_sources = \
platform/ps3/ps3app.cpp platform/ps3/ps3app.h \


+ 4
- 0
src/application/application.cpp ファイルの表示

@@ -17,6 +17,8 @@

#if defined __CELLOS_LV2__
# include "platform/ps3/ps3app.h"
#elif defined __native_client__
# include "platform/nacl/naclapp.h"
#elif defined HAVE_GLES_2X
# include "eglapp.h"
#else
@@ -39,6 +41,8 @@ class ApplicationData

#if defined __CELLOS_LV2__
Ps3App app;
#elif defined __native_client__
NaClApp app;
#elif defined HAVE_GLES_2X
/* FIXME: this macro is only deactivated if we include "lolgl.h" */
EglApp app;


+ 18
- 18
src/debug/quad.cpp ファイルの表示

@@ -153,7 +153,7 @@ void DebugQuad::TickDraw(float deltams)

if (!data->initialised && !IsDestroying())
{
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glGenVertexArrays(NUM_ARRAYS, data->array);
#endif
glGenBuffers(NUM_BUFFERS, data->buffer);
@@ -183,7 +183,7 @@ void DebugQuad::TickDraw(float deltams)
}
else if (data->initialised && IsDestroying())
{
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glDeleteVertexArrays(NUM_ARRAYS, data->array);
#endif
glDeleteBuffers(NUM_BUFFERS, data->buffer);
@@ -494,7 +494,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders an orange square.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glColor4f(orange.x, orange.y, orange.z, orange.w);
glEnableClientState(GL_VERTEX_ARRAY);

@@ -512,7 +512,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders a green sine wave made of 1-pixel points.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glPointSize(1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -531,7 +531,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders a multicoloured square with varying colors.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

@@ -552,7 +552,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors multiplied with an
* animated distorted checkerboard.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, data->texture[0]);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -580,7 +580,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders an orange square.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
#if !defined __CELLOS_LV2__
shader[0] = Shader::Create(
@@ -626,7 +626,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders an orange square.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
{
#if !defined __CELLOS_LV2__
@@ -679,7 +679,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders a static, coloured and tiled pattern.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
#if !defined __CELLOS_LV2__
shader[0] = Shader::Create(
@@ -732,7 +732,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders a multicoloured square with varying colors.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
{
#if !defined __CELLOS_LV2__
@@ -796,7 +796,7 @@ void DebugQuad::TickDraw(float deltams)
*
* Renders an antialiased green sine wave made of 1-pixel points.
*/
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __CELLOS_LV2__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __CELLOS_LV2__ && !defined __native_client__
if (!shader[0])
shader[0] = Shader::Create(
"#version 120\n"
@@ -842,7 +842,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors xored with an
* animated distorted checkerboard.
*/
#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
#if !defined __CELLOS_LV2__
shader[0] = Shader::Create(
@@ -915,7 +915,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors xored with an
* animated distorted checkerboard.
*/
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
{
shader[0] = Shader::Create(
@@ -985,7 +985,7 @@ void DebugQuad::TickDraw(float deltams)
* Renders a multicoloured square with varying colors xored with an
* animated distorted checkerboard.
*/
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
if (!shader[0])
{
shader[0] = Shader::Create(
@@ -1073,7 +1073,7 @@ void DebugQuad::ResetState()
glLoadIdentity();
#endif

#if !defined __ANDROID__ && !defined __APPLE__
#if !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
#endif

@@ -1082,13 +1082,13 @@ void DebugQuad::ResetState()
#if defined HAVE_GLBEGIN || defined USE_GLEW || defined __CELLOS_LV2__
glClientActiveTexture(GL_TEXTURE0);
#endif
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE);
#endif
glDisable(GL_TEXTURE_2D);

glDisable(GL_BLEND);
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glDisable(GL_POINT_SPRITE);
#endif

@@ -1100,7 +1100,7 @@ void DebugQuad::ResetState()
cgGLDisableProfile(cgGLGetLatestProfile(CG_GL_FRAGMENT));
#endif

#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__
#if !defined __CELLOS_LV2__ && !defined __ANDROID__ && !defined __APPLE__ && !defined __native_client__
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif
}


+ 82
- 0
src/platform/nacl/naclapp.cpp ファイルの表示

@@ -0,0 +1,82 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#if defined __native_client__
# include "ppapi/cpp/instance.h"
# include "ppapi/cpp/module.h"
# include "ppapi/cpp/var.h"
#endif

#include "core.h"
#include "lolgl.h"
#include "naclapp.h"

namespace lol
{

/*
* PS3 App implementation class
*/

class NaClAppData
{
friend class NaClApp;

private:
#if defined __native_client__
#endif
};

/*
* Public NaClApp class
*/

NaClApp::NaClApp(char const *title, ivec2 res, float fps) :
data(new NaClAppData())
{
#if defined __native_client__
#endif
}

void NaClApp::ShowPointer(bool show)
{
;
}

void NaClApp::Run()
{
while (!Ticker::Finished())
{
/* Tick the game */
Ticker::TickGame();

/* Tick the renderer, show the frame and clamp to desired framerate. */
Ticker::TickDraw();

#if defined __native_client__
#endif

Ticker::ClampFps();
}
}

NaClApp::~NaClApp()
{
#if defined __native_client__
#endif
delete data;
}

} /* namespace lol */


+ 42
- 0
src/platform/nacl/naclapp.h ファイルの表示

@@ -0,0 +1,42 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

//
// The NaClApp class
// -----------------
//

#if !defined __LOL_NACLAPP_H__
#define __LOL_NACLAPP_H__

#include "matrix.h"

namespace lol
{

class NaClAppData;

class NaClApp
{
public:
NaClApp(char const *title, ivec2 res, float fps);
virtual ~NaClApp();

void ShowPointer(bool show);
void Run();

private:
NaClAppData *data;
};

} /* namespace lol */

#endif // __LOL_NACLAPP_H__


+ 3
- 0
src/real.h ファイルの表示

@@ -18,6 +18,9 @@

#include <stdint.h>

/* Avoid issues with NaCl headers */
#undef log2

namespace lol
{



+ 5
- 5
src/timer.cpp ファイルの表示

@@ -15,7 +15,7 @@
#include <cstdlib>
#include <stdint.h>

#if defined __linux__ || defined __APPLE__
#if defined __linux__ || defined __native_client__ || defined __APPLE__
# include <sys/time.h>
# include <unistd.h>
#elif defined _XBOX
@@ -48,7 +48,7 @@ class TimerData
private:
TimerData()
{
#if defined __linux__ || defined __APPLE__
#if defined __linux__ || defined __native_client__ || defined __APPLE__
gettimeofday(&tv0, NULL);
#elif defined _WIN32
QueryPerformanceCounter(&cycles0);
@@ -63,7 +63,7 @@ private:
float GetOrWait(float deltams, bool update)
{
float ret, towait;
#if defined __linux__ || defined __APPLE__
#if defined __linux__ || defined __native_client__ || defined __APPLE__
struct timeval tv;
gettimeofday(&tv, NULL);
ret = 1e-3f * (tv.tv_usec - tv0.tv_usec)
@@ -108,7 +108,7 @@ private:

static float GetMsPerCycle()
{
#if defined __linux__ || defined __APPLE__
#if defined __linux__ || defined __native_client__ || defined __APPLE__
return 1.0f;
#elif defined _WIN32
LARGE_INTEGER tmp;
@@ -121,7 +121,7 @@ private:
#endif
}

#if defined __linux__ || defined __APPLE__
#if defined __linux__ || defined __native_client__ || defined __APPLE__
struct timeval tv0;
#elif defined _WIN32
LARGE_INTEGER cycles0;


+ 4
- 4
test/benchmark/trig.cpp ファイルの表示

@@ -73,7 +73,7 @@ void bench_trig(int mode)
/* Fast sin */
timer.GetMs();
for (size_t i = 0; i < TRIG_TABLE_SIZE; i++)
#if defined HAVE_FASTMATH_H
#if defined HAVE_FASTMATH_H && !defined __native_client__
pf2[i] = f_sinf(pf[i]);
#else
pf2[i] = sinf(pf[i]);
@@ -99,7 +99,7 @@ void bench_trig(int mode)
/* Fast cos */
timer.GetMs();
for (size_t i = 0; i < TRIG_TABLE_SIZE; i++)
#if defined HAVE_FASTMATH_H
#if defined HAVE_FASTMATH_H && !defined __native_client__
pf2[i] = f_cosf(pf[i]);
#else
pf2[i] = cosf(pf[i]);
@@ -130,7 +130,7 @@ void bench_trig(int mode)
timer.GetMs();
for (size_t i = 0; i < TRIG_TABLE_SIZE; i++)
{
#if defined HAVE_FASTMATH_H
#if defined HAVE_FASTMATH_H && !defined __native_client__
pf2[i] = f_sinf(pf[i]);
pf3[i] = f_cosf(pf[i]);
#else
@@ -159,7 +159,7 @@ void bench_trig(int mode)
/* Fast tan */
timer.GetMs();
for (size_t i = 0; i < TRIG_TABLE_SIZE; i++)
#if defined HAVE_FASTMATH_H
#if defined HAVE_FASTMATH_H && !defined __native_client__
pf2[i] = f_tanf(pf[i]);
#else
pf2[i] = tanf(pf[i]);


+ 4
- 0
test/tutorial/tut03.cpp ファイルの表示

@@ -34,6 +34,10 @@ using namespace lol;
static GLint const INTERNAL_FORMAT = GL_ARGB_SCE;
static GLenum const TEXTURE_FORMAT = GL_BGRA;
static GLenum const TEXTURE_TYPE = GL_UNSIGNED_INT_8_8_8_8_REV;
#elif defined __native_client__
static GLint const INTERNAL_FORMAT = GL_RGBA;
static GLenum const TEXTURE_FORMAT = GL_RGBA;
static GLenum const TEXTURE_TYPE = GL_UNSIGNED_BYTE;
#else
/* Seems efficient for little endian textures */
static GLint const INTERNAL_FORMAT = GL_RGBA;


読み込み中…
キャンセル
保存