Code Monkey home page Code Monkey logo

objectivelymvc's Introduction

Build Status Zlib License This software is PRE-ALPHA

ObjectivelyMVC

Cross-platform object oriented MVC framework for OpenGL, SDL2 and GNU C

ObjectivelyMVC is a cross-platform user interface and interaction framework for SDL2 inspired by Apple's AppKit. It is geared towards building high-quality, modern looking user interfaces within OpenGL video games that are already using SDL2. It is written in GNU C, and requires gcc or clang.

Features

Cross platform

Wait, gcc or clang? Is this a Linux-only framework? Not at all. ObjectivelyMVC supports Windows XP and later, Apple OS X, and Linux. Support for other Unix derivatives is likely there, but untested. To build ObjectivelyMVC for Windows, you can use either MinGW-w64 (cross-compile or native), or recent Visual Studio 15 Previews, which include Clang.

Object oriented Model-View-Controller implementation in C

ObjectivelyMVC is built on Objectively, an ultra-lightweight object oriented framework for GNU C. ObjectivelyMVC delivers the elegance of OO / MVC without imposing C++ on your project. If you are using C++ or Objective-C, ObjectivelyMVC is perfectly happy alongside those, too.

WindowController *windowController = $(alloc(WindowController), initWithWindow, window);

Easily embeddable in any SDL2 / OpenGL application

ObjectivelyMVC is purpose-built for video games. Unlike Gtk+, Qt, wxWidgets, FLTK, ..ObjectivelyMVC does not hijack the main loop. ObjectivelyMVC does not create a window, manage an OpenGL context, or originate events. Your game already does that, because it has to. Like your mother, ObjectivelyMVC only asks that you give it a call once in a while. That's it.

$(windowController, respondToEvent, &event);
...
$(windowController, render);

Beautiful, discoverable TrueType fonts

ObjectivelyMVC uses Fontconfig and SDL_ttf to discover and render the TrueType fonts that are available on your system. It also automatically detects High-DPI (Retina, 4K) displays, and scales fonts accordingly. The result is crisp, beautiful vector-based fonts that look native, because they are.

Array *fonts = $$(Font, allFonts);
...
release(fonts);
...
Font *verdana = $(alloc(Font), initWithAttributes, "Verdana", 24, 0); // will render at 48pt on Retina displays

Full suite of Views and Controls

ObjectivelyMVC provides a robust set of containers, views and form elements. Stack and arrange components with Box, Panel and StackView. Add Buttons, Checkboxes, Selects, Sliders, editable TextViews and more by simply instantiating them. Display tabular or grid data with TableView and CollectionView. Bind Actions to SDL_Event types on each element, or use the specialized delegate callbacks for convenience.

$((Control *) button, addActionForEventType, SDL_MOUSEBUTTONUP, my_callback, my_sender, my_data);
Select *select = $(alloc(Select), initWithFrame, NULL, ControlStyleDefault);
...
select->delegate.didSelectOption = my_callback;

Programmatic or JSON-based layout options

ObjectivelyMVC allows you to define your View hierarchy either programmatically, via JSON, or any combination of both. Programmatic layout gives you explicit control over the big picture, while JSON layout allows you to reduce boilerplate and avoid common pitfalls like memory leaks.

{
	"class": "Panel",
	"frame": [50, 50, 0, 0],
	"autoresizingMask": "ViewAutoresizingWidth",
	"contentView": {
		"subviews": [{
			"class": "Input",
			"control": {
				"class": "Checkbox",
				"identifier": "checkbox"
			},
			"label": {
				"text": "This is a checkbox:"
			}
		}]
	}
}

Examples

HelloViewController

An example application that creates a Window, enters its main loop and draws a scene before rendering a simple menu. This example uses JSON layout.

Hello

Quetoo

Quetoo is an open source FPS based on idTech2. Quetoo uses ObjectivelyMVC for its in-game user interface:

Quetoo

Installation

See INSTALL.md for installation and linking instructions.

API documentation

The API documentation can be browsed online or generated with Doxygen by running make html.

objectivelymvc's People

Contributors

ingarkct avatar jdolan avatar paril avatar tapir 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.