Coder Social home page Coder Social logo

glbasecode's Introduction

概要

GLFW3を使用してシンプルなUIを構築し、簡単なグラフィックを扱えるツールを作るための、ベースとなるコード。

ビルド

Windows/Macでの動作テストしている。linuxでも多分動くはず。

必要ライブラリ

windows版はvcpkgで必要パッケージをインストールした。 macはbrew、もしくは自前ビルドで用意。

  • opengl
  • glfw3
  • freetype2
  • glew(windowでは必要)
  • libpng(1.6以上)
  • boost(1.65以上)

ビルド手順

以下のコマンドを実行し、出来上がったプロジェクトファイルをVisual Studio/Xcodeで開いて使用する。

> mkdir build
> cd build
> cmake ..

もしくはninjaを使用する場合。

> cmake -G Ninja ..
> ninja

ファイル構成

基本的には"gllib.h"をインクルードすれば全機能にアクセスできる。

Hello,World

Labelを使ったHello,World。

#include <gllib.h>

int
main()
{
  const char* fontname = "res/SourceHanCodeJP-Normal.otf";

  double w    = 1024;
  double h    = 1024;
  auto   font = GLLib::initialize("Hello,World", fontname, w, h);
  if (!font)
    return 1;

  GLLib::bindLayer();

  auto x     = w / 2;
  auto y     = h / 2;
  auto fg    = Graphics::White;
  auto bg    = Graphics::DarkGray;
  auto lx    = x - font->getSizeX() * 6;
  auto label = Label::create("Hello,World", lx, y, fg, bg);

  for (;;)
  {
    if (GLLib::update([&]() { return true; }) == false)
      break;
  }

  GLLib::terminate();
  return 0;
}

クラス

かなり機能が増えたので改装予定。

Graphics

glfwの機能を下地とした、グラフィック・システム機能。

Font

FreeType2を使用したフォント描画機能。

Primitive(2D)

矩形・ライン・円などの基本的な図形描画機能。

Texture

テクスチャ読み込み・描画機能。現在はpng形式のみサポート。

Label

文字列を表示する。

Check Box

チェックボックス。

Text Button

文字列を使ったボタン。

Image Button

テクスチャを使用した画像ボタン。

Pulldown

プルダウンによる選択リスト。

Draw Box

階層化したパーツを指定領域内に描画する。シンプルなスクロールボックス。

Scroll Box

階層化したパーツを指定領域内に描画する。

Text Box

文字列入力。

Slide Bar

スライダー。数値を設定する。LabelやText Boxを連携できる。

Sheet

ただの下敷きとなる矩形を描画する。

Dialog

ダイアログを表示。OKのみと・キャンセル付きを選択できる。

Notification

通知メッセージを表示する。

参考

フォントの描画は以下を参考に。 https://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_01

linmath.hは以下から取得。 https://github.com/datenwolf/linmath.h

文字コード変換は以下のサイトから取得。 https://qiita.com/benikabocha/items/e943deb299d0f816f161

床井研究室のページ。 http://marina.sys.wakayama-u.ac.jp/~tokoi/

ライセンス

本プログラムは表示フォントに「源ノ角ゴシック Code JP」(https://github.com/adobe-fonts/source-han-code-jp) を使用しています。 Licensed under SIL Open Font License 1.1 (http://scripts.sil.org/OFL)

アイコンのPNGデータについては「MATERIAL DESIGN」サイトのものを使用しています。 (https://material.io/resources/icons/?style=baseline) このアイコンはApache2.0ライセンスで配布されています。

glbasecode's People

Contributors

zsuzuki avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.