My little test program built on Ubuntu 16.04


#1

I am happy the API actually works on Linux platform. Bult a little test program to showcase the uses of simple bsf framework API to display a fbx 3d model.

Source code:

void notifyResized()
{
bs::gDebug().logDebug(“Window resized!”);
}

static void setupInputConfig() {
using namespace bs;

auto inputConfig = gVirtualInput().getConfiguration();
inputConfig->registerButton(“Forward”, BC_W);
inputConfig->registerButton(“Back”, BC_S);
inputConfig->registerButton(“Left”, BC_A);
inputConfig->registerButton(“Right”, BC_D);
inputConfig->registerButton(“Forward”, BC_UP);
inputConfig->registerButton(“Back”, BC_DOWN);
inputConfig->registerButton(“Left”, BC_LEFT);
inputConfig->registerButton(“Right”, BC_RIGHT);
inputConfig->registerButton(“FastMove”, BC_LSHIFT);
inputConfig->registerButton(“RotateObj”, BC_MOUSE_LEFT);
inputConfig->registerButton(“RotateCam”, BC_MOUSE_RIGHT);

// Camera controls for axes (analog input, e.g. mouse or gamepad thumbstick)
// These return values in [-1.0, 1.0] range.
inputConfig->registerAxis(“Horizontal”,
VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseX));

inputConfig->registerAxis(“Vertical”,
VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseY));
}

/** Main entry point into the application. */
#if BS_PLATFORM == BS_PLATFORM_WIN32
#include <windows.h>

int CALLBACK WinMain(In HINSTANCE hInstance, In HINSTANCE hPrevInstance,
In LPSTR lpCmdLine, In int nCmdShow
: w)
#else
int main()
#endif
{
using namespace bs;

// Initializes the application and creates a window with the specified
// properties
VideoMode videoMode(1928, 1080);
Application::startUp(videoMode, “Table Tennis Table”, false);

SPtr primaryWindow = gApplication().getPrimaryWindow();
primaryWindow->onResized.connect(&notifyResized);
setupInputConfig();

HSceneObject so = SceneObject::create(“Table”);
so->addComponent();
so->setPosition(Vector3(0, 0, 0));
HRenderable renderable = so->addComponent();

HTexture texture = gImporter().import("/home/tangth/bsfdev/bsfExamples/Data/wood.png");
gResources().save(texture, “/home/tangth/bsfdev/bsfExamples/Data/wood.asset”, true);

HShader shader = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
HMaterial material = Material::create(shader);
material->setTexture(“gAlbedoTex”, texture);

HMesh mesh = gImporter().import("/home/tangth/bsfdev/bsfExamples/Data/PingPongTable.obj");
renderable->setMesh(mesh);
renderable->setMaterial(material);

HSceneObject cameraSO = SceneObject::create(“Camera”);
cameraSO->setPosition(Vector3(2.0f, 1.0f, 5.0f));
cameraSO->lookAt(Vector3(-0.4f, 0.0f, 0.0f));
cameraSO->addComponent();

HCamera camera = cameraSO->addComponent();
// camera->setMain(true);
camera->getViewport()->setTarget(primaryWindow);
camera->setNearClipDistance(0.00f);
camera->setFarClipDistance(1000);
camera->setMSAACount(4);
camera->setProjectionType(PT_PERSPECTIVE);
camera->setAspectRatio(1928/1080.00);

HSceneObject lightSO = SceneObject::create(“Light”);
lightSO->setPosition(Vector3(1.0f, 0.5f, 0.0f));

HLight light = lightSO->addComponent();
light->setIntensity(50.0f);

Application::instance().runMainLoop();
Application::shutDown();

return 0;

Screen shots