Shark.h
branchv_0
changeset 1 fb65455622b9
parent 0 bb715a82a8f1
child 2 3faef2f5128e
equal deleted inserted replaced
0:bb715a82a8f1 1:fb65455622b9
    32 #include "x11.h"
    32 #include "x11.h"
    33 #include "opengl.h"
    33 #include "opengl.h"
    34 #include "EPoll.h"
    34 #include "EPoll.h"
    35 #include "Logger.h"
    35 #include "Logger.h"
    36 #include "MappedFile.h"
    36 #include "MappedFile.h"
       
    37 #include "ImageLoader.h"
    37 
    38 
    38 class Shark {
    39 class Shark {
    39 private:
    40 private:
    40 
    41 
    41 	struct {
    42 	struct {
   153 			updateCameraFrontAndUp();
   154 			updateCameraFrontAndUp();
   154 		}
   155 		}
   155 
   156 
   156 	} initialCtx, ctx;
   157 	} initialCtx, ctx;
   157 
   158 
   158 	const struct {
   159 	class Texture {
   159 		int width = 640;
   160 	public:
   160 		int height = 398;
   161 		GLuint id;
   161 		GLfloat ratio = (GLfloat) width / (GLfloat) height;
   162 		std::string fileName;
   162 	} TEX;
   163 		int width;
       
   164 		int height;
       
   165 
       
   166 		GLfloat getRatio() const {
       
   167 			return (GLfloat) width / (GLfloat) height;
       
   168 		}
       
   169 	};
       
   170 	
       
   171 	ImageLoader imageLoader;
       
   172 	
       
   173 	std::vector<Texture> textures;
   163 
   174 
   164 	Configuration cfg;
   175 	Configuration cfg;
   165 	std::ostream& logOutput = std::cerr;
   176 	std::ostream& logOutput = std::cerr;
   166 
   177 
   167 	void renderImmediateMode();
   178 	void renderImmediateMode();
   168 	void runShaders(GLuint program);
   179 	void runShaders(GLuint program);
   169 	Window getRootWindow(Window defaultValue);
   180 	Window getRootWindow(Window defaultValue);
   170 	void log(LogLevel level, std::string message);
   181 	void log(LogLevel level, std::string message);
   171 	int setNonBlocking(int fd);
   182 	int setNonBlocking(int fd);
   172 	void loadVertices();
   183 	void loadVertices();
   173 	GLuint loadTexture(const std::string& fileName, int width, int height);
   184 	Texture loadTexture(const std::string& fileName);
   174 	void loadTextures(GLuint shaderProgram);
   185 	void loadTextures(GLuint shaderProgram);
   175 	GLuint loadShaders();
   186 	GLuint loadShaders();
   176 public:
   187 public:
   177 	Shark(const Configuration& cfg);
   188 	Shark(const Configuration& cfg);
   178 	virtual ~Shark();
   189 	virtual ~Shark();