starting textures
Some checks failed
Build Dusk / run-tests (push) Failing after 16s
Build Dusk / build-linux (push) Failing after 17s
Build Dusk / build-psp (push) Failing after 18s
Build Dusk / build-gamecube (push) Failing after 17s
Build Dusk / build-wii (push) Failing after 17s
Some checks failed
Build Dusk / run-tests (push) Failing after 16s
Build Dusk / build-linux (push) Failing after 17s
Build Dusk / build-psp (push) Failing after 18s
Build Dusk / build-gamecube (push) Failing after 17s
Build Dusk / build-wii (push) Failing after 17s
This commit is contained in:
@@ -203,6 +203,32 @@ errorret_t shaderSetMatrixGL(
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t shaderSetTextureGL(
|
||||
shadergl_t *shader,
|
||||
const char_t *name,
|
||||
texture_t *texture
|
||||
) {
|
||||
assertNotNull(shader, "Shader cannot be null");
|
||||
assertNotNull(texture, "Texture cannot be null");
|
||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||
|
||||
#ifdef DUSK_OPENGL_LEGACY
|
||||
assertUnreachable("Cannot set textures on legacy opengl.");
|
||||
#else
|
||||
GLint location;
|
||||
errorChain(shaderParamGetLocationGL(shader, name, &location));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
errorChain(errorGLCheck());
|
||||
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||
errorChain(errorGLCheck());
|
||||
glUniform1i(location, 0);
|
||||
errorChain(errorGLCheck());
|
||||
#endif
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
// errorret_t shaderSetColorGL(
|
||||
// shadergl_t *shader,
|
||||
// const char_t *name,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "error/errorgl.h"
|
||||
#include "display/color.h"
|
||||
#include "display/texture/texture.h"
|
||||
|
||||
typedef struct {
|
||||
#ifdef DUSK_OPENGL_LEGACY
|
||||
@@ -100,11 +100,11 @@ errorret_t shaderSetMatrixGL(
|
||||
* @param color The color data to set.
|
||||
* @return An errorret_t indicating success or failure.
|
||||
*/
|
||||
// errorret_t shaderSetTextureGL(
|
||||
// shadergl_t *shader,
|
||||
// const char_t *name,
|
||||
// texture_t *texture
|
||||
// );
|
||||
errorret_t shaderSetTextureGL(
|
||||
shadergl_t *shader,
|
||||
const char_t *name,
|
||||
texture_t *texture
|
||||
);
|
||||
|
||||
/**
|
||||
* Sets a color uniform parameter in the shader.
|
||||
|
||||
@@ -14,6 +14,6 @@ typedef shaderdefinitiongl_t shaderdefinitionplatform_t;
|
||||
#define shaderInitPlatform shaderInitGL
|
||||
#define shaderBindPlatform shaderBindGL
|
||||
#define shaderSetMatrixPlatform shaderSetMatrixGL
|
||||
// #define shaderSetTexturePlatform shaderSetTextureGL
|
||||
#define shaderSetTexturePlatform shaderSetTextureGL
|
||||
// #define shaderSetColorPlatform shaderSetColorGL
|
||||
#define shaderDisposePlatform shaderDisposeGL
|
||||
@@ -20,17 +20,21 @@
|
||||
"uniform mat4 u_View;\n"
|
||||
"uniform mat4 u_Model;\n"
|
||||
"out vec4 v_Color;\n"
|
||||
"out vec2 v_TexCoord;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = u_Proj * u_View * u_Model * vec4(aPos, 1.0);\n"
|
||||
" v_Color = aColor;\n"
|
||||
" v_TexCoord = aTexCoord;\n"
|
||||
"}\n",
|
||||
|
||||
.frag =
|
||||
"#version 330 core\n"
|
||||
"uniform sampler2D u_Texture;\n"
|
||||
"in vec4 v_Color;\n"
|
||||
"in vec2 v_TexCoord;\n"
|
||||
"out vec4 FragColor;\n"
|
||||
"void main() {\n"
|
||||
" FragColor = v_Color;\n"
|
||||
" FragColor = texture(u_Texture, v_TexCoord) * v_Color;\n"
|
||||
"}\n"
|
||||
};
|
||||
#endif
|
||||
@@ -63,19 +63,6 @@ errorret_t textureInitGL(
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t textureBindGL(texturegl_t *texture) {
|
||||
if(texture == NULL) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
errorChain(errorGLCheck());
|
||||
errorOk();
|
||||
}
|
||||
|
||||
assertTrue(texture->id != 0, "Texture ID must be valid");
|
||||
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||
errorChain(errorGLCheck());
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t textureDisposeGL(texturegl_t *texture) {
|
||||
assertNotNull(texture, "Texture cannot be NULL");
|
||||
assertTrue(texture->id != 0, "Texture ID must be valid");
|
||||
|
||||
@@ -40,14 +40,6 @@ errorret_t textureInitGL(
|
||||
const texturedata_t data
|
||||
);
|
||||
|
||||
/**
|
||||
* Binds a texture for rendering. Providing NULL will unbind any texture.
|
||||
*
|
||||
* @param texture The texture to bind.
|
||||
* @return An error if the texture failed to bind, otherwise success.
|
||||
*/
|
||||
errorret_t textureBindGL(texturegl_t *texture);
|
||||
|
||||
/**
|
||||
* Disposes a texture.
|
||||
*
|
||||
|
||||
@@ -12,5 +12,4 @@ typedef textureformatgl_t textureformatplatform_t;
|
||||
typedef texturegl_t textureplatform_t;
|
||||
|
||||
#define textureInitPlatform textureInitGL
|
||||
#define textureBindPlatform textureBindGL
|
||||
#define textureDisposePlatform textureDisposeGL
|
||||
Reference in New Issue
Block a user