mirror of https://github.com/adamdruppe/arsd.git
more efficient opengltexture option
This commit is contained in:
parent
0f77d8f380
commit
3a433690e2
21
cgi.d
21
cgi.d
|
@ -1,6 +1,5 @@
|
||||||
// FIXME: if an exception is thrown, we shouldn't necessarily cache...
|
// FIXME: if an exception is thrown, we shouldn't necessarily cache...
|
||||||
// FIXME: there's some annoying duplication of code in the various versioned mains
|
// FIXME: there's some annoying duplication of code in the various versioned mains
|
||||||
// FIXME: new ConnectionThread is done a lot, no pooling implemented
|
|
||||||
|
|
||||||
// Note: spawn-fcgi can help with fastcgi on nginx
|
// Note: spawn-fcgi can help with fastcgi on nginx
|
||||||
|
|
||||||
|
@ -9,6 +8,26 @@
|
||||||
|
|
||||||
// future direction: websocket as a separate process that you can sendfile to for an async passoff of those long-lived connections
|
// future direction: websocket as a separate process that you can sendfile to for an async passoff of those long-lived connections
|
||||||
|
|
||||||
|
/*
|
||||||
|
Session manager process: it spawns a new process, passing a
|
||||||
|
command line argument, to just be a little key/value store
|
||||||
|
of some serializable struct. On Windows, it CreateProcess.
|
||||||
|
On Linux, it can just fork or maybe fork/exec. The session
|
||||||
|
key is in a cookie.
|
||||||
|
|
||||||
|
Server-side event process: spawns an async manager. You can
|
||||||
|
push stuff out to channel ids and the clients listen to it.
|
||||||
|
|
||||||
|
websocket process: spawns an async handler. They can talk to
|
||||||
|
each other or get info from a cgi request.
|
||||||
|
|
||||||
|
Tempting to put web.d 2.0 in here. It would:
|
||||||
|
* map urls and form generation to functions
|
||||||
|
* have data presentation magic
|
||||||
|
* do the skeleton stuff like 1.0
|
||||||
|
* auto-cache generated stuff in files (at least if pure?)
|
||||||
|
*/
|
||||||
|
|
||||||
/++
|
/++
|
||||||
Provides a uniform server-side API for CGI, FastCGI, SCGI, and HTTP web applications.
|
Provides a uniform server-side API for CGI, FastCGI, SCGI, and HTTP web applications.
|
||||||
|
|
||||||
|
|
4
dom.d
4
dom.d
|
@ -4819,7 +4819,7 @@ class Table : Element {
|
||||||
tagName = "table";
|
tagName = "table";
|
||||||
}
|
}
|
||||||
|
|
||||||
///.
|
/// Creates an element with the given type and content.
|
||||||
Element th(T)(T t) {
|
Element th(T)(T t) {
|
||||||
Element e;
|
Element e;
|
||||||
if(parentDocument !is null)
|
if(parentDocument !is null)
|
||||||
|
@ -4833,7 +4833,7 @@ class Table : Element {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
///.
|
/// ditto
|
||||||
Element td(T)(T t) {
|
Element td(T)(T t) {
|
||||||
Element e;
|
Element e;
|
||||||
if(parentDocument !is null)
|
if(parentDocument !is null)
|
||||||
|
|
|
@ -226,6 +226,23 @@ final class OpenGlTexture {
|
||||||
|
|
||||||
/// Make a texture from an image.
|
/// Make a texture from an image.
|
||||||
this(TrueColorImage from) {
|
this(TrueColorImage from) {
|
||||||
|
bindFrom(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generates from text. Requires ttf.d
|
||||||
|
/// pass a pointer to the TtfFont as the first arg (it is template cuz of lazy importing, not because it actually works with different types)
|
||||||
|
this(T, FONT)(FONT* font, int size, in T[] text) if(is(T == char)) {
|
||||||
|
bindFrom(font, size, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates an empty texture class for you to use with [bindFrom] later
|
||||||
|
/// Using it when not bound is undefined behavior.
|
||||||
|
this() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// After you delete it with dispose, you may rebind it to something else with this.
|
||||||
|
void bindFrom(TrueColorImage from) {
|
||||||
assert(from.width > 0 && from.height > 0);
|
assert(from.width > 0 && from.height > 0);
|
||||||
|
|
||||||
import core.stdc.stdlib;
|
import core.stdc.stdlib;
|
||||||
|
@ -295,9 +312,8 @@ final class OpenGlTexture {
|
||||||
free(cast(void*) data);
|
free(cast(void*) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates from text. Requires ttf.d
|
/// ditto
|
||||||
/// pass a pointer to the TtfFont as the first arg (it is template cuz of lazy importing, not because it actually works with different types)
|
void bindFrom(T, FONT)(FONT* font, int size, in T[] text) if(is(T == char)) {
|
||||||
this(T, FONT)(FONT* font, int size, in T[] text) if(is(T == char)) {
|
|
||||||
assert(font !is null);
|
assert(font !is null);
|
||||||
int width, height;
|
int width, height;
|
||||||
auto data = font.renderString(text, size, width, height);
|
auto data = font.renderString(text, size, width, height);
|
||||||
|
@ -313,14 +329,26 @@ final class OpenGlTexture {
|
||||||
}
|
}
|
||||||
assert(data.length == 0);
|
assert(data.length == 0);
|
||||||
|
|
||||||
this(image);
|
bindFrom(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deletes the texture. Using it after calling this is undefined behavior
|
||||||
|
void dispose() {
|
||||||
|
glDeleteTextures(1, &_tex);
|
||||||
|
_tex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
glDeleteTextures(1, &_tex);
|
if(_tex > 0)
|
||||||
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void clearOpenGlScreen(SimpleWindow window) {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Some math helpers
|
// Some math helpers
|
||||||
|
|
||||||
|
|
26
web.d
26
web.d
|
@ -776,7 +776,7 @@ struct ReflectionInfo {
|
||||||
|
|
||||||
// these might go away.
|
// these might go away.
|
||||||
|
|
||||||
string defaultOutputFormat = "html";
|
string defaultOutputFormat = "default";
|
||||||
int versionOfOutputFormat = 2; // change this in your constructor if you still need the (deprecated) old behavior
|
int versionOfOutputFormat = 2; // change this in your constructor if you still need the (deprecated) old behavior
|
||||||
// bool apiMode = false; // no longer used - if format is json, apiMode behavior is assumed. if format is html, it is not.
|
// bool apiMode = false; // no longer used - if format is json, apiMode behavior is assumed. if format is html, it is not.
|
||||||
// FIXME: what if you want the data formatted server side, but still in a json envelope?
|
// FIXME: what if you want the data formatted server side, but still in a json envelope?
|
||||||
|
@ -1895,6 +1895,7 @@ Form createAutomaticForm(Document document, string action, in Parameter[] parame
|
||||||
|
|
||||||
auto fmt = Element.make("select");
|
auto fmt = Element.make("select");
|
||||||
fmt.name = "format";
|
fmt.name = "format";
|
||||||
|
fmt.addChild("option", "Automatic").setAttribute("value", "default");
|
||||||
fmt.addChild("option", "html").setAttribute("value", "html");
|
fmt.addChild("option", "html").setAttribute("value", "html");
|
||||||
fmt.addChild("option", "table").setAttribute("value", "table");
|
fmt.addChild("option", "table").setAttribute("value", "table");
|
||||||
fmt.addChild("option", "json").setAttribute("value", "json");
|
fmt.addChild("option", "json").setAttribute("value", "json");
|
||||||
|
@ -2755,6 +2756,15 @@ WrapperFunction generateWrapper(alias ObjectType, string funName, alias f, R)(Re
|
||||||
|
|
||||||
// FIXME: it's awkward to call manually due to the JSONValue ref thing. Returning a string would be mega nice.
|
// FIXME: it's awkward to call manually due to the JSONValue ref thing. Returning a string would be mega nice.
|
||||||
string formatAs(T, R)(T ret, string format, R api = null, JSONValue* returnValue = null, string formatJsonToStringAs = null) if(is(R : ApiProvider)) {
|
string formatAs(T, R)(T ret, string format, R api = null, JSONValue* returnValue = null, string formatJsonToStringAs = null) if(is(R : ApiProvider)) {
|
||||||
|
|
||||||
|
if(format == "default") {
|
||||||
|
static if(is(typeof(ret) : K[N][V], size_t N, K, V)) {
|
||||||
|
format = "table";
|
||||||
|
} else {
|
||||||
|
format = "html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string retstr;
|
string retstr;
|
||||||
if(api !is null) {
|
if(api !is null) {
|
||||||
static if(__traits(compiles, api._customFormat(ret, format))) {
|
static if(__traits(compiles, api._customFormat(ret, format))) {
|
||||||
|
@ -2817,8 +2827,18 @@ string formatAs(T, R)(T ret, string format, R api = null, JSONValue* returnValue
|
||||||
goto badType;
|
goto badType;
|
||||||
gotATable(table);
|
gotATable(table);
|
||||||
break;
|
break;
|
||||||
}
|
} else static if(is(typeof(ret) : K[N][V], size_t N, K, V)) {
|
||||||
else
|
auto table = cast(Table) Element.make("table");
|
||||||
|
table.addClass("data-display");
|
||||||
|
foreach(k, v; ret) {
|
||||||
|
auto row = table.addChild("tr");
|
||||||
|
foreach(cell; v)
|
||||||
|
table.addChild("td", to!string(cell));
|
||||||
|
}
|
||||||
|
gotATable(table);
|
||||||
|
break;
|
||||||
|
|
||||||
|
} else
|
||||||
goto badType;
|
goto badType;
|
||||||
default:
|
default:
|
||||||
badType:
|
badType:
|
||||||
|
|
Loading…
Reference in New Issue