<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ofelia: setColor --&gt; only one pixel color shown?]]></title><description><![CDATA[<p>Sorry for all the dumb Ofelia questions.</p>
<pre><code>ofelia d;
M.img = ofImage();
M.img:allocate(10, 10, OF_IMAGE_COLOR);
for i = 0, 99, 1 do;
M.img:setColor(i*3, ofColor(i));
end;
M.img:update();
print(&quot;color at 99&quot;, M.img:getColor(99*3):getHex() &amp; 255);
function M.bang();
M.img:bind();
ofDrawRectangle(-50, -50, 100, 100);
M.img:unbind();
end;
</code></pre>
<p>It prints &quot;color at 99 99&quot;... but the entire rectangle displays only the color at index 0. (If I change it to <code>ofColor(i+100)</code> then it displays a rectangle with gray=100.) There is NO texture mapping <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/hushed.png" title=":-O" alt=":-O" /></p>
<p>How does the ofImage contain valid pixel data but 'bind' then doesn't actually bind?</p>
<p>Edit: Attaching a patch that demos the problem without any abstractions. <a href="/uploads/files/1609122965969-imgtest.zip">imgtest.zip</a></p>
<p>Edit: <code>M.img:getTexture():bind()</code> doesn't help.</p>
<p>hjh</p>
<p><img src="/uploads/files/1609123506030-pd-img.png" alt="pd-img.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/13210/ofelia-setcolor-only-one-pixel-color-shown</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 15:18:16 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/13210.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Dec 2020 02:26:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ofelia: setColor --&gt; only one pixel color shown? on Mon, 28 Dec 2020 03:01:47 GMT]]></title><description><![CDATA[<p>Sorry for all the dumb Ofelia questions.</p>
<pre><code>ofelia d;
M.img = ofImage();
M.img:allocate(10, 10, OF_IMAGE_COLOR);
for i = 0, 99, 1 do;
M.img:setColor(i*3, ofColor(i));
end;
M.img:update();
print(&quot;color at 99&quot;, M.img:getColor(99*3):getHex() &amp; 255);
function M.bang();
M.img:bind();
ofDrawRectangle(-50, -50, 100, 100);
M.img:unbind();
end;
</code></pre>
<p>It prints &quot;color at 99 99&quot;... but the entire rectangle displays only the color at index 0. (If I change it to <code>ofColor(i+100)</code> then it displays a rectangle with gray=100.) There is NO texture mapping <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/hushed.png" title=":-O" alt=":-O" /></p>
<p>How does the ofImage contain valid pixel data but 'bind' then doesn't actually bind?</p>
<p>Edit: Attaching a patch that demos the problem without any abstractions. <a href="/uploads/files/1609122965969-imgtest.zip">imgtest.zip</a></p>
<p>Edit: <code>M.img:getTexture():bind()</code> doesn't help.</p>
<p>hjh</p>
<p><img src="/uploads/files/1609123506030-pd-img.png" alt="pd-img.png" class="img-responsive img-markdown" /></p>
]]></description><link>http://forum.pdpatchrepo.info/topic/13210/ofelia-setcolor-only-one-pixel-color-shown</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/13210/ofelia-setcolor-only-one-pixel-color-shown</guid><dc:creator><![CDATA[ddw_music]]></dc:creator><pubDate>Mon, 28 Dec 2020 03:01:47 GMT</pubDate></item><item><title><![CDATA[Reply to Ofelia: setColor --&gt; only one pixel color shown? on Mon, 28 Dec 2020 04:13:17 GMT]]></title><description><![CDATA[<p>Ah, got it. Have to use an ofPlanePrimitive() instead -- ofDrawRectangle() doesn't respect texture maps.</p>
<p>hjh</p>
<pre><code>if type(window) ~= &quot;userdata&quot; then;
window = ofWindow();
end;
;
M.img = ofImage();
;
function M.new();
ofWindow.addListener(&quot;setup&quot;, this);
ofWindow.addListener(&quot;draw&quot;, this);
ofWindow.addListener(&quot;exit&quot;, this);
window:setPosition(0, 0);
window:setSize(100, 100);
if ofWindow.exists then;
clock:delay(0);
else;
window:create();
end;
end;
;
function M.free();
window:destroy();
ofWindow.removeListener(&quot;setup&quot;, this);
ofWindow.removeListener(&quot;draw&quot;, this);
ofWindow.removeListener(&quot;exit&quot;, this);
end;
;
function M.setup();
M.img:allocate(10, 10, OF_IMAGE_COLOR);
for i = 0, 99, 1 do
M.img:setColor(i * 3, ofColor(i*2));
end;
M.img:update();
M.pln = ofPlanePrimitive();
M.pln:setRows(2);
M.pln:setColumns(2);
M.pln:setWidth(100);
M.pln:setHeight(100);
M.pln:setPosition(ofVec3f(50.0, 50.0, 0.0):vec3());
end;
;
function M.draw();
M.img:bind();
M.pln:draw();
M.img:unbind();
end;
;
function M.exit();
M.img:clear();
end
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/13210/ofelia-setcolor-only-one-pixel-color-shown/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/13210/ofelia-setcolor-only-one-pixel-color-shown/2</guid><dc:creator><![CDATA[ddw_music]]></dc:creator><pubDate>Mon, 28 Dec 2020 04:13:17 GMT</pubDate></item></channel></rss>