300x250
반응형

Blue.zip
0.06MB

 

위 프로그램을 실행하면 컴퓨터가 블루스크린 뜨면서 꺼지게 됩니다.

300x250
반응형
300x250
반응형

RadioTextColorTest.zip
0.29MB
RadioTextColorTest.exe
0.09MB

 

 

1. OnInitDialog() 함수 내에 아래 코드를 넣어줍니다.

1
::SetWindowTheme(GetDlgItem(IDC_RADIO1)->m_hWnd, L"", L"");
cs

 

2. OnCtlColor 함수 내에 변경될 색과 배경을 넣어줍니다.

1
2
3
4
5
6
   if (pWnd->GetDlgCtrlID() == IDC_RADIO1)
    {
        pDC->SetTextColor(RGB(25500));  // static text 글자색 변경
        pDC->SetBkMode(TRANSPARENT);   // static text 배경색 투명    
        //hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
    }
cs

 

 

[정보가 도움이 되셨다면 광고 배너 클릭이 글쓴이의 활력이 됩니다.]

감사합니다.

 

300x250
반응형
300x250
반응형

리스트에 선택된 행을 클립보드에 복사 하기

 

 

1. 해당 ListView에 keyDown 이벤트를 추가 하여 4~7번줄 내용을 넣습니다.

2. CopyListBox 함수를 추가 합니다.

 

해당 리스트뷰에서 콘트롤 + C 하면 클립보드로 내용이 복사 됩니다.

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
private void listview_KeyDown(object sender, KeyEventArgs e)
{
    //콘트롤 + C 누르면
    if (e.Control && e.KeyCode == Keys.C)
    {
        CopyListBox((System.Windows.Forms.ListView)sender);
    }
}
 
 
public void CopyListBox(ListView list)
{
    StringBuilder sb = new StringBuilder();
    foreach (var item in list.SelectedItems)
    {
        ListViewItem l = item as ListViewItem;
        if (l != null)
        {
            foreach (ListViewItem.ListViewSubItem sub in l.SubItems)
            {
                sb.Append(sub.Text + "\t");
            }
        }
        sb.AppendLine();
    }
    Clipboard.SetDataObject(sb.ToString().Trim()); 
}
 
cs

 

[정보가 도움이 되셨다면 광고 배너 클릭이 글쓴이의 활력이 됩니다.]

감사합니다.

 

300x250
반응형

'윈도우 프로그래밍 > c#' 카테고리의 다른 글

C# 외부 프로그램 실행, 종료  (1) 2022.04.09
300x250
반응형

DoModal()
PreSubclassWindow()
OnNcCreate()
OnNcCalcSize()
OnCreate()
OnSize()
OnMove()
OnSetFont()
OnInitDialog()
OnWindowPosChanging()
OnMove()
OnWindowPosChanged()
OnWindowPosChanging()
OnNcActivate()
OnActivate()
OnShowWindow()
OnWindowPosChanging()
OnNcPaint()
OnEraseBkgnd()
OnChildNotify()
OnCtlColor()
OnWindowPosChanged()
OnPaint()
OnCtlColor()
OnCtlColor()
OnNcHitTest()
OnSetCursor()
PreTranslateMessage()
OnMouseMove()
OnNcHitTest()
OnSetCursor()
PreTranslateMessage() 

 

[정보가 도움이 되셨다면 광고 배너 클릭이 글쓴이의 활력이 됩니다.]

감사합니다.


출처 http://egloos.zum.com/minnimok/v/4125818

300x250
반응형
300x250
반응형

#include <sb7.h>

