Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
@@ -112,7 +112,7 @@ void CrossSplitter::Layout( Skin::Base* /*skin*/ )
|
||||
else
|
||||
{
|
||||
//This should probably use Fill docking instead
|
||||
m_Sections[m_iZoomedSection]->SetBounds( 0, 0, Width(), Height() );
|
||||
m_Sections[(int)m_iZoomedSection]->SetBounds( 0, 0, Width(), Height() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void Resizer::OnMouseMoved( int x, int y, int /*deltaX*/, int /*deltaY*/ )
|
||||
if ( !m_pTarget ) return;
|
||||
if ( !m_bDepressed ) return;
|
||||
|
||||
Gwen::Rect oldBounds = m_pTarget->GetBounds();
|
||||
// Gwen::Rect oldBounds = m_pTarget->GetBounds();
|
||||
Gwen::Rect pBounds = m_pTarget->GetBounds();
|
||||
|
||||
Gwen::Point pntMin = m_pTarget->GetMinimumSize();
|
||||
|
||||
@@ -134,8 +134,14 @@ void ScrollControl::UpdateScrollBars()
|
||||
|
||||
m_InnerPanel->SetSize( Utility::Max(Width(), childrenWidth), Utility::Max(Height(), childrenHeight));
|
||||
|
||||
float wPercent = (float)Width() / (float)(childrenWidth + (m_VerticalScrollBar->Hidden() ? 0 : m_VerticalScrollBar->Width()));
|
||||
float hPercent = (float)Height() / (float)(childrenHeight + (m_HorizontalScrollBar->Hidden() ? 0 : m_HorizontalScrollBar->Height()));
|
||||
float hg = (float)(childrenWidth + (m_VerticalScrollBar->Hidden() ? 0 : m_VerticalScrollBar->Width()));
|
||||
if (hg==0.f)
|
||||
hg = 0.00001f;
|
||||
float wPercent = (float)Width() / hg;
|
||||
hg = (float)(childrenHeight + (m_HorizontalScrollBar->Hidden() ? 0 : m_HorizontalScrollBar->Height()));
|
||||
if (hg==0.f)
|
||||
hg = 0.00001f;
|
||||
float hPercent = (float)Height() / hg;
|
||||
|
||||
if ( m_bCanScrollV )
|
||||
SetVScrollRequired( hPercent >= 1 );
|
||||
|
||||
@@ -101,12 +101,12 @@ bool TreeControl::OnKeyUp( bool bDown )
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
// int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
// maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>0)
|
||||
{
|
||||
@@ -121,29 +121,32 @@ bool TreeControl::OnKeyUp( bool bDown )
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem = newIndex;
|
||||
float amount = float(newIndex)/float(maxIndex);
|
||||
// float amount = 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 minCoordViewableWindow = curAmount*contSize;
|
||||
//float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
// float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
if (contSize!=viewSize)
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
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);
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,12 +160,12 @@ bool TreeControl::OnKeyDown( bool bDown )
|
||||
if (bDown)
|
||||
{
|
||||
ForceUpdateScrollBars();
|
||||
int maxIndex = 0;
|
||||
// int maxIndex = 0;
|
||||
int newIndex = 0;
|
||||
int maxItem=0;
|
||||
int curItem=-1;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
maxIndex = maxItem;
|
||||
// maxIndex = maxItem;
|
||||
int targetItem = curItem;
|
||||
if (curItem>=0)
|
||||
{
|
||||
@@ -177,29 +180,32 @@ bool TreeControl::OnKeyDown( bool bDown )
|
||||
iterate(ITERATE_ACTION_DESELECT_INDEX,&maxItem,&deselectIndex);
|
||||
}
|
||||
curItem= newIndex;
|
||||
float amount = (int)float(newIndex)/float(maxIndex);
|
||||
// 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 minCoordViewableWindow = curAmount*contSize;
|
||||
//float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
//float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
if (contSize!=viewSize)
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
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);
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,29 +225,32 @@ bool TreeControl::OnKeyRight( bool bDown )
|
||||
int maxItem=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItem,&curItem);
|
||||
float amount = float(curItem)/float(maxItem);
|
||||
// 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 minCoordViewableWindow = curAmount*contSize;
|
||||
// float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
// float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
if (contSize!=viewSize)
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
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);
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
@@ -262,34 +271,36 @@ bool TreeControl::OnKeyLeft( bool bDown )
|
||||
int maxItems=0;
|
||||
int curItem=0;
|
||||
iterate(ITERATE_ACTION_FIND_SELECTED_INDEX,&maxItems,&curItem);
|
||||
float amount = float(curItem)/float(maxItems);
|
||||
// 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 minCoordViewableWindow = curAmount*contSize;
|
||||
// float maxCoordViewableWindow = minCoordViewableWindow+viewSize;
|
||||
float minCoordSelectedItem = curItem*16.f;
|
||||
float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
|
||||
// float maxCoordSelectedItem = (curItem+1)*16.f;
|
||||
if (contSize!=viewSize)
|
||||
{
|
||||
float newAmount = float(minCoordSelectedItem)/(contSize-viewSize);
|
||||
if (newAmount<curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
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);
|
||||
{
|
||||
int numItems = (viewSize)/16-1;
|
||||
float newAmount = float((curItem-numItems)*16)/(contSize-viewSize);
|
||||
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
if (newAmount>curAmount)
|
||||
{
|
||||
m_ScrollControl->m_VerticalScrollBar->SetScrolledAmount(newAmount,true);
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
//viewSize/contSize
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void TreeNode::Render( Skin::Base* skin )
|
||||
|
||||
TreeNode* TreeNode::AddNode( const UnicodeString& strLabel )
|
||||
{
|
||||
int sz = sizeof(TreeNode);
|
||||
// int sz = sizeof(TreeNode);
|
||||
TreeNode* node = new TreeNode( this );
|
||||
node->SetText( strLabel );
|
||||
node->Dock( Pos::Top );
|
||||
@@ -231,7 +231,7 @@ void TreeNode::iterate(int action, int* curIndex, int* targetIndex)
|
||||
|
||||
Gwen::String name = Gwen::Utility::UnicodeToString(m_Title->GetText());
|
||||
|
||||
int actualIndex = curIndex? *curIndex : -1;
|
||||
// int actualIndex = curIndex? *curIndex : -1;
|
||||
//printf("iterated over item %d with name = %s\n", actualIndex, name.c_str());
|
||||
|
||||
if (action==ITERATE_ACTION_SELECT)
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Gwen
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
GLenum format = GL_RGB;
|
||||
//GLenum format = GL_RGB;
|
||||
unsigned char* texdata = new unsigned char[256*256*4];
|
||||
for (int i=0;i<256*256;i++)
|
||||
{
|
||||
@@ -316,11 +316,11 @@ namespace Gwen
|
||||
Gwen::String converted_string = Gwen::Utility::UnicodeToString( text );
|
||||
|
||||
float yOffset=0.0f;
|
||||
for ( int i=0; i<text.length(); i++ )
|
||||
for ( int i=0; i<(int)text.length(); i++ )
|
||||
{
|
||||
wchar_t chr = text[i];
|
||||
// wchar_t chr = text[i];
|
||||
char ch = converted_string[i];
|
||||
float curSpacing = sGwenDebugFontSpacing[ch] * m_fLetterSpacing * fSize * m_fFontScale[0];
|
||||
float curSpacing = sGwenDebugFontSpacing[(int)ch] * m_fLetterSpacing * fSize * m_fFontScale[0];
|
||||
Gwen::Rect r( pos.x + yOffset, pos.y-fSize*0.2f, (fSize * m_fFontScale[0]), fSize * m_fFontScale[1] );
|
||||
|
||||
if ( m_pFontTexture )
|
||||
@@ -390,10 +390,10 @@ namespace Gwen
|
||||
Gwen::String converted_string = Gwen::Utility::UnicodeToString( text );
|
||||
float spacing = 0.0f;
|
||||
|
||||
for ( int i=0; i<text.length(); i++ )
|
||||
for ( int i=0; i<(int)text.length(); i++ )
|
||||
{
|
||||
char ch = converted_string[i];
|
||||
spacing += sGwenDebugFontSpacing[ch];
|
||||
spacing += sGwenDebugFontSpacing[(int)ch];
|
||||
}
|
||||
|
||||
p.x = spacing*m_fLetterSpacing*fSize * m_fFontScale[0];
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Gwen
|
||||
m_Render->DrawLinedRect( control->GetRenderBounds() );
|
||||
}
|
||||
|
||||
Gwen::Rect rect = control->GetRenderBounds();
|
||||
// Gwen::Rect rect = control->GetRenderBounds();
|
||||
if ( bChecked )
|
||||
{
|
||||
m_Render->SetDrawColor( Color( 0, 0, 0, 255) );
|
||||
@@ -490,7 +490,7 @@ namespace Gwen
|
||||
virtual void DrawSlider( Gwen::Controls::Base* control, bool bIsHorizontal, int numNotches, int barSize)
|
||||
{
|
||||
Gwen::Rect rect = control->GetRenderBounds();
|
||||
Gwen::Rect notchRect = rect;
|
||||
// Gwen::Rect notchRect = rect;
|
||||
|
||||
if ( bIsHorizontal )
|
||||
{
|
||||
|
||||
@@ -145,7 +145,7 @@ struct sth_stash* sth_create(int cachew, int cacheh, RenderCallbacks* renderCall
|
||||
memset(stash,0,sizeof(struct sth_stash));
|
||||
|
||||
stash->m_renderCallbacks = renderCallbacks;
|
||||
|
||||
|
||||
// Allocate memory for the first texture
|
||||
texture = (struct sth_texture*)malloc(sizeof(struct sth_texture));
|
||||
if (texture == NULL)
|
||||
@@ -161,11 +161,11 @@ struct sth_stash* sth_create(int cachew, int cacheh, RenderCallbacks* renderCall
|
||||
stash->itw = 1.0f/cachew;
|
||||
stash->ith = 1.0f/cacheh;
|
||||
stash->textures = texture;
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture, 0, stash->tw, stash->th);
|
||||
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture, 0, stash->tw, stash->th);
|
||||
|
||||
return stash;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
@@ -177,7 +177,7 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
if (fnt == NULL) goto error;
|
||||
memset(fnt,0,sizeof(struct sth_font));
|
||||
|
||||
|
||||
|
||||
// Init hash lookup.
|
||||
for (i = 0; i < HASH_LUT_SIZE; ++i)
|
||||
fnt->lut[i] = -1;
|
||||
@@ -187,8 +187,8 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
// Init stb_truetype
|
||||
if (!stbtt_InitFont(&fnt->font, fnt->data, 0))
|
||||
goto error;
|
||||
|
||||
|
||||
|
||||
|
||||
// Store normalized line height. The real line height is got
|
||||
// by multiplying the lineh by font size.
|
||||
stbtt_GetFontVMetrics(&fnt->font, &ascent, &descent, &lineGap);
|
||||
@@ -203,7 +203,7 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
fnt->next = stash->fonts;
|
||||
stash->fonts = fnt;
|
||||
|
||||
|
||||
|
||||
return idx++;
|
||||
|
||||
error:
|
||||
@@ -219,8 +219,8 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
FILE* fp = 0;
|
||||
int datasize;
|
||||
unsigned char* data = NULL;
|
||||
int idx;
|
||||
|
||||
int idx=0;
|
||||
|
||||
// Read in the font data.
|
||||
fp = fopen(path, "rb");
|
||||
if (!fp) goto error;
|
||||
@@ -229,11 +229,16 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
fseek(fp,0,SEEK_SET);
|
||||
data = (unsigned char*)malloc(datasize);
|
||||
if (data == NULL) goto error;
|
||||
fread(data, 1, datasize, fp);
|
||||
int bytesRead;
|
||||
bytesRead = fread(data, 1, datasize, fp);
|
||||
if (bytesRead)
|
||||
{
|
||||
idx = sth_add_font_from_memory(stash, data);
|
||||
}
|
||||
fclose(fp);
|
||||
fp = 0;
|
||||
|
||||
|
||||
idx = sth_add_font_from_memory(stash, data);
|
||||
// Modify type of the loaded font.
|
||||
if (idx)
|
||||
stash->fonts->type = TTFONT_FILE;
|
||||
@@ -241,7 +246,7 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
free(data);
|
||||
|
||||
return idx;
|
||||
|
||||
|
||||
error:
|
||||
if (data) free(data);
|
||||
if (fp) fclose(fp);
|
||||
@@ -271,7 +276,7 @@ int sth_add_bitmap_font(struct sth_stash* stash, int ascent, int descent, int li
|
||||
fnt->type = BMFONT;
|
||||
fnt->next = stash->fonts;
|
||||
stash->fonts = fnt;
|
||||
|
||||
|
||||
return idx++;
|
||||
|
||||
error:
|
||||
@@ -295,7 +300,7 @@ error:
|
||||
|
||||
if (stash == NULL) return;
|
||||
texture = stash->textures;
|
||||
while (texture != NULL && texture->id != id)
|
||||
while (texture != NULL && texture->id != id)
|
||||
texture = texture->next;
|
||||
|
||||
if (texture == NULL)
|
||||
@@ -313,7 +318,7 @@ error:
|
||||
while (fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT) return;
|
||||
|
||||
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (!decutf8(&state, &codepoint, *(unsigned char*)s)) break;
|
||||
@@ -338,7 +343,7 @@ error:
|
||||
glyph->xoff = xoffset;
|
||||
glyph->yoff = yoffset - base;
|
||||
glyph->xadv = xadvance;
|
||||
|
||||
|
||||
// Find code point and size.
|
||||
h = hashint(codepoint) & (HASH_LUT_SIZE-1);
|
||||
// Insert char to hash lookup.
|
||||
@@ -353,7 +358,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
float scale;
|
||||
struct sth_texture* texture = NULL;
|
||||
struct sth_glyph* glyph = NULL;
|
||||
|
||||
|
||||
unsigned int h;
|
||||
float size = isize/10.0f;
|
||||
int rh;
|
||||
@@ -369,10 +374,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
i = fnt->glyphs[i].next;
|
||||
}
|
||||
// Could not find glyph.
|
||||
|
||||
|
||||
// For bitmap fonts: ignore this glyph.
|
||||
if (fnt->type == BMFONT) return 0;
|
||||
|
||||
|
||||
// For truetype fonts: create this glyph.
|
||||
scale = stbtt_ScaleForPixelHeight(&fnt->font, size);
|
||||
g = stbtt_FindGlyphIndex(&fnt->font, codepoint);
|
||||
@@ -380,7 +385,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
stbtt_GetGlyphBitmapBox(&fnt->font, g, scale,scale, &x0,&y0,&x1,&y1);
|
||||
gw = x1-x0;
|
||||
gh = y1-y0;
|
||||
|
||||
|
||||
// Check if glyph is larger than maximum texture size
|
||||
if (gw >= stash->tw || gh >= stash->th)
|
||||
return 0;
|
||||
@@ -396,7 +401,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
if (texture->rows[i].h >= rh && texture->rows[i].x+gw+1 <= stash->tw)
|
||||
br = &texture->rows[i];
|
||||
}
|
||||
|
||||
|
||||
// If no row is found, there are 3 possibilities:
|
||||
// - add new row
|
||||
// - try next texture
|
||||
@@ -421,10 +426,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
texture = texture->next;
|
||||
if (texture == NULL) goto error;
|
||||
memset(texture,0,sizeof(struct sth_texture));
|
||||
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture,0,stash->tw,stash->th);
|
||||
|
||||
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -434,10 +439,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
br->x = BORDER_X_LEFT;
|
||||
br->y = py+BORDER_Y_BOTTOM;
|
||||
br->h = rh+ADDITIONAL_HEIGHT;
|
||||
texture->nrows++;
|
||||
texture->nrows++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Alloc space for new glyph.
|
||||
fnt->nglyphs++;
|
||||
fnt->glyphs = (sth_glyph*)realloc(fnt->glyphs, fnt->nglyphs*sizeof(struct sth_glyph));
|
||||
@@ -473,7 +478,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
stash->m_renderCallbacks->updateTexture(texture,glyph, stash->tw, stash->th);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return glyph;
|
||||
|
||||
error:
|
||||
@@ -486,26 +491,26 @@ static int get_quad(struct sth_stash* stash, struct sth_font* fnt, struct sth_gl
|
||||
{
|
||||
float rx,ry;
|
||||
float scale = 1.f/s_retinaScale;//1.0f;
|
||||
|
||||
|
||||
if (fnt->type == BMFONT)
|
||||
scale = isize/(glyph->size*10.0f);
|
||||
|
||||
rx = (*x + scale * float(glyph->xoff));
|
||||
ry = (*y + scale * float(glyph->yoff));
|
||||
|
||||
|
||||
q->x0 = rx;
|
||||
q->y0 = ry + 1.5f*0.5f*float(isize)/10.f;
|
||||
|
||||
q->x1 = rx + scale * float(glyph->x1 - glyph->x0_);
|
||||
q->y1 = ry + scale * float(glyph->y1 - glyph->y0)+ 1.5f*0.5f*float(isize)/10.f;
|
||||
|
||||
|
||||
q->s0 = float(glyph->x0_) * stash->itw;
|
||||
q->t0 = float(glyph->y0) * stash->ith;
|
||||
q->s1 = float(glyph->x1) * stash->itw;
|
||||
q->t1 = float(glyph->y1) * stash->ith;
|
||||
|
||||
|
||||
*x += scale * glyph->xadv;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -523,7 +528,7 @@ static Vertex* setv(Vertex* v, float x, float y, float s, float t, float width,
|
||||
}
|
||||
v->position.p[2] = 0.f;
|
||||
v->position.p[3] = 1.f;
|
||||
|
||||
|
||||
v->uv.p[0] = s;
|
||||
v->uv.p[1] = t;
|
||||
|
||||
@@ -531,7 +536,7 @@ static Vertex* setv(Vertex* v, float x, float y, float s, float t, float width,
|
||||
v->colour.p[1] = 0.1f;
|
||||
v->colour.p[2] = 0.1f;
|
||||
v->colour.p[3] = 1.f;
|
||||
|
||||
|
||||
return v+1;
|
||||
}
|
||||
|
||||
@@ -545,7 +550,7 @@ static void flush_draw(struct sth_stash* stash)
|
||||
{
|
||||
if (texture->nverts > 0)
|
||||
{
|
||||
stash->m_renderCallbacks->render(texture);
|
||||
stash->m_renderCallbacks->render(texture);
|
||||
texture->nverts = 0;
|
||||
}
|
||||
texture = texture->next;
|
||||
@@ -584,7 +589,7 @@ void sth_end_draw(struct sth_stash* stash)
|
||||
stash->nverts += 6;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
flush_draw(stash);
|
||||
stash->drawing = 0;
|
||||
}
|
||||
@@ -606,7 +611,7 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
Vertex* v;
|
||||
struct sth_font* fnt = NULL;
|
||||
|
||||
|
||||
if (stash == NULL) return;
|
||||
|
||||
if (!stash->textures) return;
|
||||
@@ -614,23 +619,23 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
int once = true;
|
||||
for (; once; ++s)
|
||||
{
|
||||
once=false;
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
continue;
|
||||
glyph = get_glyph(stash, fnt, codepoint, isize);
|
||||
if (!glyph)
|
||||
if (!glyph)
|
||||
continue;
|
||||
texture = glyph->texture;
|
||||
if (texture->nverts+6 >= VERT_COUNT)
|
||||
flush_draw(stash);
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q))
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q))
|
||||
continue;
|
||||
|
||||
|
||||
v = &texture->newverts[texture->nverts];
|
||||
q.x0 = 0;
|
||||
q.y0 = 0;
|
||||
@@ -646,11 +651,11 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
v = setv(v, q.x0, q.y1, 0,1,(float)screenwidth,(float)screenheight);
|
||||
texture->nverts += 6;
|
||||
}
|
||||
|
||||
|
||||
flush_draw(stash);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (dx) *dx = x;
|
||||
}
|
||||
@@ -664,7 +669,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
float x, float y,
|
||||
const char* s, float* dx, int screenwidth, int screenheight, int measureOnly, float retinaScale)
|
||||
{
|
||||
|
||||
|
||||
unsigned int codepoint;
|
||||
struct sth_glyph* glyph = NULL;
|
||||
struct sth_texture* texture = NULL;
|
||||
@@ -673,7 +678,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
Vertex* v;
|
||||
struct sth_font* fnt = NULL;
|
||||
|
||||
|
||||
s_retinaScale = retinaScale;
|
||||
if (stash == NULL) return;
|
||||
|
||||
@@ -682,23 +687,23 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
continue;
|
||||
glyph = get_glyph(stash, fnt, codepoint, isize);
|
||||
if (!glyph) continue;
|
||||
texture = glyph->texture;
|
||||
|
||||
|
||||
if (!measureOnly)
|
||||
{
|
||||
if (texture->nverts+6 >= VERT_COUNT)
|
||||
flush_draw(stash);
|
||||
}
|
||||
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q)) continue;
|
||||
|
||||
|
||||
if (!measureOnly)
|
||||
{
|
||||
v = &texture->newverts[texture->nverts];
|
||||
@@ -714,7 +719,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
texture->nverts += 6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dx) *dx = x;
|
||||
}
|
||||
|
||||
@@ -730,16 +735,16 @@ void sth_dim_text(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
struct sth_font* fnt = NULL;
|
||||
float x = 0, y = 0;
|
||||
|
||||
if (stash == NULL)
|
||||
|
||||
if (stash == NULL)
|
||||
return;
|
||||
if (!stash->textures)
|
||||
if (!stash->textures)
|
||||
return;
|
||||
fnt = stash->fonts;
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
*minx = *maxx = x;
|
||||
*miny = *maxy = y;
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ InternalOpenGL2RenderCallbacks::~InternalOpenGL2RenderCallbacks()
|
||||
void InternalOpenGL2RenderCallbacks::display2()
|
||||
{
|
||||
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
// glViewport(0,0,10,10);
|
||||
|
||||
//const float timeScale = 0.008f;
|
||||
@@ -48,39 +47,31 @@ void InternalOpenGL2RenderCallbacks::display2()
|
||||
glBindBuffer(GL_ARRAY_BUFFER, s_vertexBuffer);
|
||||
glBindVertexArray(s_vertexArrayObject);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
// glBindTexture(GL_TEXTURE_2D,m_texturehandle);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
vec2 p( 0.f,0.f);//?b?0.5f * sinf(timeValue), 0.5f * cosf(timeValue) );
|
||||
glUniform2fv(data->m_positionUniform, 1, (const GLfloat *)&p);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(data->m_positionAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(data->m_colourAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(data->m_textureAttribute);
|
||||
|
||||
glVertexAttribPointer(data->m_positionAttribute, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)0);
|
||||
glVertexAttribPointer(data->m_colourAttribute , 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)sizeof(vec4));
|
||||
glVertexAttribPointer(data->m_textureAttribute , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(sizeof(vec4)+sizeof(vec4)));
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
/*
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
|
||||
@@ -101,10 +92,7 @@ void InternalOpenGL2RenderCallbacks::display2()
|
||||
|
||||
void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_glyph* glyph, int textureWidth, int textureHeight)
|
||||
{
|
||||
GLint err;
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
if (glyph)
|
||||
@@ -114,13 +102,11 @@ void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_gly
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, *gltexture);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, textureWidth, textureHeight, 0, GL_RED, GL_UNSIGNED_BYTE, texture->m_texels);
|
||||
|
||||
GLenum err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
} else
|
||||
{
|
||||
@@ -132,8 +118,7 @@ void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_gly
|
||||
|
||||
//create new texture
|
||||
glGenTextures(1, texId);
|
||||
GLenum err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
@@ -143,8 +128,7 @@ void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_gly
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, textureWidth, textureHeight, 0, GL_RED, GL_UNSIGNED_BYTE, texture->m_texels);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
////////////////////////////
|
||||
//create the other data
|
||||
@@ -155,8 +139,7 @@ void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_gly
|
||||
glGenBuffers(1, &s_vertexBuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, s_vertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, VERT_COUNT * sizeof(Vertex), texture->newverts, GL_DYNAMIC_DRAW);
|
||||
GLuint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
for (int i=0;i<INDEX_COUNT;i++)
|
||||
{
|
||||
@@ -167,9 +150,8 @@ void InternalOpenGL2RenderCallbacks::updateTexture(sth_texture* texture, sth_gly
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s_indexBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER,INDEX_COUNT*sizeof(int), s_indexData,GL_STATIC_DRAW);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
}
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
}
|
||||
} else
|
||||
{
|
||||
//delete texture
|
||||
@@ -196,13 +178,10 @@ void InternalOpenGL2RenderCallbacks::render(sth_texture* texture)
|
||||
|
||||
GLuint* texId = (GLuint*) texture->m_userData;
|
||||
|
||||
GLint err;
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, *texId);
|
||||
bool useFiltering = false;
|
||||
@@ -215,25 +194,21 @@ void InternalOpenGL2RenderCallbacks::render(sth_texture* texture)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, s_vertexBuffer);
|
||||
glBindVertexArray(s_vertexArrayObject);
|
||||
glBufferData(GL_ARRAY_BUFFER, texture->nverts * sizeof(Vertex), &texture->newverts[0].position.p[0], GL_DYNAMIC_DRAW);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s_indexBuffer);
|
||||
|
||||
//glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
int indexCount = texture->nverts;
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
@@ -32,7 +32,14 @@ ENDIF(APPLE)
|
||||
|
||||
#no Linux detection?
|
||||
IF(NOT WIN32 AND NOT APPLE)
|
||||
SET(OpenGLWindow_SRCS ${OpenGLWindowLinux_CPP} ${OpenGLWindowCommon_CPP} )
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows
|
||||
)
|
||||
ADD_DEFINITIONS(-DGLEW_STATIC)
|
||||
ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1")
|
||||
ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1")
|
||||
|
||||
SET(OpenGLWindow_SRCS ${OpenGLWindowLinux_CPP} ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows/glew.c ${OpenGLWindowCommon_CPP} )
|
||||
ENDIF()
|
||||
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ subject to the following restrictions:
|
||||
|
||||
///todo: make this configurable in the gui
|
||||
bool useShadowMap=true;//false;//true;
|
||||
float shadowMapWidth=8192;
|
||||
float shadowMapHeight=8192;
|
||||
int shadowMapWidth=8192;
|
||||
int shadowMapHeight=8192;
|
||||
float shadowMapWorldSize=100;
|
||||
float WHEEL_MULTIPLIER=0.01f;
|
||||
float MOUSE_MOVE_MULTIPLIER = 0.4f;
|
||||
|
||||
@@ -131,8 +131,8 @@ void GLPrimitiveRenderer::loadBufferData()
|
||||
glGenBuffers(1, &m_data->m_vertexBuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(Vertex), vertexData, GL_DYNAMIC_DRAW);
|
||||
GLuint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
@@ -142,16 +142,14 @@ void GLPrimitiveRenderer::loadBufferData()
|
||||
|
||||
glEnableVertexAttribArray(m_data->m_positionAttribute);
|
||||
glEnableVertexAttribArray(m_data->m_colourAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(m_data->m_textureAttribute);
|
||||
|
||||
glVertexAttribPointer(m_data->m_positionAttribute, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)0);
|
||||
glVertexAttribPointer(m_data->m_colourAttribute , 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)sizeof(vec4));
|
||||
glVertexAttribPointer(m_data->m_textureAttribute , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(sizeof(vec4)+sizeof(vec4)));
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
@@ -191,8 +189,7 @@ void GLPrimitiveRenderer::loadBufferData()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256,256,0,GL_RGB,GL_UNSIGNED_BYTE,image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
delete[] image;
|
||||
|
||||
@@ -217,36 +214,25 @@ void GLPrimitiveRenderer::drawLine()
|
||||
|
||||
void GLPrimitiveRenderer::drawRect(float x0, float y0, float x1, float y1, float color[4])
|
||||
{
|
||||
GLint err;
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,m_data->m_texturehandle);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
drawTexturedRect(x0,y0,x1,y1,color,0,0,1,1);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
}
|
||||
|
||||
void GLPrimitiveRenderer::drawTexturedRect(float x0, float y0, float x1, float y1, float color[4], float u0,float v0, float u1, float v1, int useRGBA)
|
||||
{
|
||||
GLint err;
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
glUseProgram(m_data->m_shaderProg);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vertexBuffer);
|
||||
glBindVertexArray(m_data->m_vertexArrayObject);
|
||||
@@ -263,10 +249,10 @@ void GLPrimitiveRenderer::drawTexturedRect(float x0, float y0, float x1, float y
|
||||
}
|
||||
|
||||
Vertex vertexData[4] = {
|
||||
{ vec4(-1.+2.*x0/float(m_screenWidth), 1.-2.*y0/float(m_screenHeight), 0, 0 ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u0,v0)},
|
||||
{ vec4(-1.+2.*x0/float(m_screenWidth), 1.-2.*y1/float(m_screenHeight), 0, 1 ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u0,v1)},
|
||||
{ vec4( -1.+2.*x1/float(m_screenWidth), 1.-2.*y1/float(m_screenHeight), 1, 1 ), vec4(color[0], color[1], color[2], color[3]) ,vec2(u1,v1)},
|
||||
{ vec4( -1.+2.*x1/float(m_screenWidth), 1.-2.*y0/float(m_screenHeight), 1, 0 ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u1,v0)}
|
||||
{ vec4(-1.f+2.f*x0/float(m_screenWidth), 1.f-2.f*y0/float(m_screenHeight), 0.f, 0.f ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u0,v0)},
|
||||
{ vec4(-1.f+2.f*x0/float(m_screenWidth), 1.f-2.f*y1/float(m_screenHeight), 0.f, 1.f ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u0,v1)},
|
||||
{ vec4( -1.f+2.f*x1/float(m_screenWidth), 1.f-2.f*y1/float(m_screenHeight), 1.f, 1.f ), vec4(color[0], color[1], color[2], color[3]) ,vec2(u1,v1)},
|
||||
{ vec4( -1.f+2.f*x1/float(m_screenWidth), 1.f-2.f*y0/float(m_screenHeight), 1.f, 0.f ), vec4( color[0], color[1], color[2], color[3] ) ,vec2(u1,v0)}
|
||||
};
|
||||
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0,4 * sizeof(Vertex), vertexData);
|
||||
@@ -276,8 +262,7 @@ void GLPrimitiveRenderer::drawTexturedRect(float x0, float y0, float x1, float y
|
||||
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
vec2 p( 0.f,0.f);//?b?0.5f * sinf(timeValue), 0.5f * cosf(timeValue) );
|
||||
if (useRGBA)
|
||||
@@ -290,60 +275,47 @@ void GLPrimitiveRenderer::drawTexturedRect(float x0, float y0, float x1, float y
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(m_data->m_positionAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(m_data->m_colourAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(m_data->m_textureAttribute);
|
||||
|
||||
glVertexAttribPointer(m_data->m_positionAttribute, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)0);
|
||||
glVertexAttribPointer(m_data->m_colourAttribute , 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)sizeof(vec4));
|
||||
glVertexAttribPointer(m_data->m_textureAttribute , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(sizeof(vec4)+sizeof(vec4)));
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_data->m_indexBuffer);
|
||||
|
||||
//glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
int indexCount = 6;
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
//glDisableVertexAttribArray(m_data->m_textureAttribute);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glUseProgram(0);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -119,55 +119,37 @@ public:
|
||||
{
|
||||
m_yOffset=0;
|
||||
glEnable(GL_BLEND);
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
//glColor4ub(255,0,0,255);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// saveOpenGLState(width,height);//m_glutScreenWidth,m_glutScreenHeight);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
}
|
||||
virtual void End()
|
||||
{
|
||||
@@ -375,10 +357,7 @@ public:
|
||||
glBindTexture(GL_TEXTURE_2D,texHandle);
|
||||
// glDisable(GL_DEPTH_TEST);
|
||||
|
||||
GLint err;
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
/* bool useFiltering = true;
|
||||
@@ -406,8 +385,8 @@ public:
|
||||
m_primitiveRenderer->drawTexturedRect(rect.x, rect.y+m_yOffset, rect.x+rect.w, rect.y+rect.h+m_yOffset, color,0+add,0,1+add,1,true);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ void gltLoadShaderSrc(const char *szShaderSrc, GLuint shader)
|
||||
GLuint gltLoadShaderPair(const char *szVertexProg, const char *szFragmentProg)
|
||||
{
|
||||
|
||||
GLuint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
// Temporary Shader objects
|
||||
GLuint hVertexShader;
|
||||
@@ -36,7 +35,7 @@ GLuint gltLoadShaderPair(const char *szVertexProg, const char *szFragmentProg)
|
||||
|
||||
// Compile them
|
||||
glCompileShader(hVertexShader);
|
||||
err = glGetError();
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glGetShaderiv(hVertexShader, GL_COMPILE_STATUS, &testVal);
|
||||
if(testVal == GL_FALSE)
|
||||
@@ -51,10 +50,10 @@ GLuint gltLoadShaderPair(const char *szVertexProg, const char *szFragmentProg)
|
||||
return (GLuint)NULL;
|
||||
}
|
||||
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glCompileShader(hFragmentShader);
|
||||
err = glGetError();
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glGetShaderiv(hFragmentShader, GL_COMPILE_STATUS, &testVal);
|
||||
if(testVal == GL_FALSE)
|
||||
@@ -69,7 +68,7 @@ GLuint gltLoadShaderPair(const char *szVertexProg, const char *szFragmentProg)
|
||||
return (GLuint)NULL;
|
||||
}
|
||||
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
// Check for errors
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
virtual void setWindowTitle(const char* title);
|
||||
|
||||
|
||||
int fileOpenDialog(char* filename, int maxNameLength);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -989,8 +989,48 @@ void MacOpenGLWindow::setRequestExit()
|
||||
m_internalData->m_exitRequested = true;
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
int MacOpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)
|
||||
{
|
||||
//save/restore the OpenGL context, NSOpenPanel can mess it up
|
||||
//http://stackoverflow.com/questions/13987148/nsopenpanel-breaks-my-sdl-opengl-app
|
||||
|
||||
NSOpenGLContext *foo = [NSOpenGLContext currentContext];
|
||||
// get the url of a .txt file
|
||||
NSOpenPanel * zOpenPanel = [NSOpenPanel openPanel];
|
||||
NSArray * zAryOfExtensions = [NSArray arrayWithObject:@"urdf"];
|
||||
[zOpenPanel setAllowedFileTypes:zAryOfExtensions];
|
||||
NSInteger zIntResult = [zOpenPanel runModal];
|
||||
|
||||
[foo makeCurrentContext];
|
||||
|
||||
if (zIntResult == NSFileHandlingPanelCancelButton) {
|
||||
NSLog(@"readUsingOpenPanel cancelled");
|
||||
return 0;
|
||||
}
|
||||
NSURL *zUrl = [zOpenPanel URL];
|
||||
if (zUrl)
|
||||
{
|
||||
//without the file://
|
||||
NSString *myString = [zUrl absoluteString];
|
||||
int slen = [myString length];
|
||||
if (slen < maxNameLength)
|
||||
{
|
||||
const char *cfilename=[myString UTF8String];
|
||||
//expect file:// at start of URL
|
||||
const char* p = strstr(cfilename, "file://");
|
||||
if (p==cfilename)
|
||||
{
|
||||
int actualLen = strlen(cfilename)-7;
|
||||
memcpy(filename, cfilename+7,actualLen);
|
||||
filename[actualLen]=0;
|
||||
return actualLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -430,19 +430,17 @@ static void writeTextureToFile(int textureWidth, int textureHeight, const char*
|
||||
{
|
||||
int numComponents = 4;
|
||||
//glPixelStorei(GL_PACK_ALIGNMENT,1);
|
||||
GLuint err=glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
b3Assert(glGetError()==GL_NO_ERROR);
|
||||
//glReadBuffer(GL_BACK);//COLOR_ATTACHMENT0);
|
||||
err=glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
float* orgPixels = (float*)malloc(textureWidth*textureHeight*numComponents*4);
|
||||
glReadPixels(0,0,textureWidth, textureHeight, GL_RGBA, GL_FLOAT, orgPixels);
|
||||
//it is useful to have the actual float values for debugging purposes
|
||||
|
||||
//convert float->char
|
||||
char* pixels = (char*)malloc(textureWidth*textureHeight*numComponents);
|
||||
err=glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
for (int j=0;j<textureHeight;j++)
|
||||
{
|
||||
|
||||
@@ -137,6 +137,40 @@ void Win32OpenGLWindow::endRendering()
|
||||
|
||||
}
|
||||
|
||||
int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||
{
|
||||
//wchar_t wideChars[1024];
|
||||
|
||||
OPENFILENAME ofn ;
|
||||
ZeroMemory( &ofn , sizeof( ofn));
|
||||
ofn.lStructSize = sizeof ( ofn );
|
||||
ofn.hwndOwner = NULL ;
|
||||
|
||||
#ifdef UNICODE
|
||||
WCHAR bla[1024];
|
||||
ofn.lpstrFile = bla;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = 1023;
|
||||
ofn.lpstrFilter = L"URDF\0*.urdf\0";
|
||||
#else
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = 1023;
|
||||
//ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
|
||||
ofn.lpstrFilter = "URDF\0*.urdf\0";
|
||||
|
||||
#endif
|
||||
|
||||
ofn.nFilterIndex =1;
|
||||
ofn.lpstrFileTitle = NULL ;
|
||||
ofn.nMaxFileTitle = 0 ;
|
||||
ofn.lpstrInitialDir=NULL ;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
|
||||
GetOpenFileName( &ofn );
|
||||
return strlen(fileName);
|
||||
|
||||
|
||||
//return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
virtual void endRendering();
|
||||
|
||||
virtual float getRetinaScale() const {return 1.f;}
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,34 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
|
||||
GLint att[] = { GLX_RGBA,
|
||||
GLX_DEPTH_SIZE, 24,
|
||||
GLX_RED_SIZE , 8,
|
||||
GLX_GREEN_SIZE , 8,
|
||||
GLX_BLUE_SIZE , 8,
|
||||
GLX_ALPHA_SIZE , 8,
|
||||
GLX_STENCIL_SIZE , 8,
|
||||
GLX_DOUBLEBUFFER,
|
||||
None };
|
||||
/*
|
||||
static int att[] =
|
||||
{
|
||||
GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None
|
||||
|
||||
GLX_X_RENDERABLE , True,
|
||||
GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
|
||||
GLX_RENDER_TYPE , GLX_RGBA_BIT,
|
||||
GLX_X_VISUAL_TYPE , GLX_TRUE_COLOR,
|
||||
GLX_RED_SIZE , 8,
|
||||
GLX_GREEN_SIZE , 8,
|
||||
GLX_BLUE_SIZE , 8,
|
||||
GLX_ALPHA_SIZE , 8,
|
||||
GLX_DEPTH_SIZE , 24,
|
||||
GLX_STENCIL_SIZE , 8,
|
||||
GLX_DOUBLEBUFFER , True,
|
||||
None
|
||||
};
|
||||
*/
|
||||
static bool forceOpenGL3 = true;
|
||||
|
||||
|
||||
@@ -37,6 +64,7 @@ static bool forceOpenGL3 = true;
|
||||
#ifdef DYNAMIC_LOAD_X11_FUNCTIONS
|
||||
|
||||
///our X11 function typedefs
|
||||
|
||||
typedef int (*PFNXFREE)(void*);
|
||||
typedef XErrorHandler (* PFNXSETERRORHANDLER) (XErrorHandler);
|
||||
typedef int (* PFNXSYNC) (Display* a,Bool b);
|
||||
@@ -47,10 +75,14 @@ typedef int (*PFNXMAPWINDOW) (Display*, Window);
|
||||
typedef int (*PFNXSTORENAME) (Display* a,Window b,_Xconst char* c);
|
||||
typedef int (*PFNXCLOSEDISPLAY) (Display* a);
|
||||
typedef int (*PFNXDESTROYWINDOW) (Display* a,Window b);
|
||||
typedef int (*PFNXRAISEWINDOW) (Display* a, Window b);
|
||||
|
||||
#if NeedWidePrototypes
|
||||
typedef KeySym (*PFNXKEYCODETOKEYSYM) (Display* a,unsigned int b,int c);
|
||||
typedef KeySym* (*PFNXGETKEYBOARDMAPPING) (Display*,unsigned int,int,int*);
|
||||
typedef KeySym (*PFNXKEYCODETOKEYSYM) (Display* a,unsigned int b,int c);
|
||||
#else
|
||||
typedef KeySym (*PFNXKEYCODETOKEYSYM) (Display* a,KeyCode b,int c);
|
||||
typedef KeySym* (*PFNXGETKEYBOARDMAPPING) (Display*,KeyCode,int,int*);
|
||||
typedef KeySym (*PFNXKEYCODETOKEYSYM) (Display* a,KeyCode b,int c);
|
||||
#endif
|
||||
typedef void (*PFNXCONVERTCASE) (KeySym /* sym */,KeySym * /* lower */,KeySym * /* upper */);
|
||||
typedef int (*PFNXPENDING) (Display* a);
|
||||
@@ -63,6 +95,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
#define X11_LIBRARY "libX11.so.6"
|
||||
|
||||
#define MyXSync m_data->m_x11_XSync
|
||||
#define MyXGetKeyboardMapping m_data->m_x11_XGetKeyboardMapping
|
||||
#define MyXSetErrorHandler m_data->m_x11_XSetErrorHandler
|
||||
#define MyXOpenDisplay m_data->m_x11_XOpenDisplay
|
||||
#define MyXCreateColormap m_data->m_x11_XCreateColormap
|
||||
@@ -70,6 +103,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
#define MyXMapWindow m_data->m_x11_XMapWindow
|
||||
#define MyXStoreName m_data->m_x11_XStoreName
|
||||
#define MyXDestroyWindow m_data->m_x11_XDestroyWindow
|
||||
#define MyXRaiseWindow m_data->m_x11_XRaiseWindow
|
||||
#define MyXCloseDisplay m_data->m_x11_XCloseDisplay
|
||||
#define MyXKeycodeToKeysym m_data->m_x11_XKeycodeToKeysym
|
||||
#define MyXConvertCase m_data->m_x11_XConvertCase
|
||||
@@ -87,6 +121,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
|
||||
#else
|
||||
#define MyXSync XSync
|
||||
#define MyXGetKeyboardMapping XGetKeyboardMapping
|
||||
#define MyXSetErrorHandler XSetErrorHandler
|
||||
#define MyXOpenDisplay XOpenDisplay
|
||||
#define MyXCreateColormap XCreateColormap
|
||||
@@ -94,6 +129,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
#define MyXMapWindow XMapWindow
|
||||
#define MyXStoreName XStoreName
|
||||
#define MyXDestroyWindow XDestroyWindow
|
||||
#define MyXRaiseWindow XRaiseWindow
|
||||
#define MyXCloseDisplay XCloseDisplay
|
||||
#define MyXKeycodeToKeysym XKeycodeToKeysym
|
||||
#define MyXConvertCase XConvertCase
|
||||
@@ -136,7 +172,9 @@ struct InternalData2
|
||||
PFNXSTORENAME m_x11_XStoreName;
|
||||
PFNXCLOSEDISPLAY m_x11_XCloseDisplay;
|
||||
PFNXDESTROYWINDOW m_x11_XDestroyWindow;
|
||||
PFNXRAISEWINDOW m_x11_XRaiseWindow;
|
||||
PFNXKEYCODETOKEYSYM m_x11_XKeycodeToKeysym;
|
||||
PFNXGETKEYBOARDMAPPING m_x11_XGetKeyboardMapping;
|
||||
PFNXCONVERTCASE m_x11_XConvertCase;
|
||||
PFNXPENDING m_x11_XPending;
|
||||
PFNXNEXTEVENT m_x11_XNextEvent;
|
||||
@@ -190,13 +228,15 @@ struct InternalData2
|
||||
if (missingFunc) { printf("Error: missing func XMapWindow in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
missingFunc = ((m_x11_XStoreName = (PFNXSTORENAME) dlsym(m_x11_library,"XStoreName"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XStoreName in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
|
||||
missingFunc = ((m_x11_XCloseDisplay = (PFNXCLOSEDISPLAY) dlsym(m_x11_library,"XCloseDisplay"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XCloseDisplay in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
|
||||
missingFunc = ((m_x11_XDestroyWindow = (PFNXDESTROYWINDOW) dlsym(m_x11_library,"XDestroyWindow"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XMapWindow in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
if (missingFunc) { printf("Error: missing func XDestroyWindow in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
missingFunc = ((m_x11_XRaiseWindow = (PFNXRAISEWINDOW) dlsym(m_x11_library,"XRaiseWindow"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XRaiseWindow in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
|
||||
missingFunc = ((m_x11_XGetKeyboardMapping = (PFNXGETKEYBOARDMAPPING) dlsym(m_x11_library,"XGetKeyboardMapping"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XGetKeyboardMapping in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
missingFunc = ((m_x11_XKeycodeToKeysym = (PFNXKEYCODETOKEYSYM) dlsym(m_x11_library,"XKeycodeToKeysym"))==NULL) | missingFunc;
|
||||
if (missingFunc) { printf("Error: missing func XKeycodeToKeysym in %s, exiting!\n", X11_LIBRARY); exit(0);}
|
||||
missingFunc = ((m_x11_XConvertCase = (PFNXCONVERTCASE) dlsym(m_x11_library,"XConvertCase"))==NULL) | missingFunc;
|
||||
@@ -612,9 +652,21 @@ void X11OpenGLWindow::closeWindow()
|
||||
|
||||
int X11OpenGLWindow::getAsciiCodeFromVirtualKeycode(int keycode)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
KeySym key, key_lc, key_uc;
|
||||
|
||||
key = MyXKeycodeToKeysym( m_data->m_dpy, keycode, 0 );
|
||||
int keysyms_per_keycode_return;
|
||||
KeySym *keysym = MyXGetKeyboardMapping(m_data->m_dpy,
|
||||
keycode,
|
||||
1,
|
||||
&keysyms_per_keycode_return);
|
||||
|
||||
key = keysym[0];
|
||||
|
||||
|
||||
//key = MyXKeycodeToKeysym( m_data->m_dpy, keycode, 0 );
|
||||
|
||||
switch( key )
|
||||
{
|
||||
case XK_Escape: return B3G_ESCAPE;
|
||||
@@ -660,9 +712,12 @@ int X11OpenGLWindow::getAsciiCodeFromVirtualKeycode(int keycode)
|
||||
{
|
||||
return (int) key;
|
||||
}
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
MyXFree(keysym);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::pumpMessage()
|
||||
@@ -913,4 +968,29 @@ b3KeyboardCallback X11OpenGLWindow::getKeyboardCallback()
|
||||
{
|
||||
return m_data->m_keyboardCallback;
|
||||
}
|
||||
#include <stdio.h>
|
||||
|
||||
int X11OpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)
|
||||
{
|
||||
int len = 0;
|
||||
FILE * output = popen("zenity --file-selection --file-filter=\"*.urdf\" --file-filter=\"*.*\"","r");
|
||||
if (output)
|
||||
{
|
||||
while( fgets(filename, maxNameLength-1, output) != NULL )
|
||||
{
|
||||
len=strlen(filename);
|
||||
if (len>0)
|
||||
{
|
||||
filename[len-1]=0;
|
||||
printf("file open (length=%d) = %s\n", len,filename);
|
||||
}
|
||||
}
|
||||
pclose(output);
|
||||
} else
|
||||
{
|
||||
printf("Error: fileOpenDialog no popen output, perhaps install zenity?\n");
|
||||
}
|
||||
MyXRaiseWindow(m_data->m_dpy, m_data->m_win);
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
|
||||
virtual void setWindowTitle(const char* title);
|
||||
|
||||
int fileOpenDialog(char* filename, int maxNameLength);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ class b3gWindowInterface
|
||||
|
||||
virtual float getRetinaScale() const =0;
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif //B3G_WINDOW_INTERFACE_H
|
||||
@@ -5,8 +5,14 @@
|
||||
--flags {}
|
||||
|
||||
|
||||
|
||||
defines { "LUA_COMPAT_ALL"}
|
||||
|
||||
if os.is("Linux") then
|
||||
defines {"LUA_USE_LINUX"}
|
||||
end
|
||||
if os.is("MacOSX") then
|
||||
defines {"LUA_USE_MACOSX"}
|
||||
end
|
||||
|
||||
targetdir "../../lib"
|
||||
includedirs {
|
||||
@@ -18,4 +24,4 @@
|
||||
}
|
||||
|
||||
include "lua_compiler"
|
||||
include "lua_standalone"
|
||||
include "lua_standalone"
|
||||
|
||||
@@ -115,6 +115,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym);
|
||||
|
||||
|
||||
#if defined(LUA_USE_DLOPEN)
|
||||
|
||||
/*
|
||||
** {========================================================================
|
||||
** This is an implementation of loadlib based on the dlfcn interface.
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
#if defined(LUA_USE_LINUX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
#define LUA_USE_READLINE /* needs some extra libraries */
|
||||
//#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
//#define LUA_USE_READLINE /* needs some extra libraries */
|
||||
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
|
||||
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
|
||||
#define LUA_USE_LONGLONG /* assume support for long long */
|
||||
@@ -51,8 +51,8 @@
|
||||
|
||||
#if defined(LUA_USE_MACOSX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* does not need -ldl */
|
||||
#define LUA_USE_READLINE /* needs an extra library: -lreadline */
|
||||
//#define LUA_USE_DLOPEN /* does not need -ldl */
|
||||
//#define LUA_USE_READLINE /* needs an extra library: -lreadline */
|
||||
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
|
||||
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
|
||||
#define LUA_USE_LONGLONG /* assume support for long long */
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
#define NOCRYPT
|
||||
#define NOUNCRYPT
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@ my_shared_ptr<ModelInterface> parseURDF(const std::string &xml_string)
|
||||
{
|
||||
my_shared_ptr<Link> link;
|
||||
link.reset(new Link);
|
||||
model->m_numLinks++;
|
||||
|
||||
try {
|
||||
parseLink(*link, link_xml);
|
||||
@@ -176,6 +177,7 @@ my_shared_ptr<ModelInterface> parseURDF(const std::string &xml_string)
|
||||
{
|
||||
my_shared_ptr<Joint> joint;
|
||||
joint.reset(new Joint);
|
||||
model->m_numJoints++;
|
||||
|
||||
if (parseJoint(*joint, joint_xml))
|
||||
{
|
||||
|
||||
@@ -223,6 +223,8 @@ public:
|
||||
std::vector<my_shared_ptr<Joint> > child_joints;
|
||||
std::vector<my_shared_ptr<Link> > child_links;
|
||||
|
||||
mutable int m_link_index;
|
||||
|
||||
const Link* getParent() const
|
||||
{return parent_link_;}
|
||||
|
||||
@@ -242,6 +244,8 @@ public:
|
||||
this->child_links.clear();
|
||||
this->collision_array.clear();
|
||||
this->visual_array.clear();
|
||||
this->m_link_index=-1;
|
||||
this->parent_link_ = NULL;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <map>
|
||||
//#include <boost/function.hpp>
|
||||
#include <urdf/urdfdom_headers/urdf_model/include/urdf_model/link.h>
|
||||
|
||||
#include <stdio.h> //printf
|
||||
#include <urdf/urdfdom_headers/urdf_exception/include/urdf_exception/exception.h>
|
||||
|
||||
namespace urdf {
|
||||
@@ -82,6 +82,8 @@ public:
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_numLinks=0;
|
||||
m_numJoints = 0;
|
||||
name_.clear();
|
||||
this->links_.clear();
|
||||
this->joints_.clear();
|
||||
@@ -132,6 +134,7 @@ public:
|
||||
this->getLink(child_link_name, child_link);
|
||||
if (!child_link)
|
||||
{
|
||||
printf("Error: child link [%s] of joint [%s] not found\n", child_link_name.c_str(),joint->first.c_str() );
|
||||
assert(0);
|
||||
// throw ParseError("child link [" + child_link_name + "] of joint [" + joint->first + "] not found");
|
||||
}
|
||||
@@ -206,6 +209,8 @@ public:
|
||||
/// \brief The root is always a link (the parent of the tree describing the robot)
|
||||
my_shared_ptr<Link> root_link_;
|
||||
|
||||
int m_numLinks;//includes parent
|
||||
int m_numJoints;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user