-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImpBrush.cpp
64 lines (51 loc) · 1.5 KB
/
ImpBrush.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// ImpBrush.cpp
//
// The implementation of virtual brush. All the other brushes inherit from it.
//
#include "impressionistDoc.h"
#include "impressionistUI.h"
#include "ImpBrush.h"
// Static class member initializations
int ImpBrush::c_nBrushCount = 0;
ImpBrush** ImpBrush::c_pBrushes = NULL;
ImpBrush::ImpBrush(ImpressionistDoc* pDoc,
char* name) :
m_pDoc(pDoc),
m_pBrushName(name)
{
}
//---------------------------------------------------
// Return m_pDoc, which connects the UI and brushes
//---------------------------------------------------
ImpressionistDoc* ImpBrush::GetDocument(void)
{
return m_pDoc;
}
//---------------------------------------------------
// Return the name of the current brush
//---------------------------------------------------
char* ImpBrush::BrushName(void)
{
return m_pBrushName;
}
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLubyte color[4];
float color2[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
for (int i = 0; i < 3; i++) {
color2[i] = color[i] / 256.0;
}
color2[3] = pDoc->getAlpha();
glColor4fv( color2 );
}