texplay 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +9 -0
- data/README.markdown +8 -2
- data/Rakefile +3 -4
- data/examples/example_lsystem.rb +4 -2
- data/examples/example_scale.rb +1 -26
- data/ext/texplay/bindings.c +48 -0
- data/ext/texplay/bindings.h +2 -1
- data/ext/texplay/extconf.rb +13 -4
- data/ext/texplay/gen_eval.c +5 -3
- data/ext/texplay/texplay.c +1 -0
- data/ext/texplay/utils.c +0 -1
- data/lib/texplay.rb +1 -1
- metadata +5 -7
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
16/10/09
|
|
2
|
+
version 0.2.7
|
|
3
|
+
* removed memory leak from Gosu::Image#to_blob, now writing directly to RSTRING_PTR
|
|
4
|
+
|
|
5
|
+
12/10/09
|
|
6
|
+
version 0.2.666
|
|
7
|
+
* added Gosu::Image#to_blob
|
|
8
|
+
* to_blob functionality enables Gosu::Images to work with DevIL library
|
|
9
|
+
|
|
1
10
|
6/10/09
|
|
2
11
|
version 0.2.5
|
|
3
12
|
* fixed quad_draw flicker bug
|
data/README.markdown
CHANGED
|
@@ -5,14 +5,20 @@
|
|
|
5
5
|
INSTRUCTIONS
|
|
6
6
|
============
|
|
7
7
|
|
|
8
|
-
**TexPlay version 0.2.
|
|
8
|
+
**TexPlay version 0.2.7**
|
|
9
9
|
|
|
10
10
|
Gem installation:
|
|
11
11
|
|
|
12
12
|
+ sudo gem install texplay
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
How to build the gems? (maintainers only)
|
|
15
15
|
|
|
16
|
+
+ Install rake-compiler (http://github.com/luislavena/rake-compiler)
|
|
17
|
+
+ Install 1.9.1 and 1.8.6 mingw ruby versions (instructions above)
|
|
18
|
+
+ Type: rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1
|
|
19
|
+
+ Upload new gems to rubyforge and gemcutter.
|
|
20
|
+
|
|
21
|
+
How to build from source?
|
|
16
22
|
+ rake compile
|
|
17
23
|
|
|
18
24
|
OR
|
data/Rakefile
CHANGED
|
@@ -2,7 +2,7 @@ require 'rake/clean'
|
|
|
2
2
|
require 'rake/gempackagetask'
|
|
3
3
|
require 'rake/extensiontask'
|
|
4
4
|
|
|
5
|
-
TEXPLAY_VERSION = "0.2.
|
|
5
|
+
TEXPLAY_VERSION = "0.2.7"
|
|
6
6
|
|
|
7
7
|
$dlext = Config::CONFIG['DLEXT']
|
|
8
8
|
|
|
@@ -20,15 +20,14 @@ specification = Gem::Specification.new do |s|
|
|
|
20
20
|
s.require_path = 'lib'
|
|
21
21
|
s.add_dependency("gosu",">=0.7.14")
|
|
22
22
|
s.platform = Gem::Platform::RUBY
|
|
23
|
-
s.extensions = ["ext/texplay/extconf.rb"]
|
|
24
23
|
s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
|
|
25
24
|
s.has_rdoc = false
|
|
25
|
+
|
|
26
|
+
s.extensions = ["ext/texplay/extconf.rb"]
|
|
26
27
|
s.files = ["Rakefile", "README.markdown", "CHANGELOG",
|
|
27
28
|
"lib/texplay.rb", "lib/texplay-contrib.rb"] +
|
|
28
29
|
FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "examples/*.rb",
|
|
29
30
|
"examples/media/*"].to_a
|
|
30
|
-
|
|
31
|
-
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
Rake::GemPackageTask.new(specification) do |package|
|
data/examples/example_lsystem.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'common'
|
|
2
|
-
require '
|
|
2
|
+
require 'devil/gosu'
|
|
3
3
|
|
|
4
4
|
Dragon = TexPlay::LSystem.new do
|
|
5
5
|
rule "F" => "F"
|
|
@@ -47,7 +47,9 @@ class W < Gosu::Window
|
|
|
47
47
|
def initialize
|
|
48
48
|
super(1024, 768, false, 20)
|
|
49
49
|
@img = TexPlay::create_blank_image(self, 500, 500)
|
|
50
|
-
@img.
|
|
50
|
+
@img.set_options :color => :rand
|
|
51
|
+
@img.lsystem(400, 350, Dragon, :order => 13, :line_length => 4)
|
|
52
|
+
@img.save("dragon.jpg")
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
def draw
|
data/examples/example_scale.rb
CHANGED
|
@@ -8,34 +8,9 @@ class W < Gosu::Window
|
|
|
8
8
|
def initialize
|
|
9
9
|
super(1024, 768, false, 20)
|
|
10
10
|
@img = Gosu::Image.new(self, "#{Common::MEDIA}/logo.png")
|
|
11
|
-
#@img.rect 0,0, @img.width - 1, @img.height - 1
|
|
12
11
|
@img2 = TexPlay::create_blank_image(self, 500, 500)
|
|
13
|
-
#@img2.rect 0,0, 1000, 1000, :fill => true
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
options = options.first ? options.first : {}
|
|
17
|
-
|
|
18
|
-
options = {
|
|
19
|
-
:color_control => proc do |c1, c2, x, y|
|
|
20
|
-
factor = options[:factor] || 1
|
|
21
|
-
factor_x = options[:factor_x] || factor
|
|
22
|
-
factor_y = options[:factor_y] || factor
|
|
23
|
-
|
|
24
|
-
x = factor_x * (x - cx) + cx
|
|
25
|
-
y = factor_y * (y - cy) + cy
|
|
26
|
-
|
|
27
|
-
rect x, y, x + factor_x, y + factor_y, :color => c2, :fill => true
|
|
28
|
-
:none
|
|
29
|
-
end
|
|
30
|
-
}.merge!(options)
|
|
31
|
-
|
|
32
|
-
splice img, cx, cy, options
|
|
33
|
-
|
|
34
|
-
self
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@img2.splice_and_scale @img, 0, 50, :factor => 0.3, :factor_y => 4
|
|
13
|
+
@img2.splice_and_scale @img, 0, 50, :factor => 2
|
|
39
14
|
@img2.splice @img, 0, 200
|
|
40
15
|
end
|
|
41
16
|
|
data/ext/texplay/bindings.c
CHANGED
|
@@ -333,6 +333,54 @@ m_get_options(VALUE self)
|
|
|
333
333
|
return get_image_local(self, USER_DEFAULTS);
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
static void
|
|
337
|
+
get_image_chunk_with_size(char * data, texture_info * tex, char * blob)
|
|
338
|
+
{
|
|
339
|
+
int x, y;
|
|
340
|
+
|
|
341
|
+
for(y = 0; y < tex->height; y++)
|
|
342
|
+
for(x = 0; x < tex->width; x++) {
|
|
343
|
+
int buf_index = 4 * (x + y * tex->width);
|
|
344
|
+
|
|
345
|
+
int offset = calc_pixel_offset(tex, x, y);
|
|
346
|
+
|
|
347
|
+
memcpy(blob + buf_index, data + offset, 4);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
VALUE
|
|
352
|
+
m_to_blob(VALUE self)
|
|
353
|
+
{
|
|
354
|
+
texture_info tex;
|
|
355
|
+
int sidelength;
|
|
356
|
+
VALUE blob;
|
|
357
|
+
void * new_array = NULL;
|
|
358
|
+
|
|
359
|
+
ADJUST_SELF(self);
|
|
360
|
+
|
|
361
|
+
get_texture_info(self, &tex);
|
|
362
|
+
|
|
363
|
+
glEnable(GL_TEXTURE_2D);
|
|
364
|
+
glBindTexture(GL_TEXTURE_2D, tex.tname);
|
|
365
|
+
|
|
366
|
+
/* get length of a side, since square texture */
|
|
367
|
+
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &sidelength);
|
|
368
|
+
|
|
369
|
+
/* initialize texture data array, mult. by 4 because {rgba} */
|
|
370
|
+
new_array = malloc(sidelength * sidelength * 4);
|
|
371
|
+
|
|
372
|
+
/* get texture data from video memory */
|
|
373
|
+
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE,(void*)(new_array));
|
|
374
|
+
|
|
375
|
+
blob = rb_str_new(NULL, 4 * tex.width * tex.height);
|
|
376
|
+
|
|
377
|
+
get_image_chunk_with_size(new_array, &tex, RSTRING_PTR(blob));
|
|
378
|
+
|
|
379
|
+
glDisable(GL_TEXTURE_2D);
|
|
380
|
+
|
|
381
|
+
return blob;
|
|
382
|
+
}
|
|
383
|
+
|
|
336
384
|
/* return the pixel colour for the given x, y */
|
|
337
385
|
VALUE
|
|
338
386
|
m_getpixel(int argc, VALUE * argv, VALUE self)
|
data/ext/texplay/bindings.h
CHANGED
|
@@ -30,7 +30,6 @@ VALUE m_rshift(int argc, VALUE * argv, VALUE self);
|
|
|
30
30
|
|
|
31
31
|
VALUE m_each(int argc, VALUE * argv, VALUE self);
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
VALUE m_quad_cached(VALUE self);
|
|
35
34
|
VALUE m_cache_refresh(VALUE self);
|
|
36
35
|
|
|
@@ -42,4 +41,6 @@ VALUE m_force_sync(VALUE self, VALUE ary);
|
|
|
42
41
|
VALUE m_dup_image(VALUE self);
|
|
43
42
|
VALUE m_clone_image(VALUE self);
|
|
44
43
|
|
|
44
|
+
VALUE m_to_blob(VALUE self);
|
|
45
|
+
|
|
45
46
|
#endif
|
data/ext/texplay/extconf.rb
CHANGED
|
@@ -4,18 +4,27 @@ require 'mkmf'
|
|
|
4
4
|
# linux
|
|
5
5
|
if RUBY_PLATFORM =~ /linux/ then
|
|
6
6
|
exit unless have_library("glut")
|
|
7
|
+
exit unless have_library("GL")
|
|
7
8
|
|
|
8
9
|
# macosx
|
|
9
10
|
elsif RUBY_PLATFORM =~ /darwin/
|
|
10
11
|
$LDFLAGS += " -framework GLUT"
|
|
11
|
-
$
|
|
12
|
+
$CFLAGS += " -I/System/Library/Frameworks/GLUT.framework/Headers"
|
|
12
13
|
|
|
13
14
|
# windows
|
|
14
|
-
else
|
|
15
|
-
|
|
15
|
+
else
|
|
16
|
+
|
|
17
|
+
exit unless have_library("freeglut_static")
|
|
18
|
+
exit unless have_library("opengl32")
|
|
19
|
+
|
|
20
|
+
if RUBY_PLATFORM =~ /mingw/
|
|
21
|
+
$CFLAGS += " -I/home/john/.rake-compiler/ruby/ruby-1.9.1-p243/include"
|
|
22
|
+
$CFLAGS += " -I/home/john/.rake-compiler/ruby/ruby-1.8.6-p287/include"
|
|
23
|
+
$CFLAGS += " -D FREEGLUT_STATIC"
|
|
24
|
+
end
|
|
16
25
|
end
|
|
17
26
|
|
|
18
27
|
# 1.9 compatibility
|
|
19
|
-
$
|
|
28
|
+
$CFLAGS += " -DRUBY_19" if RUBY_VERSION =~ /1.9/
|
|
20
29
|
|
|
21
30
|
create_makefile('texplay')
|
data/ext/texplay/gen_eval.c
CHANGED
|
@@ -37,6 +37,7 @@ set_hidden_self(VALUE duped_context, VALUE hidden_self)
|
|
|
37
37
|
VALUE
|
|
38
38
|
rb_capture(VALUE self) {
|
|
39
39
|
VALUE hidden_self;
|
|
40
|
+
VALUE result;
|
|
40
41
|
|
|
41
42
|
rb_need_block();
|
|
42
43
|
|
|
@@ -46,11 +47,12 @@ rb_capture(VALUE self) {
|
|
|
46
47
|
(2) otherwise simply yield to the block
|
|
47
48
|
*/
|
|
48
49
|
if(!NIL_P(hidden_self))
|
|
49
|
-
rb_obj_instance_eval(0, 0, hidden_self);
|
|
50
|
+
result = rb_obj_instance_eval(0, 0, hidden_self);
|
|
50
51
|
else
|
|
51
|
-
rb_yield(Qnil);
|
|
52
|
+
result = rb_yield(Qnil);
|
|
52
53
|
|
|
53
|
-
return
|
|
54
|
+
/* we want the return value of capture to be the return value of the block */
|
|
55
|
+
return result;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
/** ruby 1.9 funcs **/
|
data/ext/texplay/texplay.c
CHANGED
|
@@ -60,6 +60,7 @@ Init_texplay() {
|
|
|
60
60
|
|
|
61
61
|
rb_define_method(jm_Module, "dup", m_dup_image, 0);
|
|
62
62
|
rb_define_method(jm_Module, "clone", m_clone_image, 0);
|
|
63
|
+
rb_define_method(jm_Module, "to_blob", m_to_blob, 0);
|
|
63
64
|
rb_define_method(jm_Module, "force_sync", m_force_sync, 1);
|
|
64
65
|
rb_define_method(jm_Module, "set_options", m_user_set_options, 1);
|
|
65
66
|
rb_define_method(jm_Module, "get_options", m_get_options, 0);
|
data/ext/texplay/utils.c
CHANGED
data/lib/texplay.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: texplay
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Mair (banisterfiend)
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-10-
|
|
12
|
+
date: 2009-10-16 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -82,10 +82,8 @@ files:
|
|
|
82
82
|
- examples/media/gosu.png
|
|
83
83
|
- examples/media/logo.png
|
|
84
84
|
- examples/media/empty2.png
|
|
85
|
-
has_rdoc:
|
|
85
|
+
has_rdoc: false
|
|
86
86
|
homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
|
|
87
|
-
licenses: []
|
|
88
|
-
|
|
89
87
|
post_install_message:
|
|
90
88
|
rdoc_options: []
|
|
91
89
|
|
|
@@ -106,9 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
104
|
requirements: []
|
|
107
105
|
|
|
108
106
|
rubyforge_project:
|
|
109
|
-
rubygems_version: 1.
|
|
107
|
+
rubygems_version: 1.2.0
|
|
110
108
|
signing_key:
|
|
111
|
-
specification_version:
|
|
109
|
+
specification_version: 2
|
|
112
110
|
summary: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
|
|
113
111
|
test_files: []
|
|
114
112
|
|