COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-28-2020, 09:46 AM   #1
Tugrul
Human being with feelings
 
Join Date: Nov 2016
Posts: 19
Default DrawLine problem

Hi,
very simple question but I couldn't fixe it.
Why the code below get exception ?
IColor color(255,0,0,255);
pGraphics->DrawLine(COLOR_RED,100,50,150,150,NULL,false);

The code is in the
mLayoutFunc = [&](IGraphics* pGraphics) {.
..
..
}


Thanks in advance
Tugrul is offline   Reply With Quote
Old 01-28-2020, 01:53 PM   #2
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

you can't just call IGraphics:: Draw / Fill etc methods anywhere. You need to be within an IControl:: Draw() method
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 01-29-2020, 08:28 AM   #3
Tugrul
Human being with feelings
 
Join Date: Nov 2016
Posts: 19
Default

Quote:
Originally Posted by olilarkin View Post
you can't just call IGraphics:: Draw / Fill etc methods anywhere. You need to be within an IControl:: Draw() method
Thanks for your reply
is there an example that I can follow the way ?

Tuğrul

For example I also have exception in that case :
void TwoRuleFilter::OnIdle()
{

IGraphics *g = GetUI();
if(g == NULL) return;


g->DrawLine(COLOR_WHITE,100,50,150,150,0,true);


}

Last edited by Tugrul; 01-29-2020 at 08:46 AM.
Tugrul is offline   Reply With Quote
Old 01-29-2020, 09:30 AM   #4
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

i'm not going to help any more after this... you need to try and figure it out yourself, by searching forum etc...


class MyNewControl : public IControl
{
public:
MyNewControl(const IRECT& bounds)
: IControl(bounds)
{}

void Draw(IGraphics& g) override
{
g.FillRect(COLOR_RED, mRECT);
g.DrawLine(COLOR_WHITE,100,50,150,150,0,true);
}
};


in layout func...

mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachPanelBackground(COLOR_GRAY);
pGraphics->AttachControl(new MyNewControl (pGraphics->GetBounds().GetCentredInside(100).GetVShifted(-100), kGain));
};
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 01-29-2020, 10:14 AM   #5
Tugrul
Human being with feelings
 
Join Date: Nov 2016
Posts: 19
Default

Quote:
Originally Posted by olilarkin View Post
i'm not going to help any more after this... you need to try and figure it out yourself, by searching forum etc...


class MyNewControl : public IControl
{
public:
MyNewControl(const IRECT& bounds)
: IControl(bounds)
{}

void Draw(IGraphics& g) override
{
g.FillRect(COLOR_RED, mRECT);
g.DrawLine(COLOR_WHITE,100,50,150,150,0,true);
}
};


in layout func...

mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachPanelBackground(COLOR_GRAY);
pGraphics->AttachControl(new MyNewControl (pGraphics->GetBounds().GetCentredInside(100).GetVShifted(-100), kGain));
};

ok i got it, thanks.

Tuğrul
Tugrul is offline   Reply With Quote
Old 01-29-2020, 04:46 PM   #6
Nikolaos
Human being with feelings
 
Join Date: Dec 2019
Posts: 29
Default IPlug2 OnMsgFromDelegate

Is there any risk if within OnMsgFromDelegate

I use a setdirty (true) (do I need to update a parameter) ???
Nikolaos is offline   Reply With Quote
Old 01-30-2020, 03:59 AM   #7
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

you can't just call IGraphics:: Draw / Fill etc methods anywhere. You need to be within an IControl:: Draw() method
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.