Jump to content
  • Advertisement

Valera

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

106 Neutral

About Valera

  • Rank
    Member
  1. Why, then, in the example of the book about nothing written?
  2. #pragma once #include "GraphEngine.h" class SinglePoint { public: void startup() { static const char * vs_source[] = { "#version 420 core \n" " \n" "void main(void) \n" "{ \n" " gl_Position = vec4(0.0, 0.0, 0.0, 1.0); \n" "} \n" }; static const char * fs_source[] = { "#version 420 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); } void render(double currentTime) { static const GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f }; glClearBufferfv(GL_COLOR, 0, red); glUseProgram(program); glPointSize(40.0f); glDrawArrays(GL_POINTS, 0, 1); } void shutdown() { glDeleteVertexArrays(1, &vao); glDeleteProgram(program); } private: GLuint program; GLuint vao; }; and void GLCore::ClickOk() { //sh = new Shaders(); //sh->Startup(); //sh->Render(); auto v = new SinglePoint(); v->startup(); v->render(1.0); SwapBuffer(); } Clear buffer is red color and not draw point(
  3. It`s my two small class. .h class ShaderCompile { public: GLuint Compile(); private: GLuint vertex_shader; GLuint fragment_shader; GLuint shader; const GLchar * vertex_shader_source { "#version 450 core \n" " \n" "void main(void) \n" "{ \n" " gl_Position = vec4(0.0, 0.0, 0.5, 1.0); \n" "} \n" }; const GLchar * fragment_shader_source { "#version 450 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" }; }; .cpp GLuint ShaderCompile::Compile() { const GLchar * proxy_shader[1]; proxy_shader[0] = vertex_shader_source; vertex_shader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertex_shader, 1, proxy_shader, NULL); glCompileShader(vertex_shader); proxy_shader[0] = fragment_shader_source; fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragment_shader, 1, proxy_shader, NULL); glCompileShader(fragment_shader); shader = glCreateProgram(); glAttachShader(shader, vertex_shader); glAttachShader(shader, fragment_shader); glLinkProgram(shader); glDeleteShader(vertex_shader); glDeleteShader(fragment_shader); auto status = GL_LINK_STATUS; auto error = glGetError(); auto comp = GL_COMPILE_STATUS; GLint linked = 0; glGetProgramiv(shader, GL_LINK_STATUS, &linked); if (!linked) return 0; return shader; } and .h class Shaders { public: void Startup(); void Shutdown(); void Render(); private: ShaderCompile * compiler; GLuint rendering_program; GLuint vertex_array_object; }; .cpp void Shaders::Startup() { compiler = new ShaderCompile(); rendering_program = compiler->Compile(); glCreateVertexArrays(1, &vertex_array_object); glBindVertexArray(vertex_array_object); } void Shaders::Shutdown() { glDeleteVertexArrays(1, &vertex_array_object); glDeleteProgram(rendering_program); delete compiler; } void Shaders::Render() { const GLfloat color[] { 0.0, 0.8, 1.0, 1.0 }; glClearBufferfv(GL_COLOR, 0, color); glUseProgram(rendering_program); glDrawArrays(GL_POINTS, 0, 1); glPointSize(100.0f); } I call this on click button event void GLCore::ClickOk() { sh = new Shaders(); sh->Startup(); sh->Render(); } and SwapBuffers on paint form event void GLCore::SwapBuffer() { SwapBuffers(m_Hdc); } Why dont draw point?  glDrawArrays(GL_POINTS, 0, 1);
  4. Valera

    Problem with glew.h

    Just don`t see, it`s work. Thanks alot for your help. 
  5. Valera

    Problem with glew.h

    I use vs2013. compiling dll c++\cli and when i using LPRECT rect without malloc() this value becomes 0x00000000 and GetWindowRect() return false. I am sorry, my english is bad 
  6. Valera

    Problem with glew.h

    I replaced to glew32s.lib, don't help
  7. Valera

    Problem with glew.h

    Yes, Windows 7 #define GLEW_STATIC #include <glew.h> #include <stdio.h> namespace TestTest { public ref class Test1 { public: void Test(); }; }; and include glew32.lib
  8. Valera

    Problem with glew.h

    I try minimal example and have error  #include "TestGlew.h" using namespace TestTest; void Test1::Test() { glewExperimental = GL_TRUE; glewInit(); GLuint vertexBuffer; glGenBuffers(1, &vertexBuffer); printf("%u\n", vertexBuffer); } and C# call dll var t = new Test1(); t.Test();
  9. Valera

    Problem with glew.h

    I create context on event form_load  GLManagedWrapper::GLManagedWrapper(INT_PTR hWnd) { if (!glewInit()) return; glewExperimental = GL_TRUE; m_Hwnd = (HWND)hWnd; if (!m_Hwnd) return; int m_Width, m_Height; LPRECT rect = (LPRECT)malloc(sizeof(RECT)); if (GetWindowRect(m_Hwnd, rect)) { m_Width = rect->right - rect->left; m_Height = rect->bottom - rect->top; } else return; free(rect); m_Hdc = GetDC(m_Hwnd); if (m_Hdc) { GLSetPixelFormat(m_Hdc); ReSizeGLScene(m_Width, m_Height); InitGL(); } }
  10. Hi all, I try use glew. This my code if (glewInit() == GLEW_NO_ERROR) { GLuint vertexbuffer; glGenBuffers(1, &vertexbuffer); } and I get an error on glGenBuffers An unhandled exception of type 'System.AccessViolationException' occurred in ManagedLib.dll, in compiled my dll c++/cli
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!