Embed
Email

game

Document Sample
game
Description

You can learn games and 3D animation design and here also you can learn about the design and the anatomy of the game so that it could produce a working game

Shared by: Wahyu Nurcahyo
Categories
Tags
Stats
views:
18
posted:
10/26/2011
language:
English
pages:
45
Tips for game development:

Graphics, Audio, Sensor

bada Developer Day in Seoul

Dec 08, 2010









Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved

Contents



Games in bada

Audio tips

Sensor tips

3D rendering tips

Summary









*This material is based on bada SDK 1.2.0

2

Games in bada

Many games in

Appstore





Videos or live demos









3

bada features for games





Input Output







Sensors Graphics

Weather





Vibration

Face detection

Audio

Sound Service-centric





$2 $3

In-App Remote contents

purchasing SNS Gateway



4

1



Audio tips

Two ways to play sound

General-purpose audio/video playback

– Multiple audio playback (max.: 10)

Player







– Supports streaming*

– MP3, WMA, MIDI, ..



*Streaming protocol: RTSP (API 1.0), HTTP (API 1.1)







Plays only PCM data

AudioOut









– Multiple audio playback (max.: 64)

– Double buffering is possible







6

Player

Step 1: Create a Player instance

pPlayer = new Player;

pPlayer->Construct(*pListener);

// IPlayerEventListener



Step 2: Load a file and play it

result r = pPlayer->OpenFile(path);

pPlayer->Play();



Step 3: Stop playing and close it

pPlayer->Stop();

pPlayer->Close();









7

AudioOut

Step 1: Create an AudioOut instance

pAO = new AudioOut();

pAO->Construct(*pListener);// IAudioOutEventListener

//Prepares the audio output device

pAO->Prepare(AUDIO_TYPE_PCM_S16_LE,

AUDIO_CHANNEL_TYPE_MONO, SAMPLERATE);



Step 2: Write PCM data

// Fill buffer with PCM data

pAO->WriteBuffer(*pOutBuffer);



Step 3: Play the sound

pAO->Start();









8

AudioOut

Step 4: Process events

void EventListener::OnAudioOutBufferEndReached

(Osp::Media::AudioOut &src)

{ //Write Next PCM data

}



Step 5: Stop the sound

pAO->Stop(); //or Reset()









9

Audio tips

Preferred PCM format Use the preferred PCM format

Double buffering to reduce the internal

Sound mixing

operations

Handled by platform

Field Values

Handled by application

Channels Stereo

Sample rate 44.1Khz

Bit per sample 16-bit









10

Audio tips

Preferred PCM format Reduce latency

Double buffering AudioOut Device Application

Sound mixing

Handled by platform

Event:

Handled by application Buffer End Reached



Buffer1



Buffer2 Step 1. Initialize AudioOut

Step 2. Write a buffer two times

Buffer3

Step 3. Start playback

Step 4. Playback is ended

Step 5. Event is fired

Buffer2 is used by AudioOut

Step 6. Write a new buffer



11

Audio tips

Preferred PCM format Sound mixing

Double buffering

– Combine multiple sounds

Sound mixing

into one

Handled by platform

Handled by application

Sound mixing by application

reduces the internal resource

and event processing









12

Audio tips

Preferred PCM format Headset

Double buffering

– Platform will change the

Sound mixing

sound path automatically*

Handled by platform

Handled by application

Incoming call

– Player and AudioOut are

stopped by the platform**

– The application should

resume them***

* Osp::System::DeviceManager

** IAudioOutEventListener::OnAudioOutInterrupted

*** IAudioOutEventListener::OnAudioOutRelased 13

Audio tips

Preferred PCM format Silent mode

Double buffering – No event is fired

Sound mixing – Check the silent mode*

Handled by platform

Handled by application

Side volume key**





Foreground/Background

– Stop the audio on background



*Osp::System::SettingInfo

**Osp::Ui::IKeyEventListener

14

2



Sensor tips

Sensor

Sensors

Type Properties

Acceleration sensor x, y, z

