Skip to content

Commit

Permalink
Merge pull request #99 from SShikhali/feature/ORO-0-ogl
Browse files Browse the repository at this point in the history
Unit tests for `glRegister` functions
  • Loading branch information
takahiroharada authored Oct 3, 2024
2 parents c16bb34 + c17717b commit 834d057
Show file tree
Hide file tree
Showing 13 changed files with 32,171 additions and 0 deletions.
59 changes: 59 additions & 0 deletions UnitTest/basicTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include "basicTests.h"
#include "common.h"

#define GLEW_STATIC
#include "contrib/glew/include/glew/glew.h"
#include "contrib/glfw/include/GLFW/glfw3.h"

TEST_F( OroTestBase, init )
{

Expand Down Expand Up @@ -971,5 +975,60 @@ TEST_F( OroTestBase, ManagedMemory )
o.unloadKernelCache();
}

TEST_F( OroTestBase, glRegisterBuffer )
{
ASSERT_EQ( glfwInit(), GLFW_TRUE );
GLFWwindow* window = glfwCreateWindow( 1, 1, "glRegisterBuffer", nullptr, nullptr );
glfwMakeContextCurrent( window );
ASSERT_EQ( glewInit(), GLEW_OK );

const uint32_t dataSize = 1024u;
GLuint buf = 0;
oroGraphicsResource* oroResource = nullptr;

// Create buffer object
glGenBuffers( 1, &buf );
glBindBuffer( GL_ARRAY_BUFFER, buf );
glBufferData( GL_ARRAY_BUFFER, dataSize, NULL, GL_DYNAMIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, 0 );

OROCHECK( oroGraphicsGLRegisterBuffer( &oroResource, buf, oroGraphicsRegisterFlagsNone ) );
OROCHECK( oroGraphicsUnregisterResource( oroResource ) );

glDeleteBuffers( 1, &buf );
buf = 0;

glfwDestroyWindow( window );
window = nullptr;
glfwTerminate();
}

TEST_F( OroTestBase, glRegisterImage )
{
ASSERT_EQ( glfwInit(), GLFW_TRUE );
GLFWwindow* window = glfwCreateWindow( 1, 1, "glRegisterImage", nullptr, nullptr );
glfwMakeContextCurrent( window );
ASSERT_EQ( glewInit(), GLEW_OK );

const uint32_t imageSize = 64u;
GLuint texture = 0;
oroGraphicsResource* oroResource = nullptr;

// Create texture object
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, imageSize, imageSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glBindTexture( GL_TEXTURE_2D, 0 );

OROCHECK( oroGraphicsGLRegisterImage( &oroResource, texture, GL_TEXTURE_2D, oroGraphicsRegisterFlagsNone ) );
OROCHECK( oroGraphicsUnregisterResource( oroResource ) );

glDeleteTextures( 1, &texture );

glfwDestroyWindow( window );
window = nullptr;
glfwTerminate();
}

Binary file added UnitTest/contrib/glew/glew32s.lib
Binary file not shown.
Loading

0 comments on commit 834d057

Please sign in to comment.