Git Product home page Git Product logo

anttweakbar-sdl2's Introduction

Gutted SDL 2, CMake port of AntTweakBar

This is a fork of AntTweakBar 1.16 that has been butchered for my own use.

Changes from upstream:

  • Removed all rendering backends except OpenGL core
  • Removed all event backends except SDL 1.3
  • Upgraded SDL 1.3 backend to SDL 2
  • Replaced remaining platform-specific code with SDL 2 calls
  • Added minimal CMake build file, static lib only
  • Removed OpenGL function loader code, added hooks to inject own loader

AntTweakBar is very hacky code (-fno-strict-aliasing should hint at that), so I suggest you don't use this. But if you are, like me right now, in a hurry for a quick&easy UI, here is how:

First, this project is not meant to compile on its own. Instead, include it as a subdirectory in another CMake project. This is mostly because it doesn't ship the (non-standard) FindSDL2.cmake module, but also because you need to define some variables.

# Set this to whatever your OpenGL loader include file is.
# On Linux you could probably get away with GL/gl.h
# This must be defined before everything else.
# You could also pass this on the CMake command-line as -DATB_OPENGL_HEADER=...
set(ATB_OPENGL_HEADER GLXW/glxw.h)

# Now include the subdirectory, easy enough!
# This will provide you with an AntTweakBar target to link against!
add_subdirectory(libs/AntTweakBar-sdl2 EXCLUDE_FROM_ALL)

# Finally, hook AntTweakBar up to your program:
include_directories(SYSTEM libs/AntTweakBar-sdl2/include)
add_definitions(-DTW_STATIC)
target_link_libraries(yourexe AntTweakBar)

Original README

AntTweakBar is a small and easy-to-use C/C++ library that allows programmers to quickly add a light and intuitive GUI into OpenGL and DirectX based graphic programs to interactively tweak parameters.

This package includes the development version of the AntTweakBar library for Windows, GNU/Linux and OSX, and some program examples (sources + binaries).

For installation and documentation please refer to: http://anttweakbar.sourceforge.net/doc

anttweakbar-sdl2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

anttweakbar-sdl2's Issues

TwBar variable editing doesn't fully work.

function TwEventSDL never calls:

  • TwKeyPressed(TW_KEY_RETURN, event->key.keysym.mod), this ends the editing of a variable field.
  • TwKeyPressed(TW_KEY_BACKSPACE, event->key.keysym.mod), this removes character from focused variable field.

The problem lies within TwEventSDL2.cpp starting from line 55

Current code:

    case SDL_KEYDOWN: 
          if( event->key.keysym.sym & SDLK_SCANCODE_MASK )
          {
              int key = 0;
              switch( event->key.keysym.sym )
              {
              case SDLK_UP:
                  key = TW_KEY_UP;
                  break;
              //and so on

Suggested fix:

    case SDL_KEYDOWN:
        if( event->key.keysym.sym ) //I left this line in for the sake of simplicity
        {
            int key = 0;
            switch( event->key.keysym.sym )
            {
            case SDLK_RETURN:
                key = TW_KEY_RETURN;
                break;
            case SDLK_BACKSPACE:
                key = TW_KEY_BACKSPACE;
                break;
            case SDLK_UP:
                key = TW_KEY_UP;
                break;
            //and so on

In the case that i am mistaken i give my apologies for wasting your time and please remove this issue.

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.