glstuff

experiments with opengl2/ogles2/sdl
git clone http://frotz.net/git/glstuff.git
Log | Files | Refs

app.h (1337B)


      1 /* Copyright 2013 Brian Swetland <swetland@frotz.net>
      2  *
      3  * Licensed under the Apache License, Version 2.0 (the "License");
      4  * you may not use this file except in compliance with the License.
      5  * You may obtain a copy of the License at
      6  *
      7  *     http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software
     10  * distributed under the License is distributed on an "AS IS" BASIS,
     11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12  * See the License for the specific language governing permissions and
     13  * limitations under the License.
     14  */
     15 
     16 #ifndef _APP_H_
     17 #define _APP_H_
     18 
     19 #include "opengl.h"
     20 
     21 class App {
     22 public:
     23 	App();
     24 	virtual ~App();
     25 
     26 	// configuration options
     27 	void setSize(int w, int h);
     28 
     29 	// parse commandline for configuration overrides
     30 	void setOptions(int argc, char **argv);
     31 
     32 	// state query
     33 	int fps(void) { return _fps; };
     34 	int width(void) { return _width; };
     35 	int height(void) { return _height; };
     36 	float aspect(void) { return ((float) _width) / ((float) _height); };
     37 	int keydown(int code) { return _keystate[code]; }
     38 
     39 	int run(void);
     40 
     41 	virtual int init(void) = 0;
     42 	virtual int render(void) = 0;
     43 	virtual void key(int code) {};
     44 
     45 private:
     46 	int _width, _height;
     47 	int _vsync;
     48 	int _fps;
     49 
     50 	char _keystate[512];
     51 	void handleEvents(void);
     52 };
     53 
     54 #endif