- restored to space texture
- invert option added to gl texture load
This commit is contained in:
parent
b2f5f56063
commit
eb519bdf93
|
@ -67,16 +67,16 @@ int link_shader(GLuint program)
|
|||
return 0;
|
||||
}
|
||||
|
||||
GLuint get_gl_texture_from_surface(SDL_Surface *surface, GLint mipmap_filter)
|
||||
GLuint get_gl_texture_from_surface(SDL_Surface *surface, GLint mipmap_filter, bool invert = false)
|
||||
{
|
||||
GLuint id;
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &id);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
GLenum format;
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
format = GL_BGRA;
|
||||
format = invert ? GL_RGBA : GL_BGRA;
|
||||
#else
|
||||
format = GL_RGBA;
|
||||
format = invert ? GL_BGRA : GL_RGBA;
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, format,
|
||||
GL_UNSIGNED_BYTE, surface->pixels);
|
||||
|
@ -143,8 +143,8 @@ void Mushroom::update()
|
|||
|
||||
Demo::Demo()
|
||||
{
|
||||
// Mix_Music *music = Mix_LoadMUS("resource/Field.mp3");
|
||||
Mix_Music *music = Mix_LoadMUS("/home/frank/WATERMELON-clean.mp3");
|
||||
Mix_Music *music = Mix_LoadMUS("resource/Field.mp3");
|
||||
// Mix_Music *music = Mix_LoadMUS("/home/frank/WATERMELON-clean.mp3");
|
||||
Mix_PlayMusic(music, -1);
|
||||
load_gl_context();
|
||||
delegate.subscribe(&Demo::respond, this);
|
||||
|
@ -222,18 +222,18 @@ void Demo::load_gl_context()
|
|||
view = glm::lookAt(
|
||||
glm::vec3(4, 3, 3), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
|
||||
SDL_Surface* surface = zoomSurface(
|
||||
rotateSurface90Degrees(IMG_Load("resource/tile.png"), 2), 1, -1, SMOOTHING_OFF);
|
||||
rotateSurface90Degrees(IMG_Load("resource/tile.png"), 2), -1, 1, SMOOTHING_OFF);
|
||||
SDL_Log("tile.png bytes per pixel %i", surface->format->BytesPerPixel);
|
||||
space_texture_id = get_gl_texture_from_surface(surface, GL_LINEAR);
|
||||
space_texture_id = get_gl_texture_from_surface(surface, GL_LINEAR, true);
|
||||
SDL_FreeSurface(surface);
|
||||
std::vector<fs::path> paths = sfw::glob("/home/frank/projects/public/games/rov/face03/[0-9]+\\-.+\\.png");
|
||||
for (fs::path path : paths)
|
||||
{
|
||||
surface = zoomSurface(rotateSurface90Degrees(IMG_Load(path.c_str()), 2), -1, 1, SMOOTHING_OFF);
|
||||
SDL_Log("loading %s", path.c_str());
|
||||
face_ids.push_back(get_gl_texture_from_surface(surface, GL_LINEAR));
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
// std::vector<fs::path> paths = sfw::glob("/home/frank/projects/public/games/buddi/local/face03/[0-9]+\\-.+\\.png");
|
||||
// for (fs::path path : paths)
|
||||
// {
|
||||
// surface = zoomSurface(rotateSurface90Degrees(IMG_Load(path.c_str()), 2), -1, 1, SMOOTHING_OFF);
|
||||
// SDL_Log("loading %s", path.c_str());
|
||||
// face_ids.push_back(get_gl_texture_from_surface(surface, GL_LINEAR));
|
||||
// SDL_FreeSurface(surface);
|
||||
// }
|
||||
std::array<glm::vec2, 6> framerate_indicator_uv = {
|
||||
{
|
||||
{0, 1}, {1, 1}, {0, 0},
|
||||
|
@ -439,11 +439,13 @@ void Demo::update()
|
|||
glEnableVertexAttribArray(1);
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib3f(2, 1, 1, 1);
|
||||
for (int ii = 0; ii < 6; ii++)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, face_ids[ii]);
|
||||
glDrawArrays(GL_TRIANGLES, ii * 6, 6);
|
||||
}
|
||||
// for (int ii = 0; ii < 6; ii++)
|
||||
// {
|
||||
// glBindTexture(GL_TEXTURE_2D, face_ids[ii]);
|
||||
// glDrawArrays(GL_TRIANGLES, ii * 6, 6);
|
||||
// }
|
||||
glBindTexture(GL_TEXTURE_2D, space_texture_id);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
//glFlush();
|
||||
SDL_GL_SwapWindow(window);
|
||||
// if (amount_rotated < 3.14f * 2)
|
||||
|
|
Loading…
Reference in New Issue