Improved SLK_color(.c), SLK_render(.c) and renamed to SoftLK
Improved code quality Added comments
This commit is contained in:
parent
506f2e8a58
commit
90f39d92bc
|
@ -8,7 +8,7 @@ modification, are permitted provided that the following conditions are met:
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
10
README.md
10
README.md
|
@ -1,4 +1,4 @@
|
|||
# SLK Engine
|
||||
# SoftLK Engine
|
||||
|
||||
A software accelerated engine that uses OpenGL to bring the graphics to the screen. It's made for low resolutions (eg. 256x240), but can be used for higher resolutions, too.
|
||||
|
||||
|
@ -12,11 +12,11 @@ A software accelerated engine that uses OpenGL to bring the graphics to the scre
|
|||
|
||||
## License
|
||||
|
||||
SLK is free Software (as in freedom) and is released under the 3-clause BSD license, see LICENSE.md for details. Most of the examples are released under the same license, unless noted otherwise of course.
|
||||
SoftLK is free Software (as in freedom) and is released under the 3-clause BSD license, see LICENSE.md for details. Most of the examples are released under the same license, unless noted otherwise of course.
|
||||
|
||||
## Using SLK
|
||||
## Using SoftLK
|
||||
|
||||
To use SLK you need to have the following libraries installed:
|
||||
To use SoftLK you need to have the following libraries installed:
|
||||
|
||||
* [SDL 2](https://www.libsdl.org/)
|
||||
|
||||
|
@ -30,7 +30,7 @@ Linux:
|
|||
|
||||
## Plattforms
|
||||
|
||||
SLK has been tested and is working on the following plattforms/os:
|
||||
SoftLK has been tested and is working on the following plattforms/os:
|
||||
|
||||
* Void GNU/Linux, amd64: [Enter the void](https://voidlinux.org/)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
@ -25,8 +25,29 @@
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../../include/SLK/SLK.h"
|
||||
//External includes
|
||||
//-------------------------------------
|
||||
|
||||
//Internal includes
|
||||
#include "../../include/SLK/SLK_types.h"
|
||||
#include "../../include/SLK/SLK_functions.h"
|
||||
//-------------------------------------
|
||||
//
|
||||
//#defines
|
||||
//-------------------------------------
|
||||
|
||||
//Typedefs
|
||||
//-------------------------------------
|
||||
|
||||
//Variables
|
||||
//-------------------------------------
|
||||
|
||||
//Function prototypes
|
||||
//-------------------------------------
|
||||
|
||||
//Function implementations
|
||||
|
||||
//Creates a SLK_Color struct from 4 unsigned 8bit ints.
|
||||
SLK_Color SLK_color_create(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
{
|
||||
SLK_Color c;
|
||||
|
@ -38,6 +59,10 @@ SLK_Color SLK_color_create(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
|||
return c;
|
||||
}
|
||||
|
||||
//Creates a SLK_Paxel struct from 2 unsigned 8bit ints.
|
||||
//index is the index of the currently used palette.
|
||||
//mask is wether the paxel is supposed to be drawn:
|
||||
//SLK_OPAQUE for drawing, SLK_TRANSPARENT for skipping.
|
||||
SLK_Paxel SLK_color_create_paxel(uint8_t index, uint8_t mask)
|
||||
{
|
||||
SLK_Paxel p;
|
||||
|
@ -46,3 +71,4 @@ SLK_Paxel SLK_color_create_paxel(uint8_t index, uint8_t mask)
|
|||
|
||||
return p;
|
||||
}
|
||||
//-------------------------------------
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
@ -25,10 +25,33 @@
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../../include/SLK/SLK.h"
|
||||
//External includes
|
||||
#include <SDL2/SDL.h>
|
||||
#include "../../include/glad/glad.h"
|
||||
//-------------------------------------
|
||||
|
||||
//Internal includes
|
||||
#include "../../include/SLK/SLK_types.h"
|
||||
#include "../../include/SLK/SLK_functions.h"
|
||||
#include "SLK_variables.h"
|
||||
//-------------------------------------
|
||||
|
||||
//#defines
|
||||
//-------------------------------------
|
||||
|
||||
//Typedefs
|
||||
//-------------------------------------
|
||||
|
||||
//Variables
|
||||
//-------------------------------------
|
||||
|
||||
//Function prototypes
|
||||
//-------------------------------------
|
||||
|
||||
//Function implementations
|
||||
|
||||
//Performs some necessary OpenGL function calls.
|
||||
//Gets called by SLK_setup, don't call by yourself.
|
||||
void SLK_render_init()
|
||||
{
|
||||
printf("OpenGL loaded\n");
|
||||
|
@ -37,8 +60,6 @@ void SLK_render_init()
|
|||
printf("Renderer: %s\n",glGetString(GL_RENDERER));
|
||||
printf("Version: %s\n",glGetString(GL_VERSION));
|
||||
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
//glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glViewport(0,0,screen_width,screen_height);
|
||||
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
||||
|
@ -48,6 +69,8 @@ void SLK_render_init()
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
//Clears the window and redraws the scene.
|
||||
//Drawing is performed from back to front, layer 0 is always drawn last.
|
||||
void SLK_render_update()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -102,3 +125,4 @@ void SLK_render_update()
|
|||
|
||||
SDL_GL_SwapWindow(sdl_window);
|
||||
}
|
||||
//-------------------------------------
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SLK nor the
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
/*
|
||||
(C) 2019 Lukas Holzbeierlein (Captain4LK)
|
||||
Copyright (c) 2020, Lukas Holzbeierlein (Captain4LK)
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of SoftLK nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL CAPTAIN4LK BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SLK_VARIABLES_H_
|
||||
|
|
Loading…
Reference in a new issue