Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: GLSL Issue, How to add this file to vc2010?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296

    Question GLSL Issue, How to add this file to vc2010?

    the file name, basic.vert,
    //
    #version 400
    in vec3 VertexPosition;
    in vec3 VertexColor;

    out vec3 Color;

    void main()
    {
    Color =VertexColor;
    gl_Position = vec4(VertexPosition,1.0);
    }
    How to add it in vc?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    and this , name basic.frag /// they are for gl4.0 sample.
    #version 400
    in vec3 Color;
    out vec4 FragColor;

    void main()
    {
    FragColor = vec4(Color,1.0);
    }
    ////////////////////////////////
    The main app is
    #pragma comment(lib,"glew32.lib")

    #include <GL/glew.h>
    #include "textfile.h"

    #include <GL/glut.h>
    #include <iostream>
    using namespace std;

    GLuint vShader,fShader;

    float positionData[] = {
    -0.8f, -0.8f, 0.0f,
    0.8f, -0.8f, 0.0f,
    0.0f, 0.8f, 0.0f };

    float colorData[] = {
    1.0f, 0.0f, 0.0f,
    0.0f, 1.0f, 0.0f,
    0.0f, 0.0f, 1.0f };

    GLuint vaoHandle;//vertex array object
    .......

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2015
    Posts
    21
    How? You don't. This are plain data-files, your exe has to read. Nothing, VS has to compile. After compiling your exe, put them into the Debug-Folder in your Solution-Folder, thats (as default) your "current workingdir" when you start your exe.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by tkausl View Post
    How? You don't. This are plain data-files, your exe has to read. Nothing, VS has to compile. After compiling your exe, put them into the Debug-Folder in your Solution-Folder, thats (as default) your "current workingdir" when you start your exe.
    You mean compile them, basic.vert and basic.frag individually into each *.exe, then put the *.exe into debug dir with main prog, then run the main program?

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    No, he means to stick the text files there.

    You compile shaders during your program's execution, not at C/C++ compile time.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    I mean how to use them in vc2010, if not use their special complier like NVIDIA FxComposer etc.

  7. #7
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    You use them in VC2010 no differently than in any other toolchain.

    The compiler you use is the one that happens at runtime, not at your program's compile time. You load a text file that contains your shader's text, you stick that text string into OpenGL, and out comes a compiled, linked program object.

    This happens no matter what compiler you use for C++.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    pls show an example, or step by step by use vc. is it:
    stck the two files to the debug fold with mainglslpro.exe?

  9. #9
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    pls show an example, or step by step by use vc.
    Um, here's an idea. Why don't you follow that nice link I gave you?

    And more importantly, if you can't even load a file in a C++ program without someone giving you code to copy-and-paste from, you aren't ready to be doing graphics at all. Learn how to use C++ for a while, then you can learn how to do graphics programming in it.

  10. #10
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Alfonse Reinheart View Post
    You use them in VC2010 no differently than in any other toolchain.

    The compiler you use is the one that happens at runtime, not at your program's compile time. You load a text file that contains your shader's text, you stick that text string into OpenGL, and out comes a compiled, linked program object.

    This happens no matter what compiler you use for C++.
    the doc is too loong to read, is there any simpe step to describe how to use it under vc?

Page 1 of 2 12 LastLast

Similar Threads

  1. glsl if statment issue
    By borcha in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-12-2015, 09:16 PM
  2. GLSL Translation Issue
    By Wasabi in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-07-2011, 01:33 AM
  3. glui VC2010 error
    By Shao tian in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-01-2011, 12:34 PM
  4. GLSL Issue on ATI Card
    By GrahamH in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-01-2008, 11:47 AM
  5. Weird GLSL Issue
    By toneburst in forum OpenGL: GLSL
    Replies: 17
    Last Post: 04-05-2008, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean