Uniform,attribute type error?

hi,

im using SDL2, NDK, OpenGl ES 2.0 on ubunto 12.04, and when i declare variable as “uniform type or attribute type”, i get this error :

main.cpp:15:1: error: ‘uniform’ does not name a type

here my included files :
#include <SDL2/SDL.h>
#include <android/log.h>
#include <iostream>
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <GLES2/gl2ext.h>

thanks a lot.

And what do you have at line 15 of main.cpp?

here my main.cpp

my program work without any porblem when i remove this line “uniform vec4 myVar;”


#include <SDL2/SDL.h>
#include <android/log.h>
#include <iostream>
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <GLES2/gl2ext.h>

uniform vec4 myVar;

int main(int argc, char **argv)
{
// Notre fenetre

SDL_Window* fenetre(0);
SDL_GLContext contexteOpenGL(0);

SDL_Event evenements;
bool terminer(false);


// Initialisation de la SDL

if(SDL_Init(SDL_INIT_VIDEO) &lt; 0)
{
    std::cout &lt;&lt; "Erreur lors de l'initialisation de la SDL : " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
    SDL_Quit();
    
    return -1;
}


// Version d'OpenGL

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);


// Double Buffer

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);


// Creation de la fenetre

fenetre = SDL_CreateWindow("Test SDL 2.0", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);

if(fenetre == 0)
{
    std::cout &lt;&lt; "Erreur lors de la creation de la fenetre : " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
    SDL_Quit();
    
    return -1;
}


// Creation du contexte OpenGL

contexteOpenGL = SDL_GL_CreateContext(fenetre);

if(contexteOpenGL == 0)
{
    std::cout &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
    SDL_DestroyWindow(fenetre);
    SDL_Quit();
    
    return -1;
}


// Boucle principale

while(!terminer)
{
    SDL_PollEvent(&evenements);
    
    if(evenements.window.event == SDL_WINDOWEVENT_CLOSE)
        terminer = true;
    
    glClearColor(0.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    
    SDL_GL_SwapWindow(fenetre);
    
    SDL_Delay(100);
}


// On quitte la SDL

SDL_GL_DeleteContext(contexteOpenGL);
SDL_DestroyWindow(fenetre);
SDL_Quit();

return 0;

}


thank you thokra for your reply

Please use [noparse]


[/noparse] tags around source code.
You are programming in C/C++ and “uniform” is not a keyword in those languages, hence the compiler complains. It is a keyword in GLSL, but code written in GLSL is stored in strings (or loaded at runtime from text files) and passed to the shader compiler (at runtime!) that is part of your OpenGL implementation (aka. the graphics driver).

sorry its my first post, and thank you its clear :wink:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.