class tessllatedgstri_app : public sb7::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Tessellation and Geometry Shaders";

        sb7::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    virtual void startup()
    {
        static const char * vs_source[] =
        {
            "#version 410 core                                                                  \n"
            "                                                                                   \n"
            "void main(void)                                                                    \n"
            "{                                                                                  \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),                   \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),                   \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0));                  \n"
            "                                                                                   \n"
            "    gl_Position = vertices[gl_VertexID];                                           \n"
            "}                                                                                  \n"
        };

        static const char * tcs_source[] =
        {
            "#version 410 core                                                                  \n"
            "                                                                                   \n"
            "layout (vertices = 3) out;                                                         \n"
            "                                                                                   \n"
            "void main(void)                                                                    \n"
            "{                                                                                  \n"
            "    if (gl_InvocationID == 0)                                                      \n"
            "    {                                                                              \n"
            "        gl_TessLevelInner[0] = 5.0;                                                \n"
            "        gl_TessLevelOuter[0] = 5.0;                                                \n"
            "        gl_TessLevelOuter[1] = 5.0;                                                \n"
            "        gl_TessLevelOuter[2] = 5.0;                                                \n"
            "    }                                                                              \n"
            "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;      \n"
            "}                                                                                  \n"
        };

        static const char * tes_source[] =
        {
            "#version 410 core                                                                  \n"
            "                                                                                   \n"
            "layout (triangles, equal_spacing, cw) in;                                          \n"
            "                                                                                   \n"
            "void main(void)                                                                    \n"
            "{                                                                                  \n"
            "    gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) +                        \n"
            "                  (gl_TessCoord.y * gl_in[1].gl_Position) +                        \n"
            "                  (gl_TessCoord.z * gl_in[2].gl_Position);                         \n"
            "}                                                                                  \n"
        };

        static const char * gs_source[] =
        {
            "#version 410 core                                                                  \n"
            "                                                                                   \n"
            "layout (triangles) in;                                                             \n"
            "layout (points, max_vertices = 3) out;                                             \n"
            "                                                                                   \n"
            "void main(void)                                                                    \n"
            "{                                                                                  \n"
            "    int i;                                                                         \n"
            "                                                                                   \n"
            "    for (i = 0; i < gl_in.length(); i++)                                           \n"
            "    {                                                                              \n"
            "        gl_Position = gl_in[i].gl_Position;                                        \n"
            "        EmitVertex();                                                              \n"
            "    }                                                                              \n"
            "}                                                                                  \n"
        };

        static const char * fs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "out vec4 color;                                                   \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    color = vec4(0.0, 0.8, 1.0, 1.0);                             \n"
            "}                                                                 \n"
        };

        program = glCreateProgram();
        GLuint vs = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vs, 1, vs_source, NULL);
        glCompileShader(vs);

        GLuint tcs = glCreateShader(GL_TESS_CONTROL_SHADER);
        glShaderSource(tcs, 1, tcs_source, NULL);
        glCompileShader(tcs);

        GLuint tes = glCreateShader(GL_TESS_EVALUATION_SHADER);
        glShaderSource(tes, 1, tes_source, NULL);
        glCompileShader(tes);

        GLuint gs = glCreateShader(GL_GEOMETRY_SHADER);
        glShaderSource(gs, 1, gs_source, NULL);
        glCompileShader(gs);

        GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fs, 1, fs_source, NULL);
        glCompileShader(fs);

        glAttachShader(program, vs);
        glAttachShader(program, tcs);
        glAttachShader(program, tes);
        glAttachShader(program, gs);
        glAttachShader(program, fs);

        glLinkProgram(program);

        glDeleteShader(vs);
        glDeleteShader(tcs);
        glDeleteShader(tes);
        glDeleteShader(gs);
        glDeleteShader(fs);

        glGenVertexArrays(1, &vao);
        glBindVertexArray(vao);
    }

    virtual void render(double currentTime)
    {
        static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, green);

        glUseProgram(program);

        glPointSize(5.0f);

        glDrawArrays(GL_PATCHES, 0, 3);
    }

    virtual void shutdown()
    {
        glDeleteVertexArrays(1, &vao);
        glDeleteProgram(program);
    }

private:
    GLuint          program;
    GLuint          vao;
};

DECLARE_MAIN(tessllatedgstri_app)

 

 

 

300x250
반응형
300x250
반응형

 

#include <sb7.h>

