0

I just installed Visual Studio 2012/2013 on my Mac with Windows7 on bootcamp.

However, it seems that my VS project(win32 project) does not working properly on them. Once I click F5/ctrl+F5, the window just shows and disappears in a sudden. I tried both VS 2012 and 2013, both got the same issue. And the exe file generated in the bin folder has the same problem. All of the projects I tested works fine on other PCs.

I tried a basic console "HelloWorld" project, it worked correctly.

Any one know what's wrong with it?

screenshot here: https://i.stack.imgur.com/bT9HU.jpg

Thanks a lot!

Sty

<!-- language: C++ -->
#include <sb6.h>
#include <vmath.h>

class my_app : public sb6::application
{
public:
    void startup(){
        rendering_program = compile_shaders();
        glGenVertexArrays(1, &vertex_array_object);
        glBindVertexArray(vertex_array_object);
    }

    void render(double currentTime){

        const GLfloat color[] = { 0.0f, 0.0f, 0.5f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, color);

        glUseProgram(rendering_program);

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

        glVertexAttrib4fv(0, attrib);

        GLfloat attribColor[] = { 1.0f, 0.0f, 0.0f, 1.0f };
        glVertexAttrib4fv(1, attribColor);

        glDrawArrays(GL_TRIANGLES, 0, 3);
    }

    void shutdown(){
        glDeleteVertexArrays(1, &vertex_array_object);
        glDeleteProgram(rendering_program);
    }
private:
    GLuint rendering_program;
    GLuint vertex_array_object;

    GLuint compile_shaders(void){
        GLuint vertex_shader;
        GLuint fragment_shader;
        GLuint program;

        static const GLchar * vertex_shader_source[] = {
            "#version 410 core                                                      \n"
            "                                                                       \n"
            "layout (location = 0) in vec4 offset;                                  \n"
            "layout (location = 1) in vec4 color;                                   \n"
            "                                                                       \n"
            "out VS_OUT                                                             \n"
            "{                                                                      \n"
            "   vec4 color;                                                         \n"
            "} vs_out;                                                              \n"
            "                                                                       \n"
            "void main(void)                                                        \n"
            "{                                                                      \n"
            "   const vec4 vertices[3] = vec4[3](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] + offset;                       \n"
            "   vs_out.color = color;                                               \n"
            "}                                                                      \n"
        };

        static const GLchar * fragment_shader_source[] = {
            "#version 410 core                              \n"
            "                                               \n"
            "in VS_OUT                                      \n"
            "{                                              \n"
            "   vec4 color;                                 \n"
            "} fs_in;                                       \n"
            "                                               \n"
            "out vec4 color;                                \n"
            "                                               \n"
            "void main(void)                                \n"
            "{                                              \n"
            "   color = fs_in.color;                        \n"
            "}                                              \n"
        };

        vertex_shader = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vertex_shader, 1, vertex_shader_source, NULL);
        glCompileShader(vertex_shader);

        fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fragment_shader, 1, fragment_shader_source, NULL);
        glCompileShader(fragment_shader);

        program = glCreateProgram();
        glAttachShader(program, vertex_shader);
        glAttachShader(program, fragment_shader);
        glLinkProgram(program);

        glDeleteShader(vertex_shader);
        glDeleteShader(fragment_shader);

        return program;
    }
};
DECLARE_MAIN(my_app);
styzhu
  • 1
  • 2
  • Just for clarity, you're not running that bootcamp partition under VMware, right? You've actually *booted* the bootcamp partition and are running native windows directly on your hardware? And include the source of your program in your question, stripping any cruft not needed to reproduce the issue (which is likely quite a lot). – WhozCraig Mar 10 '15 at 06:33
  • Hi @WhozCraig, no I was not running it on bootcamp. Edited the post with the source code. I've tried several projects, all of them have the same issue. Also I found out that using Microsoft Remote Desktop to remote control another PC which should runs fine will get me the same issue. Same situation happens to my friend. Maybe it's something related to OpenGL? – styzhu Mar 11 '15 at 01:44

0 Answers0