Browse Source

增加文件加载功能

master
blobt 4 years ago
parent
commit
238d86fbc3
  1. 21
      main.cpp
  2. 2
      utils.h

21
main.cpp

@ -1,7 +1,28 @@
#include "ggl.h" #include "ggl.h"
#include "scene.h" #include "scene.h"
#include "utils.h"
#pragma comment(lib, "opengl32.lib") #pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glew32.lib") #pragma comment(lib, "glew32.lib")
unsigned char * LoadFileContent(const char *path, int &filesize) {
unsigned char*fileContent = nullptr;
filesize = 0;
FILE*pFile = fopen(path, "rb");
if (pFile) {
fseek(pFile, 0, SEEK_END);
int nLen = ftell(pFile);
if (nLen > 0) {
rewind(pFile);
fileContent = new unsigned char[nLen + 1];
fread(fileContent, sizeof(unsigned char), nLen, pFile);
fileContent[nLen] = '\0';
filesize = nLen;
}
fclose(pFile);
}
return fileContent;
}
/** /**
*ÏûÏ¢´¦Àíº¯Êý *ÏûÏ¢´¦Àíº¯Êý
*/ */

2
utils.h

@ -0,0 +1,2 @@
#pragma once
unsigned char * LoadFileContent(const char*path, int&filesize);
Loading…
Cancel
Save