Added include path to common. Renamed math to fpumath.
This commit is contained in:
parent
fc9dc6a3cd
commit
18f2e82362
@ -3,12 +3,12 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "processevents.h"
|
||||
|
||||
int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
{
|
||||
|
@ -3,14 +3,14 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,14 +3,14 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,14 +3,14 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,15 +3,15 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,14 +3,14 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,15 +3,15 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/countof.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,15 +3,15 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/string.h>
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/aviwriter.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "aviwriter.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
@ -3,16 +3,16 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/uint32_t.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "../common/packrect.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
#include "packrect.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -3,17 +3,17 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/countof.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "../common/imgui/imgui.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
@ -3,19 +3,19 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/countof.h>
|
||||
#include <bx/string.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include "../common/font/font_manager.h"
|
||||
#include "../common/font/text_buffer_manager.h"
|
||||
#include "font/font_manager.h"
|
||||
#include "font/text_buffer_manager.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
|
@ -3,18 +3,18 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
|
||||
#include "../common/font/font_manager.h"
|
||||
#include "../common/font/text_metrics.h"
|
||||
#include "../common/font/text_buffer_manager.h"
|
||||
#include "../common/imgui/imgui.h"
|
||||
#include "font/font_manager.h"
|
||||
#include "font/text_metrics.h"
|
||||
#include "font/text_buffer_manager.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -112,13 +112,13 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
// Create a distance field font.
|
||||
FontHandle base_distance_font = fontManager->createFontByPixelSize(font_tt, 0, 48, FONT_TYPE_DISTANCE);
|
||||
|
||||
|
||||
// Create a scaled down version of the same font (without adding anything to the atlas).
|
||||
FontHandle scaled_font = fontManager->createScaledFontToPixelSize(base_distance_font, 14);
|
||||
|
||||
TextLineMetrics metrics(fontManager, scaled_font);
|
||||
|
||||
TextLineMetrics metrics(fontManager->getFontInfo(scaled_font) );
|
||||
uint32_t lineCount = metrics.getLineCount(bigText);
|
||||
|
||||
|
||||
float visibleLineCount = 20.0f;
|
||||
|
||||
const char* textBegin = 0;
|
||||
@ -129,7 +129,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
textBufferManager->setTextColor(scrollableBuffer, 0xFFFFFFFF);
|
||||
|
||||
textBufferManager->appendText(scrollableBuffer, scaled_font, textBegin, textEnd);
|
||||
|
||||
|
||||
MouseState mouseState;
|
||||
int32_t scrollArea = 0;
|
||||
while (!processEvents(width, height, debug, reset, &mouseState) )
|
||||
@ -145,22 +145,22 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
const int guiPanelWidth = 250;
|
||||
const int guiPanelHeight = 200;
|
||||
|
||||
|
||||
imguiBeginScrollArea("Text Area", width - guiPanelWidth - 10, 10, guiPanelWidth, guiPanelHeight, &scrollArea);
|
||||
imguiSeparatorLine();
|
||||
|
||||
|
||||
static float textScroll = 0.0f;
|
||||
static float textRotation = 0.0f;
|
||||
static float textScale = 1.0f;
|
||||
static float textSize = 14.0f;
|
||||
|
||||
bool recomputeVisibleText = false;
|
||||
|
||||
bool recomputeVisibleText = false;
|
||||
recomputeVisibleText |= imguiSlider("Number of lines", &visibleLineCount, 1.0f, 177.0f , 1.0f);
|
||||
if(imguiSlider("Font size", &textSize, 6.0f, 64.0f , 1.0f))
|
||||
{
|
||||
fontManager->destroyFont(scaled_font);
|
||||
scaled_font = fontManager->createScaledFontToPixelSize(base_distance_font, (uint32_t) textSize);
|
||||
metrics = TextLineMetrics (fontManager, scaled_font);
|
||||
metrics = TextLineMetrics(fontManager->getFontInfo(scaled_font) );
|
||||
recomputeVisibleText = true;
|
||||
}
|
||||
|
||||
@ -174,9 +174,9 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
metrics.getSubText(bigText,(uint32_t)textScroll, (uint32_t)(textScroll+visibleLineCount), textBegin, textEnd);
|
||||
textBufferManager->appendText(scrollableBuffer, scaled_font, textBegin, textEnd);
|
||||
}
|
||||
|
||||
|
||||
imguiEndScrollArea();
|
||||
|
||||
|
||||
imguiEndFrame();
|
||||
|
||||
// Set view 0 default viewport.
|
||||
@ -209,10 +209,10 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
// Setup a top-left ortho matrix for screen space drawing.
|
||||
mtxOrtho(proj, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
|
||||
|
||||
|
||||
// Set view and projection matrix for view 0.
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
|
||||
//very crude approximation :(
|
||||
float textAreaWidth = 0.5f * 66.0f * fontManager->getFontInfo(scaled_font).maxAdvanceWidth;
|
||||
|
||||
@ -220,7 +220,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
float textCenterMat[16];
|
||||
float textScaleMat[16];
|
||||
float screenCenterMat[16];
|
||||
|
||||
|
||||
mtxRotateZ(textRotMat, textRotation);
|
||||
mtxTranslate(textCenterMat, -(textAreaWidth * 0.5f), (-visibleLineCount)*metrics.getLineHeight()*0.5f, 0);
|
||||
mtxScale(textScaleMat, textScale, textScale, 1.0f);
|
||||
@ -229,16 +229,16 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
//first translate to text center, then scale, then rotate
|
||||
float tmpMat[16];
|
||||
mtxMul(tmpMat, textCenterMat, textRotMat);
|
||||
|
||||
|
||||
float tmpMat2[16];
|
||||
mtxMul(tmpMat2, tmpMat, textScaleMat);
|
||||
|
||||
|
||||
float tmpMat3[16];
|
||||
mtxMul(tmpMat3, tmpMat2, screenCenterMat);
|
||||
|
||||
// Set model matrix for rendering.
|
||||
bgfx::setTransform(tmpMat3);
|
||||
|
||||
|
||||
// Draw your text.
|
||||
textBufferManager->submitTextBuffer(scrollableBuffer, 0);
|
||||
|
||||
|
@ -3,16 +3,16 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include "../common/entry.h"
|
||||
#include "../common/dbg.h"
|
||||
#include "../common/math.h"
|
||||
#include "../common/processevents.h"
|
||||
#include "../common/imgui/imgui.h"
|
||||
#include "entry.h"
|
||||
#include "dbg.h"
|
||||
#include "fpumath.h"
|
||||
#include "processevents.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Jeremie Roy. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
* Copyright 2013 Jeremie Roy. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <wchar.h> // wcslen
|
||||
|
||||
@ -22,7 +22,7 @@ void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)
|
||||
{
|
||||
GlyphInfo glyph;
|
||||
const FontInfo& font = m_fontManager->getFontInfo(_fontHandle);
|
||||
|
||||
|
||||
if (font.lineGap > m_lineGap)
|
||||
{
|
||||
m_lineGap = font.lineGap;
|
||||
@ -37,7 +37,7 @@ void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)
|
||||
|
||||
CodePoint codepoint = 0;
|
||||
uint32_t state = 0;
|
||||
|
||||
|
||||
for (; *_string; ++_string)
|
||||
{
|
||||
if (!utf8_decode(&state, (uint32_t*)&codepoint, *_string) )
|
||||
@ -52,7 +52,8 @@ void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)
|
||||
m_x = 0;
|
||||
break;
|
||||
}
|
||||
//TODO handle kerning
|
||||
|
||||
|
||||
m_x += glyph.advance_x;
|
||||
if(m_x > m_width)
|
||||
{
|
||||
@ -73,7 +74,7 @@ void TextMetrics::appendText(FontHandle _fontHandle, const wchar_t* _string)
|
||||
{
|
||||
GlyphInfo glyph;
|
||||
const FontInfo& font = m_fontManager->getFontInfo(_fontHandle);
|
||||
|
||||
|
||||
if (font.lineGap > m_lineGap)
|
||||
{
|
||||
m_lineGap = font.lineGap;
|
||||
@ -113,10 +114,9 @@ void TextMetrics::appendText(FontHandle _fontHandle, const wchar_t* _string)
|
||||
}
|
||||
}
|
||||
|
||||
TextLineMetrics::TextLineMetrics(FontManager* _fontManager, FontHandle _fontHandle)
|
||||
TextLineMetrics::TextLineMetrics(const FontInfo& _fontInfo)
|
||||
{
|
||||
const FontInfo& font = _fontManager->getFontInfo(_fontHandle);
|
||||
m_lineHeight = font.ascender - font.descender + font.lineGap;
|
||||
m_lineHeight = _fontInfo.ascender - _fontInfo.descender + _fontInfo.lineGap;
|
||||
}
|
||||
|
||||
uint32_t TextLineMetrics::getLineCount(const char* _string) const
|
||||
@ -177,8 +177,8 @@ void TextLineMetrics::getSubText(const char* _string, uint32_t _firstLine, uint3
|
||||
|
||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||
_begin = _string;
|
||||
|
||||
while((*_string) && (currentLine < _lastLine) )
|
||||
|
||||
while ( (*_string) && (currentLine < _lastLine) )
|
||||
{
|
||||
for (; *_string; ++_string)
|
||||
{
|
||||
@ -281,7 +281,7 @@ void TextLineMetrics::getVisibleText(const wchar_t* _string, float _top, float _
|
||||
{
|
||||
// y is bottom of a text line
|
||||
float y = m_lineHeight;
|
||||
|
||||
|
||||
const wchar_t* _textEnd = _string + wcslen(_string);
|
||||
|
||||
while (y < _top)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Jeremie Roy. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
* Copyright 2013 Jeremie Roy. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifndef __TEXT_METRICS_H__
|
||||
#define __TEXT_METRICS_H__
|
||||
@ -12,13 +12,13 @@ class TextMetrics
|
||||
{
|
||||
public:
|
||||
TextMetrics(FontManager* _fontManager);
|
||||
|
||||
|
||||
/// Append an ASCII/utf-8 string to the metrics helper.
|
||||
void appendText(FontHandle _fontHandle, const char* _string);
|
||||
|
||||
/// Append a wide char string to the metrics helper.
|
||||
void appendText(FontHandle _fontHandle, const wchar_t* _string);
|
||||
|
||||
|
||||
/// Return the width of the measured text.
|
||||
float getWidth() const { return m_width; }
|
||||
|
||||
@ -38,8 +38,8 @@ private:
|
||||
class TextLineMetrics
|
||||
{
|
||||
public:
|
||||
TextLineMetrics(FontManager* _fontManager, FontHandle _fontHandle);
|
||||
|
||||
TextLineMetrics(const FontInfo& _fontInfo);
|
||||
|
||||
/// Return the height of a line of text using the given font.
|
||||
float getLineHeight() const { return m_lineHeight; }
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
|
||||
/// Return the number of text line in the given text.
|
||||
uint32_t getLineCount(const wchar_t* _string) const;
|
||||
|
||||
|
||||
/// Return the first and last character visible in the [_firstLine, _lastLine] range.
|
||||
void getSubText(const char* _string, uint32_t _firstLine, uint32_t _lastLine, const char*& _begin, const char*& _end);
|
||||
|
||||
@ -62,7 +62,6 @@ public:
|
||||
void getVisibleText(const wchar_t* _string, float _top, float _bottom, const wchar_t*& _begin, const wchar_t*& _end);
|
||||
|
||||
private:
|
||||
FontManager* m_fontManager;
|
||||
float m_lineHeight;
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <bgfx.h>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "../math.h"
|
||||
#include "../fpumath.h"
|
||||
|
||||
#include "vs_imgui_color.bin.h"
|
||||
#include "fs_imgui_color.bin.h"
|
||||
|
@ -47,6 +47,7 @@ function exampleProject(_name, _uuid)
|
||||
BX_DIR .. "include",
|
||||
BGFX_DIR .. "include",
|
||||
BGFX_DIR .. "3rdparty",
|
||||
BGFX_DIR .. "examples/common",
|
||||
}
|
||||
|
||||
files {
|
||||
|
Loading…
Reference in New Issue
Block a user