class tessellatedtri_app : public sb7::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Tessellated Triangle";

        sb7::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    virtual void startup()
    {
        static const char * vs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0)); \n"
            "                                                                  \n"
            "    gl_Position = vertices[gl_VertexID];                          \n"
            "}                                                                 \n"
        };

        static const char * tcs_source[] =
        {
            "#version 410 core                                                                 \n"
            "                                                                                  \n"
            "layout (vertices = 3) out;                                                        \n"
            "                                                                                  \n"
            "void main(void)                                                                   \n"
            "{                                                                                 \n"
            "    if (gl_InvocationID == 0)                                                     \n"
            "    {                                                                             \n"
            "        gl_TessLevelInner[0] = 5.0;                                               \n"
            "        gl_TessLevelOuter[0] = 5.0;                                               \n"
            "        gl_TessLevelOuter[1] = 5.0;                                               \n"
            "        gl_TessLevelOuter[2] = 5.0;                                               \n"
            "    }                                                                             \n"
            "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;     \n"
            "}                                                                                 \n"
        };

        static const char * tes_source[] =
        {
            "#version 410 core                                                                 \n"
            "                                                                                  \n"
            "layout (triangles, equal_spacing, cw) in;                                         \n"
            "                                                                                  \n"
            "void main(void)                                                                   \n"
            "{                                                                                 \n"
            "    gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) +                       \n"
            "                  (gl_TessCoord.y * gl_in[1].gl_Position) +                       \n"
            "                  (gl_TessCoord.z * gl_in[2].gl_Position);                        \n"
            "}                                                                                 \n"
        };

        static const char * fs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "out vec4 color;                                                   \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    color = vec4(0.0, 0.8, 1.0, 1.0);                             \n"
            "}                                                                 \n"
        };

        program = glCreateProgram();
        GLuint vs = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vs, 1, vs_source, NULL);
        glCompileShader(vs);

        GLuint tcs = glCreateShader(GL_TESS_CONTROL_SHADER);
        glShaderSource(tcs, 1, tcs_source, NULL);
        glCompileShader(tcs);

        GLuint tes = glCreateShader(GL_TESS_EVALUATION_SHADER);
        glShaderSource(tes, 1, tes_source, NULL);
        glCompileShader(tes);

        GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fs, 1, fs_source, NULL);
        glCompileShader(fs);

        glAttachShader(program, vs);
        glAttachShader(program, tcs);
        glAttachShader(program, tes);
        glAttachShader(program, fs);

        glLinkProgram(program);

        glGenVertexArrays(1, &vao);
        glBindVertexArray(vao);

        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }

    virtual void render(double currentTime)
    {
        static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, green);

        glUseProgram(program);
        glDrawArrays(GL_PATCHES, 0, 3);
    }

    virtual void shutdown()
    {
        glDeleteVertexArrays(1, &vao);
        glDeleteProgram(program);
    }

private:
    GLuint          program;
    GLuint          vao;
};

DECLARE_MAIN(tessellatedtri_app)
300x250
반응형
300x250
반응형

전체코드

#include <sb7.h>

// Undefine this to take color from screen space
#define INTERPOLATE_COLOR

class colorfromposition_app : public sb7::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Simple Triangle";

        sb7::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    virtual void startup()
    {
#ifndef INTERPOLATE_COLOR
        static const char * vs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0));          \n"
            "                                                                           \n"
            "    gl_Position = vertices[gl_VertexID];                                   \n"
            "}                                                                          \n"
        };

        static const char * fs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "out vec4 color;                                                            \n"
            "                                                                           \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    color = vec4(sin(gl_FragCoord.x * 0.25) * 0.5 + 0.5,                   \n"
            "                 cos(gl_FragCoord.y * 0.25) * 0.5 + 0.5,                   \n"
            "                 sin(gl_FragCoord.x * 0.15) * cos(gl_FragCoord.y * 0.1),  \n"
            "                 1.0);                                                     \n"
            "}                                                                          \n"
        };
#else
        static const char * vs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "out vec4 vs_color; \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0));          \n"
            "    const vec4 colors[] = vec4[](vec4(1.0, 0.0, 0.0, 1.0),                 \n"
            "                                 vec4(0.0, 1.0, 0.0, 1.0),                 \n"
            "                                 vec4(0.0, 0.0, 1.0, 1.0));                \n"
            "                                                                           \n"
            "    gl_Position = vertices[gl_VertexID];                                   \n"
            "    vs_color = colors[gl_VertexID];                                        \n"
            "}                                                                          \n"
        };

        static const char * fs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "in vec4 vs_color;                                                          \n"
            "out vec4 color;                                                            \n"
            "                                                                           \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    color = vs_color;                                                      \n"
            "}                                                                          \n"
        };
#endif

        program = glCreateProgram();
        GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fs, 1, fs_source, NULL);
        glCompileShader(fs);

        GLuint vs = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vs, 1, vs_source, NULL);
        glCompileShader(vs);

        glAttachShader(program, vs);
        glAttachShader(program, fs);

        glLinkProgram(program);

        glGenVertexArrays(1, &vao);
        glBindVertexArray(vao);
    }

    virtual void render(double currentTime)
    {
        static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, green);

        glUseProgram(program);
        glDrawArrays(GL_TRIANGLES, 0, 3);
    }

    virtual void shutdown()
    {
        glDeleteVertexArrays(1, &vao);
        glDeleteProgram(program);
    }

private:
    GLuint          program;
    GLuint          vao;
};

DECLARE_MAIN(colorfromposition_app)

 

