mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
use CLineReader instead of fgets, also delete program at destruct
This commit is contained in:
parent
b6e4b4b4a6
commit
f48e186bfd
|
@ -1,5 +1,5 @@
|
|||
#include "opengl_sl.h"
|
||||
#include <base/system.h>
|
||||
#include <engine/shared/linereader.h>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
@ -7,14 +7,18 @@
|
|||
bool CGLSL::LoadShader(const char* pFile, int Type) {
|
||||
if (m_IsLoaded) return true;
|
||||
IOHANDLE f;
|
||||
//support read text in system.h/cpp
|
||||
f = (IOHANDLE)fopen(pFile, "rt");
|
||||
f = io_open(pFile, IOFLAG_READ);
|
||||
|
||||
std::vector<std::string> Lines;
|
||||
char buff[500];
|
||||
if (f) {
|
||||
//support fgets in system.h/cpp
|
||||
while (fgets(buff, 500, (FILE*)f)) Lines.push_back(buff);
|
||||
CLineReader LineReader;
|
||||
LineReader.Init(f);
|
||||
char* ReadLine = NULL;
|
||||
while ((ReadLine = LineReader.Get())) {
|
||||
Lines.push_back(ReadLine);
|
||||
Lines.back().append("\r\n");
|
||||
}
|
||||
io_close(f);
|
||||
|
||||
const char** ShaderCode = new const char*[Lines.size()];
|
||||
|
@ -73,3 +77,7 @@ GLuint CGLSL::GetShaderID() {
|
|||
CGLSL::CGLSL(){
|
||||
m_IsLoaded = false;
|
||||
}
|
||||
|
||||
CGLSL::~CGLSL(){
|
||||
DeleteShader();
|
||||
}
|
|
@ -11,6 +11,7 @@ public:
|
|||
GLuint GetShaderID();
|
||||
|
||||
CGLSL();
|
||||
virtual ~CGLSL();
|
||||
private:
|
||||
GLuint m_ShaderID;
|
||||
int m_Type;
|
||||
|
|
Loading…
Reference in a new issue