Help in C++ please

Started by Electronics Boy, May 03, 2021, 06:26:51

Previous topic - Next topic

Electronics Boy

Hi! i know that i should not post this here, but i did not find any other website(Yes, i tryed to post in stackoverflow but got my account terminated for no reason).

so this is the error log: 
||=== Build: Release in Minecraft Alpha rd-20090515 (compiler: GNU GCC Compiler) ===|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp||In constructor 'StaticShader::StaticShader()':|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|5|error: 'GL_VERTEX_SHADER' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|5|note: suggested alternative: 'GL_VERTEX_ARRAY'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|6|error: 'GL_FRAGMENT_SHADER' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|6|note: suggested alternative: 'GL_FRONT_FACE'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|8|error: 'glCreateProgram' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|8|note: suggested alternative: 'CreateProcess'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|10|error: 'glAttachShader' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|10|note: suggested alternative: 'loadShader'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|13|error: 'glBindAttribLocation' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|13|note: suggested alternative: 'MonitorInvocation'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|15|error: 'glLinkProgram' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|16|error: 'glValidateProgram' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|16|note: suggested alternative: 'ValidateRgn'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp||In member function 'void StaticShader::start()':|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|20|error: 'glUseProgram' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp||In member function 'void StaticShader::stop()':|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|23|error: 'glUseProgram' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp||In member function 'GLuint StaticShader::loadShader(std::__cxx11::string, GLenum)':|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|27|error: 'glCreateShader' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|27|note: suggested alternative: 'loadShader'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|29|error: 'glShaderSource' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|29|note: suggested alternative: 'shaderSource'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|30|error: 'glCompileShader' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|30|note: suggested alternative: 'loadShader'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|31|error: 'GL_COMPILE_STATUS' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|31|note: suggested alternative: 'LPSERVICE_STATUS'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|31|error: 'glGetShaderi' was not declared in this scope|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|31|note: suggested alternative: 'loadShader'|
C:\Users\Bittu\Documents\Minecraft C++ Coding\Minecraft Alpha rd-20090515\Minecraft Alpha rd-20090515\src\shaders\StaticShader.cpp|37|error: expected unqualified-id before '/' token|
||=== Build failed: 15 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===|


i dont know why

here is the code for shader.cpp:

#include "StaticShader.h"
#include "GL/glut.h"

StaticShader::StaticShader() {
    StaticShader::vertexShaderID = StaticShader::loadShader(StaticShader::vertexShader, GL_VERTEX_SHADER);
    StaticShader::fragmentShaderID = StaticShader::loadShader(StaticShader::fragmentShader, GL_FRAGMENT_SHADER);

    StaticShader::programID = glCreateProgram();

    glAttachShader(StaticShader::programID, vertexShaderID);
    glAttachShader(StaticShader::programID, fragmentShaderID);

    glBindAttribLocation(StaticShader::programID, 0, "position");

    glLinkProgram(StaticShader::programID);
    glValidateProgram(StaticShader::programID);
}

void StaticShader::start() {
    glUseProgram(StaticShader::programID);
}
void StaticShader::stop() {
    glUseProgram(0);
}

GLuint StaticShader::loadShader(string shaderSource, GLenum type) {
    GLuint shader = glCreateShader(type);

    glShaderSource(shader, 1, shaderSource, sizeof(shaderSource));
    glCompileShader(shader);
    if(!glGetShaderi(shader, GL_COMPILE_STATUS)) {
        cout << "Unable to compile shader!" << endl;
        exit(-1);
    }
    return shader;
}


and for shader.h:
#ifndef STATICSHADER_H
#define STATICSHADER_H

#include "GL/glut.h"
#include <iostream>

using namespace std;

class StaticShader
{
    public:
        StaticShader();
        void start();
        void stop();
    protected:
        GLuint loadShader(string shaderSource, GLenum type);

        string vertexShader = string("#version 150")      +
                              string("in vec3 position;") +
                              string("out vec3 colour;")  +

                              string("void main(void) {")  +
                              string(  "gl_Position = vec4(position,1.0);")  +
                              string(  "colour = vec3(position.x+0.5,0.0,position.y+0.5);") +
                              string("}");

        string fragmentShader = string("#version 150") +
                                string("in vec3 colour;") +
                                string("out vec4 out_Color;") +

                                string("void main(void) {") +
                                string("    out_Color = vec4(colour,1.0);") +
                                string("}");

        GLuint vertexShaderID;
        GLuint fragmentShaderID;

        GLuint programID;
    private:
};

#endif // STATICSHADER_H


for the other classes, please ask for it, i will send a link for them

Electronics Boy


mudlee

You ask help for C++ on a java library forum, and even after fixing your C++ code, you donââ,¬â,,¢t post the solution. Congrats!