Magnetic sensor (compass) x, y, z

Proximity sensor 1 (on) or 0 (off)

Tilt sensor Azimuth, Pitch, Roll



SensorManager

– Manages built-in sensors

– Polls sensors for data and delivers it to applications

at specified intervals.



16

Getting sensor data

Step 1: Create a SensorManager

Osp::Uix::SensorManager sensorMgr;

sensorMgr.Construct();



Step 2: Add a listener

sensorMgr.GetMaxInterval(

SENSOR_TYPE_MAGNETIC, interval);

sensorMgr.AddSensorListener(

*this, SENSOR_TYPE_MAGNETIC, interval, false);



Step 3: Get sensor data from event-listener*

Void OnDataReceived(SensorType sensorType,

SensorData& sensorData, result r)

{…

}



* Event hander should return immediately, else event delay or event handling

problem will occur

17

Multi-touch

The number of points depends on the

hardware









18

Multi-touch

Step 1: Enable multi-touch

Touch touch;

touch.SetMultipointEnabled(*this, true);



Step 2: Get multi-touch information

Touch touch;

IList* pList = null;

pList = touch.GetTouchInfoListN(source);

if (pList)

{

for(int i = 0; i GetCount(); i++ )

TouchInfo *pTouchInfo =

static_cast(pList->GetAt(i));

pList->RemoveAll(true);

delete pList;

}





19

3



3D rendering tips

3D rendering in bada

bada supports

– OpenGL® ES 1.1/2.0

• 1.1 – Fixed function hardware

• 2.0 – Fully programmable 3D graphics

– EGL

• Manages contexts and drawing surfaces

– Timer-based rendering loop

– Rendering on every kind of controls









21

3D rendering in bada

Timer-based rendering loop

– Step 1: Create a timer

pTimer= new Timer;

pTimer->Construct(*this);

pTimer->Start(TIME_OUT);



– Step 2: Implement event listener

class GlesCube11 :

public Osp::Base::Runtime::ITimerEventListener



void OnTimerExpired(Osp::Base::Runtime::Timer& timer);



– Step 3: Handle timer event

void GlesCube11::OnTimerExpired(Timer& timer){

pTimer->Start(TIME_OUT);

Draw(); // draw something..

}

22

3D rendering in bada

Initialize EGL

bool GlesCube11::InitEGL()

