Animated pictures; FPS counter

This commit is contained in:
Caesar2011
2016-09-13 16:11:01 +02:00
parent f99b8dab83
commit 449060a463
17 changed files with 220 additions and 57 deletions

View File

@@ -1,11 +1,10 @@
// http://stackoverflow.com/questions/6005076/building-glew-on-windows-with-mingw
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <SDL2/SDL.h>
#include <fstream>
#include <stdexcept>
#include <dirent.h>
#include "loaders.h"
int main(int argc, char* args[]) {
@@ -23,8 +22,8 @@ int main(int argc, char* args[]) {
return 1;
}
/* Create a windowed mode window and its OpenGL context */
glfwSetWindowSizeLimits(window, 640, 480, 640, 480);
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
glfwSetWindowSizeLimits(window, 640, 480, 640, 480);
if (!window) {
glfwTerminate();
return 1;
@@ -89,16 +88,23 @@ int main(int argc, char* args[]) {
glGenFramebuffers(1, &FramebufferName);
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
int lenTexFG = 10;
GLint texFGs[lenTexFG];
char buffer[50];
texBG = LoadTexture("../img/backgrounds/sky.jpg",&textw2,&texth2);
texFG = LoadTexture("../img/tests/flieger.jpg",&textw,&texth);
printf("Tex1: %d\n", texFG);
for (int i=0; i<lenTexFG; i++) {
snprintf(buffer, sizeof(buffer), "../img/foregrounds/surfing/%d.jpg", i);
texFGs[i] = LoadTexture(buffer,&textw,&texth);
}
texFG = LoadTexture("../img/foregrounds/surfing/0.jpg",&textw,&texth);
glfwSetWindowSize(window, textw, texth);
glViewport(0, 0, textw, texth);
glfwSetWindowSizeLimits(window, textw, texth, textw, texth);
// The texture we're going to render to
GLuint renderedTexture;
glGenTextures(1, &renderedTexture);
@@ -130,8 +136,6 @@ int main(int argc, char* args[]) {
GLint textureLocFore = glGetUniformLocation(programRefineID, "foreground");
GLint textureLocBack = glGetUniformLocation(programRefineID, "background");
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texFG);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texBG);
glActiveTexture(GL_TEXTURE2);
@@ -148,11 +152,31 @@ int main(int argc, char* args[]) {
printf("Height: %f\n", 1.0f/texth);
int loopNumber = -1;
double lastTime = glfwGetTime();
int nbFrames = 0;
// INIT END
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window)) {
/* Render here */
loopNumber++;
if (loopNumber >= lenTexFG) {
loopNumber = 0;
}
// Measure speed
double currentTime = glfwGetTime();
nbFrames++;
if ( currentTime - lastTime >= 1.0 ){ // If last prinf() was more than 1 sec ago
// printf and reset timer
printf("%f ms/frame\n", 1000.0/double(nbFrames));
nbFrames = 0;
lastTime += 1.0;
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texFGs[loopNumber]);
// Render to our framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
//glBindFramebuffer(GL_FRAMEBUFFER, 0);

View File

@@ -2,15 +2,16 @@
1385320478 source:d:\owncloud\documents\programmierung\cpp\opengl-test-two\main.cpp
<iostream>
1473703631 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
1473775715 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\main.cpp
<GL/glew.h>
<GLFW/glfw3.h>
<SDL2/SDL.h>
<fstream>
<stdexcept>
<dirent.h>
"loaders.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\glfw\glfw3.h
<stddef.h>
<stdint.h>
<OpenGL/gl3.h>
@@ -31,7 +32,7 @@
<GL/glext.h>
<GL/glu.h>
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl.h
"SDL_main.h"
"SDL_stdinc.h"
"SDL_assert.h"
@@ -62,12 +63,12 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_main.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_stdinc.h
"SDL_config.h"
<sys/types.h>
<stdio.h>
@@ -96,34 +97,34 @@
<stdlib.h>
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_config.h
"SDL_platform.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_platform.h
"AvailabilityMacros.h"
"TargetConditionals.h"
<winapifamily.h>
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\begin_code.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\begin_code.h
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\close_code.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\close_code.h
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_assert.h
"SDL_config.h"
"begin_code.h"
<signal.h>
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_atomic.h
"SDL_stdinc.h"
"SDL_platform.h"
"begin_code.h"
<mbarrier.h>
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_audio.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_endian.h"
@@ -133,24 +134,24 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_error.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_endian.h
"SDL_stdinc.h"
<endian.h>
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mutex.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_thread.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_atomic.h"
@@ -159,18 +160,18 @@
<process.h>
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rwops.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_clipboard.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_cpuinfo.h
"SDL_stdinc.h"
<intrin.h>
<intrin.h>
@@ -182,7 +183,7 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_events.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
@@ -196,7 +197,7 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_video.h
"SDL_stdinc.h"
"SDL_pixels.h"
"SDL_rect.h"
@@ -204,12 +205,12 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_pixels.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_rect.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_pixels.h"
@@ -217,7 +218,7 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_surface.h
"SDL_stdinc.h"
"SDL_pixels.h"
"SDL_rect.h"
@@ -226,11 +227,11 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_blendmode.h
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keyboard.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_keycode.h"
@@ -238,27 +239,27 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_keycode.h
"SDL_stdinc.h"
"SDL_scancode.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_scancode.h
"SDL_stdinc.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_mouse.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_joystick.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gamecontroller.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_rwops.h"
@@ -266,11 +267,11 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_quit.h
"SDL_stdinc.h"
"SDL_error.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_gesture.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
@@ -278,60 +279,60 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_touch.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_filesystem.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_haptic.h
"SDL_stdinc.h"
"SDL_error.h"
"SDL_joystick.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_hints.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_loadso.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_log.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_messagebox.h
"SDL_stdinc.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_power.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_render.h
"SDL_stdinc.h"
"SDL_rect.h"
"SDL_video.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_system.h
"SDL_stdinc.h"
"SDL_keyboard.h"
"SDL_render.h"
@@ -339,24 +340,24 @@
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_timer.h
"SDL_stdinc.h"
"SDL_error.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_version.h
"SDL_stdinc.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\sdl2\sdl_image.h
"SDL.h"
"SDL_version.h"
"begin_code.h"
"close_code.h"
1473015242 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
1473011642 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\gl\glew.h
<stddef.h>
<inttypes.h>
<stdint.h>
@@ -739,13 +740,13 @@
<vector>
"loaders.h"
1473669189 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\src\loaders.cpp
1473700459 source:d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\src\loaders.cpp
<SDL2/SDL.h>
<SDL2/SDL_image.h>
<fstream>
<vector>
"loaders.h"
1473669189 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\loaders.h
1473700459 d:\owncloud\documents\programmierung\cpp\imanox-chroma-matting\opengl-test-two\include\loaders.h
<GL/glew.h>