Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render-ng: web version #540

Draft
wants to merge 2 commits into
base: renderer-ng
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/renderer/src/renderer/ResourceStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ namespace renderer {
iterator it = _storage.find(rid);

if(it == _storage.end()){
throw ResourceDoesNotExistsException (rid);
printf("Resource does not exists %d\n", rid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use cout here, like

std::cout << "Resource does not exists " << rid << std::endl;`

abort();
}
return it;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ void GLES3Compositor::texture_render(Texture texture, const renderer::Rect& src_
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, t->name());

#ifndef EMSCRIPTEN
GLuint gl_error = glGetError();
if(gl_error != 0){
std::cout << "glBindTexture error: " << gl_error << std::endl;
}
#endif

_texture_shader->use();
_vertex_array->bind();
Expand Down Expand Up @@ -352,5 +354,6 @@ void GLES3Compositor::set_logical_screen_size(int32_t width, int32_t height)
void GLES3Compositor::read_pixels(uint8_t*)
{
// TODO:
throw CompositorException("GLES3Compositor::read_pixels is not implemented");
printf("GLES3Compositor::read_pixels is not implemented\n");
abort();
}
16 changes: 12 additions & 4 deletions lib/renderer/src/renderer/compositor/gles3/GLES3Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ GLES3Texture::GLES3Texture(int32_t width, int32_t height, TextureType texture_ty
glGenTextures(1, &_name);

glBindTexture(GL_TEXTURE_2D, _name);
#ifndef EMSCRIPTEN
gl_error = glGetError();
if(gl_error != 0){
throw CompositorException(std::string("glBindTexture error: ") + std::to_string(gl_error));
printf("%s\n", (std::string("glBindTexture error: ") + std::to_string(gl_error)).c_str());
Copy link
Contributor

@lpenguin lpenguin Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with

std::cout << "glBindTexture error: " << gl_error << std::endl;

abort();
}
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand All @@ -39,17 +42,22 @@ GLES3Texture::GLES3Texture(int32_t width, int32_t height, TextureType texture_ty
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
break;
default:
throw CompositorException(std::string("Unknown TextureType: ") + std::to_string((int)_texture_type));
default: {
printf("%s\n", (std::string("Unknown TextureType: ") + std::to_string((int) _texture_type)).c_str());
abort();
}
}

glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0,
format, type, pixels);

#ifndef EMSCRIPTEN
gl_error = glGetError();
if(gl_error != 0){
throw CompositorException(std::string("glTexImage2D error: ") + std::to_string(gl_error));
printf("%s\n", ((std::string("glTexImage2D error: ") + std::to_string(gl_error)).c_str()));
abort();
}
#endif

glGenerateMipmap(GL_TEXTURE_2D);
}
Expand Down
22 changes: 15 additions & 7 deletions lib/renderer/src/renderer/compositor/gles3/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void Shader::initialize(const char* vs_shader, const char* fs_shader)
if(!success){
char infoLog[1024];
glGetShaderInfoLog(vertex_shader, 1024, nullptr, infoLog);
throw CompositorException(std::string("Vertex shader compilation error: " + std::string(infoLog)));
printf("%s\n", (std::string("Vertex shader compilation error: " + std::string(infoLog))).c_str());
abort();
}
}

Expand All @@ -36,7 +37,8 @@ void Shader::initialize(const char* vs_shader, const char* fs_shader)
if(!success){
char infoLog[1024];
glGetShaderInfoLog(fragment_shader, 1024, nullptr, infoLog);
throw CompositorException(std::string("Fragment shader compilation error: " + std::string(infoLog)));
printf("%s\n", (std::string("Fragment shader compilation error: " + std::string(infoLog))).c_str());
abort();
}
}

Expand All @@ -49,7 +51,9 @@ void Shader::initialize(const char* vs_shader, const char* fs_shader)
glGetProgramiv(_program, GL_LINK_STATUS, &success);
if(!success){
char infoLog[1024];
throw CompositorException(std::string("Program link error: " + std::string(infoLog)));
glGetShaderInfoLog(fragment_shader, 1024, nullptr, infoLog);
printf("%s\n", (std::string("Program link error: " + std::string(infoLog))).c_str());
abort();
}
}
glDeleteShader(vertex_shader);
Expand All @@ -59,7 +63,8 @@ void Shader::initialize(const char* vs_shader, const char* fs_shader)
void Shader::use()
{
if(_program == 0){
throw CompositorException("shader is not initialized");
printf("shader is not initialized\n");
abort();
}
glUseProgram(_program);
}
Expand All @@ -72,7 +77,8 @@ void Shader::unuse()
void Shader::set_uniform(const char* name, int value)
{
if(_program == 0){
throw CompositorException("shader is not initialized");
printf("shader is not initialized\n");
abort();
}

glUniform1i(glGetUniformLocation(_program, name), value);
Expand All @@ -81,7 +87,8 @@ void Shader::set_uniform(const char* name, int value)
void Shader::set_uniform(const char* name, float value[4])
{
if(_program == 0){
throw CompositorException("shader is not initialized");
printf("shader is not initialized\n");
abort();
}

glUniform4f(glGetUniformLocation(_program, name), value[0], value[1], value[2], value[3]);
Expand All @@ -90,7 +97,8 @@ void Shader::set_uniform(const char* name, float value[4])
void Shader::set_uniform_mat(const char* name, float value[])
{
if(_program == 0){
throw CompositorException("shader is not initialized");
printf("shader is not initialized\n");
abort();
}

glUniformMatrix4fv(glGetUniformLocation(_program, name), 1, false, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ RustVisualBackend::RustVisualBackend(int32_t width, int32_t height)
{
std::cout << "RustVisualBackend::RustVisualBackend" << std::endl;

#ifndef EMSCRIPTEN
if(rv_api_1 != 1){
throw RendererException("Invalid libvangers_ffi version");
printf("Invalid librusty_vangers version expected 1, actual %d\n", rv_api_1);
abort();
}
#endif

rv_init_descriptor desc {
.width = (uint32_t) width,
Expand Down
2 changes: 2 additions & 0 deletions lib/renderer/src/renderer/visualbackend/rust/vange_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ typedef void* rv_context;
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EMSCRIPTEN
extern int32_t rv_api_1;
#endif

rv_context rv_init(rv_init_descriptor desc);

Expand Down
2 changes: 1 addition & 1 deletion lib/xgraph/xgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int XGR_Screen::init(int x,int y,int flags_in)
std::cout<<"XGR_Screen::init"<<std::endl;
// Init SDL video
if (XGR_ScreenSurface==NULL) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
auto* error = SDL_GetError();

std::cerr << "SDL_Init failed: "<<error<<std::endl;
Expand Down