{

EGLint numConfigs = 1;

EGLint eglConfigList[] = {/*…*/};

EGLint eglContextList[] = {/*…*/};

eglBindAPI(EGL_OPENGL_ES_API);

eglDisplay = eglGetDisplay(

(EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);

eglInitialize(eglDisplay, null, null);

eglChooseConfig(eglDisplay, eglConfigList,

&eglConfig, 1, &numConfigs);

eglSurface = eglCreateWindowSurface(eglDisplay,

eglConfig, (EGLNativeWindowType)pForm, null);

...

}





23

3D rendering in bada

Checks OpenGLES version of device

void Test1::CheckGLES(void)

{

String key(L"OpenGLESVersion");

String GLESVersion;



SystemInfo::GetValue(key,GLESVersion);

AppLog("%ls", GLESVersion.GetPointer());

}



Result string

Device Result

Wave/Wave II 1.1/2.0

Wave525





24

3D accelerator of Wave/Wave II

POWERVR SGX

– Unified Shader Architecture

• Load balancing

• Mostly identical capabilities of shaders





– Tile-based Deferred Rendering (TBDR)









25

3D accelerator of Wave/Wave II

Related resources









Visit http://www.imgtec.com









26

Tips for 3D rendering

Texture Geometry Shader

Bitmaps are added Represents 3D Program to add

to the surface of object using special effects to 3D

geometry geometric entities rendering

such as triangles,

lines, and so on









27

Texture tips

Use texture atlas Texture atlas

Use mipmap

– Contains many sub images

Load all textures on

loading time

Use FBO instead of

pbuffer









Reduces the CPU overhead to

load texture





28

Texture tips

Use texture atlas Mipmap

Use mipmap

– Image set of different scales

Load all textures on

loading time

Use FBO instead of

pbuffer









Improves speed and quality

– Removes cache miss

– Removes aliasing

29

Texture tips

Use texture atlas

Reduces the frame-drops

Use mipmap

Load all textures on

during run-time

loading time – Loading texture has

Use FBO instead of overhead

pbuffer









30

Texture tips

Use texture atlas

Frame Buffer Object (FBO)

Use mipmap

Load all textures on – For off-screen rendering

loading time

Use FBO instead of

pbuffer









FBO is more efficient than

pbuffer

31

Geometry tips

Simplify geometry You do not need a very

Order 3D geometry complex model for mobile

optimally

Use VBO if possible

devices

Use object culling









4M triangles 500 triangles 500 triangles

+ normal map







32

Geometry tips

Simplify geometry Traversal order of vertex data

V1 V3

Order 3D geometry V5



optimally

Use VBO if possible V0

V6

Use object culling

V2 V4





Interleaved attributes are

better than separate arrays

Interleaved attr.:





Separate array:





Position Normal Color

33

Geometry tips

Simplify geometry Vertex Buffer Object (VBO)

Order 3D geometry

– Uploads data(vertex,

optimally

normal..) to video device

Use VBO if possible

Use object culling









Get more performance from

driver and hardware

optimization



34

Geometry tips

Simplify geometry Object culling

Order 3D geometry

– Do not render invisible object

optimally

Use VBO if possible

Use object culling



Viewpoint View

Frustum









Improve speed



35

Geometry tips

Simplify geometry Object culling

Order 3D geometry

– Do not render invisible object

optimally

Use VBO if possible

Use object culling



Viewpoint View

Frustum









Improve speed



36

Shader tips

Prefer vertex shader to Rendering pipeline

fragment shader

Choose the

Vertex Rasterizati Fragment Frame

appropriate precision Evaluator

shader on shader Buffer



Vector and scalar

operation Texture

Memory



Avoid discard Pixel

Operations

operation





The number of vertex is much

smaller than the number of

fragment

37

Shader tips

Prefer vertex shader to Consider the tradeoff between

fragment shader

speed and quality

Choose the

appropriate precision – highp: 32-bit

Vector and scalar – Midiump: 16-bit

operation • Reduce the storage space

Avoid discard • Texture coordinate

operation

– Lowp : 10-bit

• Color, normal..









38

Shader tips

Prefer vertex shader to Be careful with the order of

fragment shader

vector and scalar operations

Choose the

appropriate precision highp vec4 v1, v2;

highp float x, y;

Vector and scalar //Bad operation: 8

operation v2 = (v1 * x) * y;

//Good operation: 5

Avoid discard v2 = v1 * (x * y);

operation









39

Shader tips

Prefer vertex shader to discard operation is expensive

fragment shader

– Use alpha blend instead of

Choose the

appropriate precision

discard

Vector and scalar

operation

Avoid discard

operation









40

4



Summary

Games in bada









42

We’ve learned..

Audio tips

Sensor tips

3D rendering tips

– Texture

– Geometry

– Shader

bada games









43

Find out more..

Tutorial

– bada Tutorial.UI and Graphics.pdf

– bada Tutorial.UI Extension.pdf

– bada Tutorial.Media.pdf

POWERVR SDK

– SGX 3D Application Recommendations









44

Thank you.


Related docs
Other docs by Wahyu Nurcahyo
permrograman web
Views: 22  |  Downloads: 1
GT
Views: 7  |  Downloads: 0
speaking
Views: 32  |  Downloads: 13
pengenalan dan pemodelan 3d
Views: 36  |  Downloads: 3
geologi struktur
Views: 100  |  Downloads: 3
mod4
Views: 27  |  Downloads: 0
3d move
Views: 14  |  Downloads: 4
Teknik Karakter
Views: 28  |  Downloads: 0
game
Views: 18  |  Downloads: 5
mod3
Views: 11  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!