I need your help for this
#include <string>
#include <iostream>
#include <windows.h>
#include <shellapi.h>
#include <gl/gl.h>
#include <gl/glext.h>
#include <stdio.h>
#include "SOIL.h"
LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
void EnableOpenGL(HWND hwnd, HDC*, HGLRC*);
void DisableOpenGL(HWND, HDC, HGLRC);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wcex;
HWND hwnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL bQuit = FALSE;
float theta = 0.0f;
// register window class
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_OWNDC;
wcex.lpfnWndProc = WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "GLSample";
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wcex))
return 0;
// create main window
hwnd = CreateWindowEx(0,
"GLSample",
"SOIL Sample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
512,
512,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
// check my error handling
/*
SOIL_load_OGL_texture( "img_test.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, 0 );
std::cout << "'" << SOIL_last_result() << "'" << std::endl;
*/
// enable OpenGL for the window
EnableOpenGL(hwnd, &hDC, &hRC);
glEnable( GL_BLEND );
//glDisable( GL_BLEND );
// straight alpha
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// premultiplied alpha (remember to do the same in glColor!!)
//glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
// do I want alpha thresholding?
glEnable( GL_ALPHA_TEST );
glAlphaFunc( GL_GREATER, 0.5f );
// log what the use is asking us to load
std::string load_me = lpCmdLine;
if( load_me.length() > 2 )
{
//load_me = load_me.substr( 1, load_me.length() - 2 );
load_me = load_me.substr( 0, load_me.length() - 0 );
} else
{
//load_me = "img_test_uncompressed.dds";
//load_me = "img_test_indexed.tga";
//load_me = "img_test.dds";
load_me = "img_test.png";
//load_me = "odd_size.jpg";
//load_me = "img_cheryl.jpg";
//load_me = "oak_odd.png";
//load_me = "field_128_cube.dds";
//load_me = "field_128_cube_nomip.dds";
//load_me = "field_128_cube_uc.dds";
//load_me = "field_128_cube_uc_nomip.dds";
//load_me = "Goblin.dds";
//load_me = "parquet.dds";
//load_me = "stpeters_probe.hdr";
//load_me = "VeraMoBI_sdf.png";
// for testing the texture rectangle code
//load_me = "test_rect.png";
}
std::cout << "'" << load_me << "'" << std::endl;
// 1st try to load it as a single-image-cubemap
// (note, need DDS ordered faces: "EWUDNS")
GLuint tex_ID;
int time_me;
std::cout << "Attempting to load as a cubemap" << std::endl;
time_me = clock();
tex_ID = SOIL_load_OGL_single_cubemap(
load_me.c_str(),
SOIL_DDS_CUBEMAP_FACE_ORDER,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_POWER_OF_TWO
| SOIL_FLAG_MIPMAPS
| SOIL_FLAG_COMPRESS_TO_DXT
| SOIL_FLAG_TEXTURE_REPEATS
| SOIL_FLAG_INVERT_Y
| SOIL_FLAG_DDS_LOAD_DIRECT
);
time_me = clock() - time_me;
std::cout << "the load time was " << 0.001f * time_me << " seconds (warning: low resolution timer)" << std::endl;
if( tex_ID > 0 )
{
glEnable( GL_TEXTURE_CUBE_MAP );
glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T );
glEnable( GL_TEXTURE_GEN_R );
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP );
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP );
glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP );
glBindTexture( GL_TEXTURE_CUBE_MAP, tex_ID );
// report
std::cout << "the loaded single cube map ID was " << tex_ID << std::endl;
//std::cout << "the load time was " << 0.001f * time_me << " seconds (warning: low resolution timer)" << std::endl;
} else
{
std::cout << "Attempting to load as a HDR texture" << std::endl;
time_me = clock();
tex_ID = SOIL_load_OGL_HDR_texture(
load_me.c_str(),
//SOIL_HDR_RGBE,
//SOIL_HDR_RGBdivA,
SOIL_HDR_RGBdivA2,
0,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_POWER_OF_TWO
| SOIL_FLAG_MIPMAPS
//| SOIL_FLAG_COMPRESS_TO_DXT
);
time_me = clock() - time_me;
std::cout << "the load time was " << 0.001f * time_me << " seconds (warning: low resolution timer)" << std::endl;
// did I fail?
if( tex_ID < 1 )
{
output:
error "clock" was not declared in this scope