- S'ha llevat la carpeta ".vscode" i la merdeta que estava dins

- Afegit mòdul jshader.
- Afegit shader al arxiu de dades
- Actualitzat makefile per a la ocasió
- Afegit lo de afegir caràcter 0 al final si es vol en jfile
- Llevat el flag d'executable que tenien tots els arxius, jo que se perqué
This commit is contained in:
2024-06-28 11:12:50 +02:00
parent 7532cac83f
commit 7e5318c501
40 changed files with 300 additions and 286 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ trick.ini
project.xcworkspace/
xcuserdata/
*.opk
.vscode/*

View File

@@ -1 +0,0 @@
{"buildTargets":["all","clean","debug"],"launchTargets":["/Users/raimonzamora/dev/proj/aee>aee()"],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":["/Users/raimonzamora/dev/proj/aee"],"compilerArgs":["-lSDL2","-lSDL2_mixer","-o","aee","-lSDL2","-lSDL2_mixer","-o","aee","-lSDL2","-lSDL2_mixer","-o","aee","-g","-lSDL2","-lSDL2_mixer","-o","aee"],"compilerPath":"/usr/bin/g++","standard":"c++11","windowsSdkVersion":""},"fileIndex":[["/Users/raimonzamora/dev/proj/aee/*.cpp",{"uri":{"$mid":1,"fsPath":"/Users/raimonzamora/dev/proj/aee/*.cpp","path":"/Users/raimonzamora/dev/proj/aee/*.cpp","scheme":"file"},"configuration":{"defines":[],"standard":"c++11","includePath":[],"forcedInclude":[],"intelliSenseMode":"gcc-x64","compilerPath":"/usr/bin/g++","compilerArgs":["-g","-lSDL2","-lSDL2_mixer","-o","aee"],"windowsSdkVersion":""}}]]}}

5
.vscode/dryrun.log vendored
View File

@@ -1,5 +0,0 @@
make debug --dry-run --keep-going --print-directory
make: Entering directory `/Users/raimonzamora/dev/proj/aee'
g++ *.cpp -g -std=c++11 -lSDL2 -lSDL2_mixer -o aee
make: Leaving directory `/Users/raimonzamora/dev/proj/aee'

10
.vscode/settings.json vendored
View File

@@ -1,10 +0,0 @@
{
"makefile.extensionOutputFolder": "./.vscode",
"makefile.launchConfigurations": [
{
"cwd": "/Users/raimonzamora/dev/proj/aee",
"binaryPath": "/Users/raimonzamora/dev/proj/aee/aee",
"binaryArgs": []
}
]
}

257
.vscode/targets.log vendored
View File

@@ -1,257 +0,0 @@
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
# GNU Make 3.81
# Copyright (C) 2006 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# This program built for i386-apple-darwin11.3.0
# Make data base, printed on Wed Sep 1 20:00:35 2021
# Variables
# automatic
<D = $(patsubst %/,%,$(dir $<))
# automatic
?F = $(notdir $?)
# environment
ELECTRON_NO_ATTACH_CONSOLE = 1
# environment
VSCODE_LOG_NATIVE = false
# makefile (from `makefile', line 1)
TARGET = aee
# automatic
?D = $(patsubst %/,%,$(dir $?))
# automatic
@D = $(patsubst %/,%,$(dir $@))
# automatic
@F = $(notdir $@)
# makefile
CURDIR := /Users/raimonzamora/dev/proj/aee
# makefile
SHELL = /bin/sh
# environment
VSCODE_NLS_CONFIG = {"locale":"es","availableLanguages":{},"_languagePackSupport":true}
# environment
_ = /usr/bin/make
# makefile (from `makefile', line 1)
MAKEFILE_LIST := makefile
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
__CFBundleIdentifier = com.apple.Terminal
# environment
VSCODE_IPC_HOOK_EXTHOST = /var/folders/jb/tqpp4m1j50d3gjsyry8hwypm0000gn/T/vscode-ipc-95aab8ae-a614-48ae-9f29-d3d97e7c17ff.sock
# environment
VSCODE_CWD = /Users/raimonzamora/dev/proj/aee
# environment
PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/raimonzamora/Library/Python/3.7/bin:/Library/Apple/usr/bin:/usr/local/CrossPack-AVR/bin
# environment
VSCODE_LOG_STACK = false
# environment
ELECTRON_RUN_AS_NODE = 1
# default
.FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink
# environment
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.PIAYv9VDcK/Listeners
# automatic
%F = $(notdir $%)
# environment
VSCODE_PIPE_LOGGING = true
# environment
PWD = /Users/raimonzamora/dev/proj/aee
# environment
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
# environment
VSCODE_AMD_ENTRYPOINT = vs/workbench/services/extensions/node/extensionHostProcess
# environment
HOME = /Users/raimonzamora
# default
MAKEFILEPATH = $(shell /usr/bin/xcode-select -print-path 2>/dev/null || echo /Developer)/Makefiles
# environment
VSCODE_CLI = 1
# environment
VSCODE_CODE_CACHE_PATH = /Users/raimonzamora/Library/Application Support/Code/CachedData/3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
# environment
LOGNAME = raimonzamora
# environment
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = true
# environment
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
# automatic
^D = $(patsubst %/,%,$(dir $^))
# environment
XPC_FLAGS = 0x0
# default
MAKE = $(MAKE_COMMAND)
# default
MAKECMDGOALS := all
# environment
SHLVL = 3
# default
MAKE_VERSION := 3.81
# environment
USER = raimonzamora
# makefile
.DEFAULT_GOAL := all
# environment
TERM_SESSION_ID = 765A9C16-03F5-46AC-A0BE-B297B910335E
# automatic
%D = $(patsubst %/,%,$(dir $%))
# default
MAKE_COMMAND := /Library/Developer/CommandLineTools/usr/bin/make
# environment
TERM_PROGRAM = Apple_Terminal
# default
.VARIABLES :=
# environment
TMPDIR = /var/folders/jb/tqpp4m1j50d3gjsyry8hwypm0000gn/T/
# automatic
*F = $(notdir $*)
# environment
VSCODE_IPC_HOOK = /Users/raimonzamora/Library/Application Support/Code/1.59.1-main.sock
# makefile
MAKEFLAGS = Rrqp
# environment
MFLAGS = -Rrqp
# automatic
*D = $(patsubst %/,%,$(dir $*))
# environment
TERM_PROGRAM_VERSION = 440
# environment
XPC_SERVICE_NAME = 0
# automatic
+D = $(patsubst %/,%,$(dir $+))
# automatic
+F = $(notdir $+)
# environment
__CF_USER_TEXT_ENCODING = 0x1F5:0x0:0x8
# environment
COMMAND_MODE = unix2003
# default
MAKEFILES :=
# environment
VSCODE_BROWSER_CODE_LOADING = bypassHeatCheck
# automatic
<F = $(notdir $<)
# environment
LC_ALL = C
# automatic
^F = $(notdir $^)
# default
SUFFIXES :=
# default
.INCLUDE_DIRS = /usr/local/include
# environment
MAKELEVEL := 0
# environment
LANG = C
# environment
TERM = xterm-256color
# environment
VSCODE_PID = 65860
# variable set hash-table stats:
# Load=70/1024=7%, Rehash=0, Collisions=1/97=1%
# Pattern-specific Variable Values
# No pattern-specific variable values.
# Directories
# . (device 16777220, inode 8187547): 48 files, no impossibilities.
# 48 files, no impossibilities in 1 directories.
# Implicit Rules
# No implicit rules.
# Files
all:
# Command-line target.
# Implicit rule search has not been done.
# Implicit/static pattern stem: `'
# File does not exist.
# File has been updated.
# Needs to be updated (-q is set).
# automatic
# @ := all
# automatic
# % :=
# automatic
# * :=
# automatic
# + :=
# automatic
# | :=
# automatic
# < :=
# automatic
# ^ :=
# automatic
# ? :=
# variable set hash-table stats:
# Load=8/32=25%, Rehash=0, Collisions=1/11=9%
# commands to execute (from `makefile', line 3):
g++ *.cpp -std=c++11 -lSDL2 -lSDL2_mixer -o $(TARGET)
# Not a target:
.SUFFIXES:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
debug:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (from `makefile', line 6):
g++ *.cpp -g -std=c++11 -lSDL2 -lSDL2_mixer -o $(TARGET)
# Not a target:
makefile:
# Implicit rule search has been done.
# Last modified 2021-09-01 20:00:32
# File has been updated.
# Successfully updated.
# variable set hash-table stats:
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
# Not a target:
.DEFAULT:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
clean:
# Implicit rule search has not been done.
# Modification time never checked.
# File has not been updated.
# commands to execute (from `makefile', line 9):
rm -rf ./$(TARGET)
# files hash-table stats:
# Load=6/1024=1%, Rehash=0, Collisions=0/20=0%
# VPATH Search Paths
# No `vpath' search paths.
# No general (`VPATH' variable) search path.
# # of strings in strcache: 1
# # of strcache buffers: 1
# strcache size: total = 4096 / max = 4096 / min = 4096 / avg = 4096
# strcache free: total = 4087 / max = 4087 / min = 4087 / avg = 4087
# Finished Make data base on Wed Sep 1 20:00:35 2021

0
bola.cpp Executable file → Normal file
View File

0
bola.h Executable file → Normal file
View File

BIN
data.jrf Executable file → Normal file

Binary file not shown.

0
engendro.cpp Executable file → Normal file
View File

0
engendro.h Executable file → Normal file
View File

0
gcwmake Executable file → Normal file
View File

0
info.h Executable file → Normal file
View File

22
jdraw8.cpp Executable file → Normal file
View File

@@ -2,13 +2,14 @@
#include "jfile.h"
#include <fstream>
#include "gif.h"
#include "jshader.h"
#ifdef GCWZERO
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#else
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_WIDTH 960
#define SCREEN_HEIGHT 720
#endif
JD8_Surface screen = NULL;
@@ -25,6 +26,7 @@ char *fps = (char *)malloc(10);
SDL_Window* sdlWindow = NULL;
SDL_Renderer* sdlRenderer = NULL;
SDL_Texture* sdlTexture = NULL;
SDL_Texture* backBuffer = NULL;
void JD8_Init(const char *title) {
screen = (JD8_Surface)calloc( 1, 64000 );
@@ -32,10 +34,18 @@ void JD8_Init(const char *title) {
pixel_data = (Uint32*)calloc(1, 320 * 200 * 4); // 1048576 );
sdlWindow = SDL_CreateWindow( title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
backBuffer = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 320, 200);
int filesize = 0;
char *buffer = JF_GetBufferFromResource("crtpi.glsl", filesize, true);
shader::init(sdlWindow, backBuffer, buffer);
free(buffer);
}
void JD8_Quit() {
@@ -180,8 +190,10 @@ void JD8_Flip() {
}
}
SDL_UpdateTexture(sdlTexture, NULL, pixel_data, 320 * sizeof(Uint32));
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, &rect);
SDL_RenderPresent(sdlRenderer);
SDL_SetRenderTarget(sdlRenderer, backBuffer);
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
shader::render();
//SDL_RenderPresent(sdlRenderer);
}
void JD8_FreeSurface(JD8_Surface surface) {

0
jdraw8.h Executable file → Normal file
View File

7
jfile.cpp Executable file → Normal file
View File

@@ -56,7 +56,7 @@ void JF_GetDataFile() {
fd.close();
}
char *JF_GetBufferFromResource(const char *resourcename, int& filesize) {
char *JF_GetBufferFromResource(const char *resourcename, int& filesize, const bool addZero) {
if( data_file == NULL ) {
JF_GetDataFile();
@@ -85,11 +85,12 @@ char *JF_GetBufferFromResource(const char *resourcename, int& filesize) {
fd.seekg( data_file->index.file_info[count].offset );
char* buffer = (char*)malloc( filesize );
char* buffer = (char*)malloc( filesize + (addZero ? 1 : 0) );
fd.read( buffer, filesize );
fd.close();
if (addZero) buffer[filesize] = 0;
return buffer;
}

2
jfile.h Executable file → Normal file
View File

@@ -2,6 +2,6 @@
void JF_SetResourceFile(const char *p_resourceFileName);
char *JF_GetBufferFromResource(const char *resourcename, int& filesize);
char *JF_GetBufferFromResource(const char *resourcename, int& filesize, const bool addZero=false);
void JF_Quit();

0
jgame.cpp Executable file → Normal file
View File

0
jgame.h Executable file → Normal file
View File

0
jinput.cpp Executable file → Normal file
View File

0
jinput.h Executable file → Normal file
View File

229
jshader.cpp Normal file
View File

@@ -0,0 +1,229 @@
#include "jshader.h"
#include <iostream>
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
#include <OpenGL/OpenGL.h>
#if ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
#include <OpenGL/gl3.h>
#else
#include <OpenGL/gl.h>
#endif //!ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
#else
#include <SDL2/SDL_opengl.h>
#include <SDL2/SDL_opengl_glext.h>
#endif
namespace shader
{
SDL_Window *win = nullptr;
SDL_Renderer *renderer = nullptr;
GLuint programId = 0;
SDL_Texture* backBuffer = nullptr;
SDL_Point win_size = {640, 480};
SDL_Point tex_size = {320, 240};
bool usingOpenGL;
#ifndef __APPLE__
// I'm avoiding the use of GLEW or some extensions handler, but that
// doesn't mean you should...
PFNGLCREATESHADERPROC glCreateShader;
PFNGLSHADERSOURCEPROC glShaderSource;
PFNGLCOMPILESHADERPROC glCompileShader;
PFNGLGETSHADERIVPROC glGetShaderiv;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
PFNGLDELETESHADERPROC glDeleteShader;
PFNGLATTACHSHADERPROC glAttachShader;
PFNGLCREATEPROGRAMPROC glCreateProgram;
PFNGLLINKPROGRAMPROC glLinkProgram;
PFNGLVALIDATEPROGRAMPROC glValidateProgram;
PFNGLGETPROGRAMIVPROC glGetProgramiv;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLUSEPROGRAMPROC glUseProgram;
bool initGLExtensions() {
glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource");
glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader");
glGetShaderiv = (PFNGLGETSHADERIVPROC)SDL_GL_GetProcAddress("glGetShaderiv");
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)SDL_GL_GetProcAddress("glGetShaderInfoLog");
glDeleteShader = (PFNGLDELETESHADERPROC)SDL_GL_GetProcAddress("glDeleteShader");
glAttachShader = (PFNGLATTACHSHADERPROC)SDL_GL_GetProcAddress("glAttachShader");
glCreateProgram = (PFNGLCREATEPROGRAMPROC)SDL_GL_GetProcAddress("glCreateProgram");
glLinkProgram = (PFNGLLINKPROGRAMPROC)SDL_GL_GetProcAddress("glLinkProgram");
glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)SDL_GL_GetProcAddress("glValidateProgram");
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)SDL_GL_GetProcAddress("glGetProgramiv");
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)SDL_GL_GetProcAddress("glGetProgramInfoLog");
glUseProgram = (PFNGLUSEPROGRAMPROC)SDL_GL_GetProcAddress("glUseProgram");
return glCreateShader && glShaderSource && glCompileShader && glGetShaderiv &&
glGetShaderInfoLog && glDeleteShader && glAttachShader && glCreateProgram &&
glLinkProgram && glValidateProgram && glGetProgramiv && glGetProgramInfoLog &&
glUseProgram;
}
#endif
GLuint compileShader(const char* source, GLuint shaderType) {
// Create ID for shader
GLuint result = glCreateShader(shaderType);
// Add define depending on shader type
const char *sources[2] = { shaderType==GL_VERTEX_SHADER?"#define VERTEX\n":"#define FRAGMENT\n", source };
// Define shader text
glShaderSource(result, 2, sources, NULL);
// Compile shader
glCompileShader(result);
//Check vertex shader for errors
GLint shaderCompiled = GL_FALSE;
glGetShaderiv( result, GL_COMPILE_STATUS, &shaderCompiled );
if( shaderCompiled != GL_TRUE ) {
std::cout << "Error en la compilación: " << result << "!" << std::endl;
GLint logLength;
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
{
GLchar *log = (GLchar*)malloc(logLength);
glGetShaderInfoLog(result, logLength, &logLength, log);
std::cout << "Shader compile log:" << log << std::endl;
free(log);
}
glDeleteShader(result);
result = 0;
// } else {
// std::cout << "Shader compilado correctamente. Id = " << result << std::endl;
}
return result;
}
GLuint compileProgram(const char* vertexShaderSource, const char* fragmentShaderSource) {
GLuint programId = 0;
GLuint vtxShaderId, fragShaderId;
programId = glCreateProgram();
vtxShaderId = compileShader(vertexShaderSource, GL_VERTEX_SHADER);
fragShaderId = compileShader(fragmentShaderSource?fragmentShaderSource:vertexShaderSource, GL_FRAGMENT_SHADER);
if(vtxShaderId && fragShaderId) {
// Associate shader with program
glAttachShader(programId, vtxShaderId);
glAttachShader(programId, fragShaderId);
glLinkProgram(programId);
glValidateProgram(programId);
// Check the status of the compile/link
GLint logLen;
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
if(logLen > 0) {
char* log = (char*) malloc(logLen * sizeof(char));
// Show any errors as appropriate
glGetProgramInfoLog(programId, logLen, &logLen, log);
std::cout << "Prog Info Log: " << std::endl << log << std::endl;
free(log);
}
}
if(vtxShaderId) {
glDeleteShader(vtxShaderId);
}
if(fragShaderId) {
glDeleteShader(fragShaderId);
}
return programId;
}
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const char* vertexShader, const char* fragmentShader)
{
shader::win = win;
shader::renderer = SDL_GetRenderer(win);
shader::backBuffer = backBuffer;
SDL_GetWindowSize(win, &win_size.x, &win_size.y);
int access;
SDL_QueryTexture(backBuffer, NULL, &access, &tex_size.x, &tex_size.y);
if (access != SDL_TEXTUREACCESS_TARGET)
{
std::cout << "ERROR FATAL: La textura per al render ha de tindre SDL_TEXTUREACCESS_TARGET definit." << std::endl;
exit(1);
}
SDL_RendererInfo rendererInfo;
SDL_GetRendererInfo(renderer, &rendererInfo);
if(!strncmp(rendererInfo.name, "opengl", 6)) {
//std::cout << "Es OpenGL!" << std::endl;
#ifndef __APPLE__
if (!initGLExtensions()) {
std::cout << "WARNING: No s'han pogut inicialitzar les extensions d'OpenGL!" << std::endl;
usingOpenGL = false;
return false;
}
#endif
// Compilar el shader y dejarlo listo para usar.
programId = compileProgram(vertexShader, fragmentShader);
//std::cout << "programId = " << programId << std::endl;
} else {
std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl;
usingOpenGL = false;
return false;
}
usingOpenGL = true;
return true;
}
void render()
{
GLint oldProgramId;
// Guarrada para obtener el textureid (en driverdata->texture)
//Detach the texture
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_SetRenderTarget(renderer, NULL);
SDL_RenderClear(renderer);
if (usingOpenGL) {
SDL_GL_BindTexture(backBuffer, NULL, NULL);
if(programId != 0) {
glGetIntegerv(GL_CURRENT_PROGRAM,&oldProgramId);
glUseProgram(programId);
}
GLfloat minx, miny, maxx, maxy;
GLfloat minu, maxu, minv, maxv;
// Coordenadas de la ventana donde pintar.
minx = 0.0f;
miny = 0.0f;
maxx = tex_size.x;
maxy = tex_size.y;
minu = 0.0f;
maxu = 1.0f;
minv = 0.0f;
maxv = 1.0f;
glViewport(0, 0, win_size.x, win_size.y);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(minu, minv);
glVertex2f(minx, miny);
glTexCoord2f(maxu, minv);
glVertex2f(maxx, miny);
glTexCoord2f(minu, maxv);
glVertex2f(minx, maxy);
glTexCoord2f(maxu, maxv);
glVertex2f(maxx, maxy);
glEnd();
SDL_GL_SwapWindow(win);
if(programId != 0) {
glUseProgram(oldProgramId);
}
} else {
SDL_RenderCopy(renderer, backBuffer, NULL, NULL);
SDL_RenderPresent(renderer);
}
}
}

44
jshader.h Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
#include <SDL2/SDL.h>
// TIPS:
// =======================================================================
// Abans de crear el renderer, cridar a la següent funció:
//
// SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
//
// Aixó li diu que volem un renderer que use especificament opengl. A més,
// al crear el renderer li tenim que dir que el volem que use acceeració
// per hardware, i que soporte render a textura. Per exemple:
//
// SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED |
// SDL_RENDERER_TARGETTEXTURE);
//
// Per altra part, al crear la textura tenim que definir que puga ser target
// de renderitzat (SDL_TEXTUREACCESS_TARGET), per exemple:
//
// SDL_Texture *tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
// SDL_TEXTUREACCESS_TARGET, 320, 240);
//
// Els shaders li'ls passem com una cadena, som nosaltres els que s'encarreguem
// de carregarlos de disc, amb fopen, ifstream, jfile o el que vullgues.
// Si els tens en un std::string, passa-li-la com "cadena.c_str()".
//
// Poden ser els dos el mateix arxiu, com fa libRetro, jo desde dins ja fique
// els defines necessaris. Si es el mateix arxiu, pots no ficar el quart paràmetre.
//
// Els shaders de libRetro no funcionen directament, hi ha que fer algunes modificacions.
//
// El pintat final de la teua escena l'has de fer com si "backBuffer" fora la pantalla.
//
// Ah! una cosa mes: al compilar, en Linux afegir "-lGL", en Windows afegir "-lopengl32".
// En Mac ni idea
namespace shader
{
const bool init(SDL_Window* win, SDL_Texture* backBuffer,
const char* vertexShader, const char* fragmentShader=nullptr);
void render();
}

0
jsound.cpp Executable file → Normal file
View File

0
jsound.h Executable file → Normal file
View File

0
main.cpp Executable file → Normal file
View File

8
makefile Executable file → Normal file
View File

@@ -1,9 +1,9 @@
TARGET=aee
all:
g++ *.cpp -std=c++11 -lSDL2 -lSDL2_mixer -o $(TARGET)
linux:
g++ *.cpp -lSDL2 -lSDL2_mixer -lGL -o $(TARGET)
debug:
g++ *.cpp -g -std=c++11 -lSDL2 -lSDL2_mixer -o $(TARGET)
windows:
g++ *.cpp -lmingw32 -lSDL2 -lSDL2_mixer -lopengl32 -mwindows -o $(TARGET)
clean:
rm -rf ./$(TARGET)

0
mapa.cpp Executable file → Normal file
View File

0
mapa.h Executable file → Normal file
View File

0
marcador.cpp Executable file → Normal file
View File

0
marcador.h Executable file → Normal file
View File

0
modulegame.cpp Executable file → Normal file
View File

0
modulegame.h Executable file → Normal file
View File

0
modulesequence.cpp Executable file → Normal file
View File

0
modulesequence.h Executable file → Normal file
View File

0
momia.cpp Executable file → Normal file
View File

0
momia.h Executable file → Normal file
View File

0
prota.cpp Executable file → Normal file
View File

0
prota.h Executable file → Normal file
View File

0
sprite.cpp Executable file → Normal file
View File

0
sprite.h Executable file → Normal file
View File