Add setUserIndex/getUserIndex (int index) to btCollisionShape
Share physics setup of BasicDemo between different graphics frameworks, see Demos\BasicDemo\BasicDemoPhysicsSetup.* Plan is to do this for all Bullet demos. Improve gwen performance and cursor navigation for tree control. tweak shadowmap size SimpleOpenGL3App::registerCubeShape accepts half extents
This commit is contained in:
@@ -105,6 +105,8 @@ void Base::Invalidate()
|
||||
{
|
||||
m_bNeedsLayout = true;
|
||||
m_bCacheTextureDirty = true;
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
}
|
||||
|
||||
void Base::DelayedDelete()
|
||||
@@ -403,12 +405,13 @@ void Base::OnBoundsChanged(Gwen::Rect oldBounds)
|
||||
//Anything that needs to update on size changes
|
||||
//Iterate my children and tell them I've changed
|
||||
//
|
||||
if ( GetParent() )
|
||||
GetParent()->OnChildBoundsChanged( oldBounds, this );
|
||||
|
||||
|
||||
|
||||
if ( m_Bounds.w != oldBounds.w || m_Bounds.h != oldBounds.h )
|
||||
{
|
||||
if ( GetParent() )
|
||||
GetParent()->OnChildBoundsChanged( oldBounds, this );
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@@ -694,6 +697,8 @@ void Base::Layout( Skin::Base* skin )
|
||||
skin->GetRender()->GetCTT()->CreateControlCacheTexture( this );
|
||||
}
|
||||
|
||||
int avoidUpdate = -15;
|
||||
|
||||
void Base::RecurseLayout( Skin::Base* skin )
|
||||
{
|
||||
if ( m_Skin ) skin = m_Skin;
|
||||
@@ -704,6 +709,10 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
m_bNeedsLayout = false;
|
||||
Layout( skin );
|
||||
}
|
||||
|
||||
|
||||
if (avoidUpdate>0)
|
||||
return;
|
||||
|
||||
Gwen::Rect rBounds = GetRenderBounds();
|
||||
|
||||
@@ -713,13 +722,21 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
rBounds.y += m_Padding.top;
|
||||
rBounds.h -= m_Padding.top + m_Padding.bottom;
|
||||
|
||||
int sz = Children.size();
|
||||
if (sz>100)
|
||||
{
|
||||
// printf("!\n");
|
||||
|
||||
}
|
||||
int curChild = 0;
|
||||
for (Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter)
|
||||
{
|
||||
Base* pChild = *iter;
|
||||
|
||||
curChild++;
|
||||
if ( pChild->Hidden() )
|
||||
continue;
|
||||
|
||||
|
||||
int iDock = pChild->GetDock();
|
||||
|
||||
if ( iDock & Pos::Fill )
|
||||
@@ -768,10 +785,12 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
}
|
||||
|
||||
pChild->RecurseLayout( skin );
|
||||
|
||||
}
|
||||
|
||||
m_InnerBounds = rBounds;
|
||||
|
||||
curChild = 0;
|
||||
//
|
||||
// Fill uses the left over space, so do that now.
|
||||
//
|
||||
@@ -779,10 +798,12 @@ void Base::RecurseLayout( Skin::Base* skin )
|
||||
{
|
||||
Base* pChild = *iter;
|
||||
int iDock = pChild->GetDock();
|
||||
|
||||
curChild++;
|
||||
if ( !(iDock & Pos::Fill) )
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
const Margin& margin = pChild->GetMargin();
|
||||
|
||||
pChild->SetBounds( rBounds.x + margin.left, rBounds.y + margin.top, rBounds.w - margin.left - margin.right, rBounds.h - margin.top - margin.bottom );
|
||||
|
||||
@@ -164,19 +164,43 @@ namespace Gwen
|
||||
virtual void RestrictToParent( bool restrict ) { m_bRestrictToParent = restrict; }
|
||||
virtual bool ShouldRestrictToParent() { return m_bRestrictToParent; }
|
||||
|
||||
virtual int X() const { return m_Bounds.x; }
|
||||
virtual int Y() const { return m_Bounds.y; }
|
||||
virtual int Width() const { return m_Bounds.w; }
|
||||
virtual int Height() const { return m_Bounds.h; }
|
||||
virtual int Bottom() const { return m_Bounds.y + m_Bounds.h + m_Margin.bottom; }
|
||||
virtual int Right() const { return m_Bounds.x + m_Bounds.w + m_Margin.right; }
|
||||
virtual int X() const
|
||||
{
|
||||
return m_Bounds.x;
|
||||
}
|
||||
virtual int Y() const
|
||||
{
|
||||
return m_Bounds.y;
|
||||
}
|
||||
virtual int Width() const
|
||||
{
|
||||
return m_Bounds.w;
|
||||
}
|
||||
virtual int Height() const
|
||||
{
|
||||
return m_Bounds.h;
|
||||
}
|
||||
virtual int Bottom() const
|
||||
{
|
||||
return m_Bounds.y + m_Bounds.h + m_Margin.bottom;
|
||||
}
|
||||
virtual int Right() const
|
||||
{
|
||||
return m_Bounds.x + m_Bounds.w + m_Margin.right;
|
||||
}
|
||||
|
||||
virtual const Margin& GetMargin() const { return m_Margin; }
|
||||
virtual const Padding& GetPadding() const { return m_Padding; }
|
||||
|
||||
virtual void SetPos( int x, int y );
|
||||
virtual void SetWidth( int w ) { SetSize( w, Height()); }
|
||||
virtual void SetHeight( int h ) { SetSize( Width(), h); }
|
||||
virtual void SetWidth( int w )
|
||||
{
|
||||
SetSize( w, Height());
|
||||
}
|
||||
virtual void SetHeight( int h )
|
||||
{
|
||||
SetSize( Width(), h);
|
||||
}
|
||||
virtual bool SetSize( int w, int h );
|
||||
virtual bool SetBounds( int x, int y, int w, int h );
|
||||
virtual bool SetBounds( const Gwen::Rect& bounds );
|
||||
@@ -188,7 +212,10 @@ namespace Gwen
|
||||
virtual void MoveTo (int x, int y );
|
||||
virtual void MoveBy (int x, int y );
|
||||
|
||||
virtual const Gwen::Rect& GetBounds() const { return m_Bounds; }
|
||||
virtual const Gwen::Rect& GetBounds() const
|
||||
{
|
||||
return m_Bounds;
|
||||
}
|
||||
|
||||
virtual Controls::Base* GetControlAt( int x, int y );
|
||||
|
||||
|
||||
@@ -61,6 +61,16 @@ namespace Gwen
|
||||
|
||||
Gwen::Event::Caller onBarMoved;
|
||||
|
||||
float getContentSize()
|
||||
{
|
||||
return m_fContentSize;
|
||||
}
|
||||
float getViewableContentSize() const
|
||||
{
|
||||
|
||||
return m_fViewableContentSize;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
ControlsInternal::ScrollBarButton* m_ScrollButton[2];
|
||||
|
||||
@@ -42,9 +42,14 @@ void TreeControl::Render( Skin::Base* skin )
|
||||
skin->DrawTreeControl( this );
|
||||
}
|
||||
|
||||
void TreeControl::ForceUpdateScrollBars()
|
||||
{
|
||||
m_ScrollControl->UpdateScrollBars();
|
||||
}
|
||||
|
||||
void TreeControl::OnChildBoundsChanged( Gwen::Rect /*oldChildBounds*/, Base* /*pChild*/ )
|
||||
{
|
||||
m_ScrollControl->UpdateScrollBars();
|
||||
//m_ScrollControl->UpdateScrollBars();
|
||||
}
|
||||
|
||||
void TreeControl::Clear()
|
||||
@@ -74,7 +79,7 @@ void TreeControl::OnNodeSelection( Controls::Base* /*control*/ )
|
||||
}
|
||||
|
||||
|
||||
void TreeControl::iterate(int action, int* curIndex, int* targetIndex)
|
||||
void TreeControl::iterate(int action, int* maxItem, int* curItem)
|
||||
{
|
||||
|
||||
Base::List& children = m_InnerPanel->GetChildren();
|
||||
@@ -83,7 +88,7 @@ void TreeControl::iterate(int action, int* curIndex, int* targetIndex)
|
||||
TreeNode* pChild = (*iter)->DynamicCastTreeNode();
|
||||
if ( !pChild )
|
||||
continue;
|
||||
pChild->iterate(action ,curIndex, targetIndex);
|
||||
pChild->iterate(action ,maxItem, curItem);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,26 +98,52 @@ bool TreeControl::OnKeyUp( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int curIndex=0;
|
||||
int targetIndex=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
maxIndex = curIndex;
|
||||
if (targetIndex>0)
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>0)
|
||||
{
|
||||
curIndex=0;
|
||||
int deselectIndex = targetIndex;
|
||||
targetIndex--;
|
||||
newIndex = targetIndex;
|
||||
iterate(ITERATE_ACTION_SELECT,&curIndex,&targetIndex);
|
||||
if (targetIndex<0)
|
||||
maxItem=0;
|
||||
int deselectIndex = targetItem;
|
||||
targetItem--;
|
||||
newIndex = targetItem;
|
||||
iterate(ITERATE_ACTION_SELECT,&maxItem,&targetItem);
|
||||
if (targetItem<0)
|
||||
{
|
||||
curIndex=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&curIndex,&deselectIndex);
|
||||
maxItem=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem = newIndex;
|
||||
float amount = float(newIndex)/float(maxIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -123,26 +154,52 @@ bool TreeControl::OnKeyDown( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int curIndex=0;
|
||||
int targetIndex=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
maxIndex = curIndex;
|
||||
if (targetIndex>=0)
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>=0)
|
||||
{
|
||||
curIndex=0;
|
||||
int deselectIndex = targetIndex;
|
||||
targetIndex++;
|
||||
newIndex = targetIndex;
|
||||
iterate(ITERATE_ACTION_SELECT,&curIndex,&targetIndex);
|
||||
if (targetIndex<0)
|
||||
maxItem=0;
|
||||
int deselectIndex = targetItem;
|
||||
targetItem++;
|
||||
newIndex = targetItem;
|
||||
iterate(ITERATE_ACTION_SELECT,&maxItem,&targetItem);
|
||||
if (targetItem<0)
|
||||
{
|
||||
curIndex=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&curIndex,&deselectIndex);
|
||||
maxItem=0;
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem= newIndex;
|
||||
float amount = (int)float(newIndex)/float(maxIndex);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
float amount = float(newIndex)/float(maxIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -153,12 +210,39 @@ bool TreeControl::OnKeyRight( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
ForceUpdateScrollBars();
|
||||
iterate(ITERATE_ACTION_OPEN,0,0);
|
||||
int curIndex=0;
|
||||
int targetIndex=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
float amount = float(targetIndex)/float(curIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
int maxItem=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
float amount = float(curItem)/float(maxItem);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -166,13 +250,51 @@ bool TreeControl::OnKeyLeft( bool bDown )
|
||||
{
|
||||
if (bDown)
|
||||
{
|
||||
extern int avoidUpdate;
|
||||
avoidUpdate = -3;
|
||||
|
||||
ForceUpdateScrollBars();
|
||||
|
||||
iterate(ITERATE_ACTION_CLOSE,0,0);
|
||||
|
||||
int curIndex=0;
|
||||
int targetIndex=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&curIndex,&targetIndex);
|
||||
float amount = float(targetIndex)/float(curIndex);
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
int maxItems=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItems,&curItem);
|
||||
float amount = float(curItem)/float(maxItems);
|
||||
|
||||
// m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(amount,true);
|
||||
float viewSize = m_ScrollControl->m_VerticalScrollBar->getViewableContentSize();
|
||||
float contSize = m_ScrollControl->m_VerticalScrollBar->getContentSize();
|
||||
|
||||
float curAmount = m_ScrollControl->m_VerticalScrollBar->GetScrolledAmount();
|
||||
float minCoordViewableWindow = curAmount*contSize;
|
||||
float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
//viewSize/contSize
|
||||
|
||||
printf("!\n");
|
||||
|
||||
//this->Layout(0);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Gwen
|
||||
|
||||
virtual void iterate(int action,int* curIndex, int* resultIndex);
|
||||
|
||||
virtual void ForceUpdateScrollBars();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -73,6 +73,7 @@ void TreeNode::Render( Skin::Base* skin )
|
||||
|
||||
TreeNode* TreeNode::AddNode( const UnicodeString& strLabel )
|
||||
{
|
||||
int sz = sizeof(TreeNode);
|
||||
TreeNode* node = new TreeNode( this );
|
||||
node->SetText( strLabel );
|
||||
node->Dock( Pos::Top );
|
||||
@@ -112,9 +113,16 @@ void TreeNode::Layout( Skin::Base* skin )
|
||||
|
||||
BaseClass::Layout( skin );
|
||||
}
|
||||
|
||||
//too many calls to PostLayout...
|
||||
//int numCalls = 0xfd;
|
||||
void TreeNode::PostLayout( Skin::Base* /*skin*/ )
|
||||
{
|
||||
|
||||
//int bla = numCalls&0xffff;
|
||||
//if (bla==0)
|
||||
// printf("TreeNode::PostLayout numCalls = %d\n", numCalls);
|
||||
|
||||
//numCalls++;
|
||||
if ( SizeToChildren( false, true ) )
|
||||
{
|
||||
InvalidateParent();
|
||||
|
||||
@@ -456,6 +456,9 @@ int main()
|
||||
|
||||
|
||||
pCanvas->RenderCanvas();
|
||||
extern int avoidUpdate;
|
||||
if (avoidUpdate<=0)
|
||||
avoidUpdate++;
|
||||
|
||||
// SwapBuffers( GetDC( g_pHWND ) );
|
||||
}
|
||||
|
||||
@@ -84,8 +84,10 @@ GWEN_CONTROL_CONSTRUCTOR( UnitTest )
|
||||
ctrl->Focus();
|
||||
ctrl->SetKeyboardInputEnabled(true);
|
||||
|
||||
ctrl->SetBounds( 30, 30, 200, 200 );
|
||||
ctrl->ExpandAll();
|
||||
ctrl->SetBounds( 30, 30, 200, 30+16*10 );
|
||||
//ctrl->ExpandAll();
|
||||
ctrl->ForceUpdateScrollBars();
|
||||
ctrl->OnKeyDown(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ subject to the following restrictions:
|
||||
|
||||
///todo: make this configurable in the gui
|
||||
bool useShadowMap=true;
|
||||
float shadowMapWidth=16384;
|
||||
float shadowMapHeight=16384;
|
||||
float shadowMapWorldSize=1000;
|
||||
float shadowMapWidth=8192;
|
||||
float shadowMapHeight=8192;
|
||||
float shadowMapWorldSize=200;
|
||||
float WHEEL_MULTIPLIER=0.01f;
|
||||
float MOUSE_MOVE_MULTIPLIER = 0.4f;
|
||||
#define MAX_POINTS_IN_BATCH 1024
|
||||
|
||||
@@ -86,14 +86,14 @@ public:
|
||||
{
|
||||
float pos[4];
|
||||
float orn[4];
|
||||
pos[0] = position[0];
|
||||
pos[1] = position[1];
|
||||
pos[2] = position[2];
|
||||
pos[3] = position[3];
|
||||
orn[0] =orientation[0];
|
||||
orn[1] =orientation[1];
|
||||
orn[2] =orientation[2];
|
||||
orn[3] =orientation[3];
|
||||
pos[0] = (float)position[0];
|
||||
pos[1] = (float)position[1];
|
||||
pos[2] = (float)position[2];
|
||||
pos[3] = (float)position[3];
|
||||
orn[0] =(float)orientation[0];
|
||||
orn[1] =(float)orientation[1];
|
||||
orn[2] =(float)orientation[2];
|
||||
orn[3] =(float)orientation[3];
|
||||
writeSingleInstanceTransformToCPU(pos,orn,srcIndex);
|
||||
|
||||
}
|
||||
|
||||
@@ -210,12 +210,35 @@ void SimpleOpenGL3App::drawText( const char* txt, int posX, int posY)
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
int SimpleOpenGL3App::registerCubeShape()
|
||||
int SimpleOpenGL3App::registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ)
|
||||
{
|
||||
struct GfxVertex
|
||||
{
|
||||
float x,y,z,w;
|
||||
float nx,ny,nz;
|
||||
float u,v;
|
||||
};
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
int shapeId = m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
b3AlignedObjectArray<GfxVertex> verts;
|
||||
verts.resize(numVertices);
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
verts[i].x = halfExtentsX*cube_vertices[i*9];
|
||||
verts[i].y = halfExtentsY*cube_vertices[i*9+1];
|
||||
verts[i].z = halfExtentsZ*cube_vertices[i*9+2];
|
||||
verts[i].w = cube_vertices[i*9+3];
|
||||
verts[i].nx = cube_vertices[i*9+4];
|
||||
verts[i].ny = cube_vertices[i*9+5];
|
||||
verts[i].nz = cube_vertices[i*9+6];
|
||||
verts[i].u = cube_vertices[i*9+7];
|
||||
verts[i].v = cube_vertices[i*9+8];
|
||||
}
|
||||
|
||||
int shapeId = m_instancingRenderer->registerShape(&verts[0].x,numVertices,cube_indices,numIndices);
|
||||
return shapeId;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ struct SimpleOpenGL3App
|
||||
SimpleOpenGL3App(const char* title, int width,int height);
|
||||
virtual ~SimpleOpenGL3App();
|
||||
|
||||
int registerCubeShape();
|
||||
int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f);
|
||||
int registerGraphicsSphereShape(float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10);
|
||||
|
||||
void drawGrid(int gridSize=10, float yOffset=0.001);
|
||||
|
||||
Reference in New Issue
Block a user