설명

        static const char * vs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "out vec4 vs_color; \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),           \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0));          \n"
            "    const vec4 colors[] = vec4[](vec4(1.0, 0.0, 0.0, 1.0),                 \n"
            "                                 vec4(0.0, 1.0, 0.0, 1.0),                 \n"
            "                                 vec4(0.0, 0.0, 1.0, 1.0));                \n"
            "                                                                           \n"
            "    gl_Position = vertices[gl_VertexID];                                   \n"
            "    vs_color = colors[gl_VertexID];                                        \n"
            "}                                                                          \n"
        };

vs_source 안의

vs_color를 out으로 선언한후

 

        static const char * fs_source[] =
        {
            "#version 420 core                                                          \n"
            "                                                                           \n"
            "in vec4 vs_color;                                                          \n"
            "out vec4 color;                                                            \n"
            "                                                                           \n"
            "void main(void)                                                            \n"
            "{                                                                          \n"
            "    color = vs_color;                                                      \n"
            "}                                                                          \n"
        };

fs_source 안에서 vs_color를 in으로 받아서 color를 결정 한다.

300x250
반응형
300x250
반응형

전체코드

#include <sb7.h>
#include <math.h>

class singlepoint_app : public sb7::application
{
    void init()
    {
        static const char title[] = "OpenGL SuperBible - Single Point";

        sb7::application::init();

        memcpy(info.title, title, sizeof(title));
    }

    virtual void startup()
    {
        static const char * vs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "layout (location = 0) in vec4 offset;                             \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0)); \n"
            "                                                                  \n"
            "    // Add 'offset' to our hard-coded vertex position             \n"
            "    gl_Position = vertices[gl_VertexID] + offset;                 \n"
            "}                                                                 \n"
        };

        static const char * fs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "out vec4 color;                                                   \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    color = vec4(0.0, 0.8, 1.0, 1.0);                             \n"
            "}                                                                 \n"
        };
		
        program = glCreateProgram();
        GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fs, 1, fs_source, NULL);
        glCompileShader(fs);

        GLuint vs = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vs, 1, vs_source, NULL);
        glCompileShader(vs);

        glAttachShader(program, vs);
        glAttachShader(program, fs);

        glLinkProgram(program);

        glGenVertexArrays(1, &vao);
        glBindVertexArray(vao);
    }

    virtual void render(double currentTime)
    {
        static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, green);

        glUseProgram(program);

        GLfloat attrib[] = { (float)sin(currentTime) * 0.5f,
                             (float)cos(currentTime) * 0.6f,
                             0.0f, 0.0f };

        glVertexAttrib4fv(0, attrib); // 1번째 파라미터 쉐이더의 layout (location = 0) 와 대칭

        glDrawArrays(GL_TRIANGLES, 0, 3);
    }

    virtual void shutdown()
    {
        glDeleteVertexArrays(1, &vao);
        glDeleteProgram(program);
    }

private:
    GLuint          program;
    GLuint          vao;
};

DECLARE_MAIN(singlepoint_app)

 

설명

    virtual void render(double currentTime)
    {
        static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, green);

        glUseProgram(program);

        GLfloat attrib[] = { (float)sin(currentTime) * 0.5f,
                             (float)cos(currentTime) * 0.6f,
                             0.0f, 0.0f };

        glVertexAttrib4fv(0, attrib); // 1번째 파라미터 쉐이더의 layout (location = 0) 와 대칭

        glDrawArrays(GL_TRIANGLES, 0, 3);
    }

render 함수내

 

        GLfloat attrib[] = { (float)sin(currentTime) * 0.5f,
                             (float)cos(currentTime) * 0.6f,
                             0.0f, 0.0f };

        glVertexAttrib4fv(0, attrib); // 1번째 파라미터 쉐이더의 layout (location = 0) 와 대칭 

부분을 보면 0값은 

static const char * vs_source[] =
        {
            "#version 410 core                                                 \n"
            "                                                                  \n"
            "layout (location = 0) in vec4 offset;                             \n"
            "                                                                  \n"
            "void main(void)                                                   \n"
            "{                                                                 \n"
            "    const vec4 vertices[] = vec4[](vec4( 0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4(-0.25, -0.25, 0.5, 1.0),  \n"
            "                                   vec4( 0.25,  0.25, 0.5, 1.0)); \n"
            "                                                                  \n"
            "    // Add 'offset' to our hard-coded vertex position             \n"
            "    gl_Position = vertices[gl_VertexID] + offset;                 \n"
            "}                                                                 \n"
        };

layout (location = 0) in vec4 offset; 의 offset 변수 인덱스번호를 의미 한다.

300x250
반응형

+ Recent posts