Hi guys

I'm currently trying to use the function : glCopyImageSubData, but the code crashes when it uses it. (Segmentation Fault, Core Dumped : Yay !)
I'm using a GeForce GTX 670 GPU with OpenGL 4.4.0 version installed. Driver : 340.96.
I really don't know what I'm doing wrong, or maybe it's a problem with a driver ...
Any help is welcomed, even needed ! Thanks in advance

Here's my super simple code...

Code :
#include <cstdlib>
#include <iostream>
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "SOIL/SOIL.h"
 
 
using namespace std;
 
GLuint tex, ctex;
 
int width, height;
 
 
void initTex(void){
 
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &tex);
    glBindTexture(GL_TEXTURE_2D, tex);
 
    //loading
    unsigned char* image;
    image = SOIL_load_image("/home/alien/sources/of_v0.9.3_linux64_release/apps/myApps/createOpenGLContext/dist/Debug/GNU-Linux/of0", &width, &height, 0, SOIL_LOAD_RGB);
 
    if(image==0){
        cout << "Image didn't loaded" << endl;
    }
 
 
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
 
 
    //Wrap Mode
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 
    //Filtering
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
    cout << SOIL_last_result() << endl;
    cout << "width = "<< width << endl;
    cout << "height = "<< height << endl;
 
    glBindTexture(GL_TEXTURE_2D, 0);
 
    glDisable(GL_TEXTURE_2D);
    cout << "init Tex glError ? " << glGetError() << endl;
    SOIL_free_image_data(image);
}
 
void copyTex(void){
 
    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &ctex);
    glBindTexture(GL_TEXTURE_2D, ctex);
 
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
    glBindTexture(GL_TEXTURE_2D, 0);
 
    cout << "ctex id = " << ctex << endl;
 
    try{
 
        glCopyImageSubData(tex, GL_TEXTURE_2D, 0, 0, 0, 0, ctex, GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1);
        cout << "MISSION COMPLETE "<<endl;
 
    }
    catch(int e) {
 
    cout << "ERROR : " << glGetError() << " - exp " << e <<endl;
 
    }
}
 
void init(void){
    glClearColor(1, 1, 1, 1);
    glShadeModel(GL_FLAT);
    initTex();
    copyTex();
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    cout << "end of init : "<<glGetError() << endl;
 
}
 
void display(void){
 
    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glBindTexture(GL_TEXTURE_2D, tex);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0, 0.0); glVertex3f(-1, 1, 0);
    glTexCoord2f(0.0, 1.0); glVertex3f(-1, -1, 0);
    glTexCoord2f(1.0, 1.0); glVertex3f(1, -1, 0);
    glTexCoord2f(1.0, 0.0); glVertex3f(1, 1, 0);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glFlush();
 
    cout << "End of Display : glError ? " << glGetError() << endl;
}
 
int main(int argc, char** argv) {
 
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(256,256);
    glutCreateWindow(argv[0]);
 
    init();
    glutDisplayFunc(display);
    glutMainLoop();
 
    return 0;
}

Cheers,

Masato