예제 #1
0
int CTexture::LoadMipmapTexture (const char *filename, bool repeatable) {
    CImage texImage;
    GLuint texid;

    if (texImage.LoadPng (filename, true) == false) return 0;
    glGenTextures (1, &texid);
    glBindTexture (GL_TEXTURE_2D, texid);
    glPixelStorei (GL_UNPACK_ALIGNMENT, 4);

    if  (repeatable) {
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    } else {
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    }

    GLenum format;
    if (texImage.depth == 3) format = GL_RGB;
    else format = GL_RGBA;

    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

    gluBuild2DMipmaps
    (GL_TEXTURE_2D, texImage.depth, texImage.nx,
     texImage.ny, format, GL_UNSIGNED_BYTE, texImage.data);

    texImage.DisposeData();
    return texid;
}
예제 #2
0
void ScreenshotN () {
    CImage image;
    string path = param.screenshot_dir;
    path += SEP;
    path += Course.CourseList[g_game.course_id].dir;
    path += "_";
    path += GetTimeString1 ();
    int type = SCREENSHOT_PROC;

    switch (type) {
    case 0:
        path += ".ppm";
        image.ReadFrameBuffer_PPM ();
        image.WritePPM (path.c_str());
        image.DisposeData ();
        break;
    case 1:
        path += ".tga";
        image.ReadFrameBuffer_TGA ();
        image.WriteTGA (path.c_str());
        image.DisposeData ();
        break;
    case 2:
        path += ".tga";
        image.ReadFrameBuffer_TGA ();
        image.WriteTGA_H (path.c_str());
        image.DisposeData ();
        break;
    case 3:
        path += ".bmp";
        image.ReadFrameBuffer_BMP ();
        image.WriteBMP (path.c_str());
        image.DisposeData ();
        break;
    }
}