From: José Fonseca Date: Sat, 10 Mar 2012 10:33:58 +0000 (+0000) Subject: Basic map buffer test. X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=commitdiff_plain;h=abd253a55273ae8c8da7f8e15f9e95a3fc118e58 Basic map buffer test. --- diff --git a/apps/gl/.gitignore b/apps/gl/.gitignore index d396b2a..522615b 100644 --- a/apps/gl/.gitignore +++ b/apps/gl/.gitignore @@ -1,3 +1,4 @@ gremedy +map_buffer tri varray diff --git a/apps/gl/CMakeLists.txt b/apps/gl/CMakeLists.txt index d78fce2..6344566 100644 --- a/apps/gl/CMakeLists.txt +++ b/apps/gl/CMakeLists.txt @@ -37,6 +37,7 @@ set (targets tri gremedy varray + map_buffer ) foreach (target ${targets}) @@ -46,8 +47,8 @@ foreach (target ${targets}) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${target}.ref.txt) add_app_test( NAME ${api}_${target} - TARGET ${api}_${target} - REF ${target}.ref.txt + TARGET ${api}_${target} + REF ${target}.ref.txt ) endif () endforeach (target) diff --git a/apps/gl/map_buffer.c b/apps/gl/map_buffer.c new file mode 100644 index 0000000..f0108ed --- /dev/null +++ b/apps/gl/map_buffer.c @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2012 Jose Fonseca + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + +#ifdef _WIN32 +#include +#endif + +#include +#include +#include + +#include +#ifdef __APPLE__ +# include +#else +# include +#endif + + +static void +parseArgs(int argc, char** argv) +{ +} + +static void +init(void) +{ + GLenum target = GL_ARRAY_BUFFER; + GLuint buffers[2]; + GLvoid *ptr; + + if (!GLEW_VERSION_1_5 || + !GLEW_ARB_map_buffer_range) { + exit(0); + } + + glGenBuffers(2, buffers); + + glBindBuffer(target, buffers[0]); + glBufferData(target, 1000, NULL, GL_STATIC_DRAW); + + ptr = glMapBufferRange(target, 100, 200, GL_MAP_WRITE_BIT); + memset(ptr, 0, 200); + glUnmapBuffer(target); + + glBindBuffer(target, buffers[1]); + glBufferData(target, 2000, NULL, GL_STATIC_DRAW); + ptr = glMapBufferRange(target, 200, 300, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); + memset(ptr, 0, 300); + + glBindBuffer(target, buffers[0]); + ptr = glMapBufferRange(target, 100, 200, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); + memset(ptr, 0, 200); + + glBindBuffer(target, buffers[1]); + glFlushMappedBufferRange(target, 20, 30); + glFlushMappedBufferRange(target, 40, 50); + glUnmapBuffer(target); + + glBindBuffer(target, buffers[0]); + glFlushMappedBufferRange(target, 10, 20); + glFlushMappedBufferRange(target, 30, 40); + glUnmapBuffer(target); + + glMapBufferRange(target, 100, 200, GL_MAP_READ_BIT); + glUnmapBuffer(target); +} + +int main(int argc, char** argv) +{ + parseArgs(argc, argv); + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutCreateWindow(argv[0]); + glewInit(); + init(); + return 0; +} diff --git a/apps/gl/map_buffer.ref.txt b/apps/gl/map_buffer.ref.txt new file mode 100644 index 0000000..e69de29