From 6286216e162319c049e3aa7c8435478668bb06d2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 28 Aug 2013 15:40:41 -0700 Subject: [PATCH] Update for language changes --- gl2.rs | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/gl2.rs b/gl2.rs index 2980873..161b337 100644 --- a/gl2.rs +++ b/gl2.rs @@ -374,18 +374,21 @@ pub fn destroy(_x: T) { // Exposed Rust API using Rust naming conventions +#[fixed_stack_segment] pub fn active_texture(texture: GLenum) { unsafe { glActiveTexture(texture); } } +#[fixed_stack_segment] pub fn attach_shader(program: GLuint, shader: GLuint) { unsafe { glAttachShader(program, shader); } } +#[fixed_stack_segment] pub fn bind_attrib_location(program: GLuint, index: GLuint, name: ~str) { unsafe { do name.to_c_str().with_ref |cstr| { @@ -394,18 +397,21 @@ pub fn bind_attrib_location(program: GLuint, index: GLuint, name: ~str) { } } +#[fixed_stack_segment] pub fn bind_buffer(target: GLenum, buffer: GLuint) { unsafe { glBindBuffer(target, buffer); } } +#[fixed_stack_segment] pub fn bind_framebuffer(target: GLenum, framebuffer: GLuint) { unsafe { glBindFramebuffer(target, framebuffer); } } +#[fixed_stack_segment] pub fn bind_texture(target: GLenum, texture: GLuint) { unsafe { glBindTexture(target, texture); @@ -414,36 +420,42 @@ pub fn bind_texture(target: GLenum, texture: GLuint) { #[cfg(not(target_os="android"), not(target_os="macos"))] #[cfg(not(target_os="android"), not(mac_10_6))] +#[fixed_stack_segment] pub fn bind_vertex_array(array: GLuint) { unsafe { glBindVertexArray(array); } } +#[fixed_stack_segment] pub fn blend_color(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) { unsafe { glBlendColor(red, green, blue, alpha); } } +#[fixed_stack_segment] pub fn blend_equation(mode: GLenum) { unsafe { glBlendEquation(mode); } } +#[fixed_stack_segment] pub fn blend_equation_separate(mode_rgb: GLenum, mode_alpha: GLenum) { unsafe { glBlendEquationSeparate(mode_rgb, mode_alpha); } } +#[fixed_stack_segment] pub fn blend_func(sfactor: GLenum, dfactor: GLenum) { unsafe { glBlendFunc(sfactor, dfactor); } } +#[fixed_stack_segment] pub fn blend_func_separate(src_rgb: GLenum, dst_rgb: GLenum, src_alpha: GLenum, dst_alpha: GLenum) { unsafe { glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); @@ -451,6 +463,7 @@ pub fn blend_func_separate(src_rgb: GLenum, dst_rgb: GLenum, src_alpha: GLenum, } // FIXME: There should be some type-safe wrapper for this... +#[fixed_stack_segment] pub fn buffer_data(target: GLenum, data: &[T], usage: GLenum) { unsafe { glBufferData(target, @@ -462,6 +475,7 @@ pub fn buffer_data(target: GLenum, data: &[T], usage: GLenum) { // FIXME: As above // Note: offset is the element offset index, not byte offset +#[fixed_stack_segment] pub fn buffer_sub_data(target: GLenum, element_offset_index: uint, data: &[T]) { unsafe { let size = size_of::(); @@ -472,108 +486,126 @@ pub fn buffer_sub_data(target: GLenum, element_offset_index: uint, data: &[T] } } +#[fixed_stack_segment] pub fn check_framebuffer_status(target: GLenum) -> GLenum { unsafe { glCheckFramebufferStatus(target) } } +#[fixed_stack_segment] pub fn clear(mask: GLbitfield) { unsafe { glClear(mask); } } +#[fixed_stack_segment] pub fn clear_color(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) { unsafe { glClearColor(red, green, blue, alpha); } } +#[fixed_stack_segment] pub fn compile_shader(shader: GLuint) { unsafe { glCompileShader(shader); } } +#[fixed_stack_segment] pub fn create_program() -> GLuint { unsafe { return glCreateProgram(); } } +#[fixed_stack_segment] pub fn create_shader(shader_type: GLenum) -> GLuint { unsafe { return glCreateShader(shader_type); } } +#[fixed_stack_segment] pub fn cull_face(mode: GLenum) { unsafe { glCullFace(mode); } } +#[fixed_stack_segment] pub fn delete_buffers(buffers: &[GLuint]) { unsafe { glDeleteBuffers(buffers.len() as GLsizei, to_ptr(buffers)); } } +#[fixed_stack_segment] pub fn delete_frame_buffers(frame_buffers: &[GLuint]) { unsafe { glDeleteFramebuffers(frame_buffers.len() as GLsizei, to_ptr(frame_buffers)); } } +#[fixed_stack_segment] pub fn delete_program(program: GLuint) { unsafe { glDeleteProgram(program); } } +#[fixed_stack_segment] pub fn delete_render_buffers(render_buffers: &[GLuint]) { unsafe { glDeleteRenderbuffers(render_buffers.len() as GLsizei, to_ptr(render_buffers)); } } +#[fixed_stack_segment] pub fn delete_shader(shader: GLuint) { unsafe { glDeleteShader(shader); } } +#[fixed_stack_segment] pub fn delete_textures(textures: &[GLuint]) { unsafe { return glDeleteTextures(textures.len() as GLsizei, to_ptr(textures)); } } +#[fixed_stack_segment] pub fn depth_func(func: GLenum) { unsafe { glDepthFunc(func); } } +#[fixed_stack_segment] pub fn depth_mask(flag: bool) { unsafe { glDepthMask(flag as GLboolean); } } +#[fixed_stack_segment] pub fn detach_shader(program: GLuint, shader: GLuint) { unsafe { glDetachShader(program, shader); } } +#[fixed_stack_segment] pub fn draw_arrays(mode: GLenum, first: GLint, count: GLsizei) { unsafe { return glDrawArrays(mode, first, count); } } +#[fixed_stack_segment] pub fn draw_elements(mode: GLenum, count: GLsizei, element_type: GLenum, indices: Option<&[u8]>) { unsafe { return glDrawElements(mode, @@ -591,6 +623,7 @@ pub fn draw_elements(mode: GLenum, count: GLsizei, element_type: GLenum, indices #[cfg(not(target_os="android"), not(target_os="macos"))] #[cfg(not(target_os="android"), not(mac_10_6))] +#[fixed_stack_segment] pub fn draw_arrays_instanced(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei) { unsafe { glDrawArraysInstanced(mode, first, count, primcount); @@ -599,6 +632,7 @@ pub fn draw_arrays_instanced(mode: GLenum, first: GLint, count: GLsizei, primcou #[cfg(not(target_os="android"), not(target_os="macos"))] #[cfg(not(target_os="android"), not(mac_10_6))] +#[fixed_stack_segment] pub fn draw_elements_instanced(mode: GLenum, count: GLsizei, element_type: GLenum, indices: Option<&[u8]>, primcount: GLsizei) { unsafe { glDrawElementsInstanced(mode, @@ -615,42 +649,49 @@ pub fn draw_elements_instanced(mode: GLenum, count: GLsizei, element_type: GLenu } } +#[fixed_stack_segment] pub fn enable(cap: GLenum) { unsafe { glEnable(cap); } } +#[fixed_stack_segment] pub fn disable(cap: GLenum) { unsafe { glDisable(cap); } } +#[fixed_stack_segment] pub fn enable_vertex_attrib_array(index: GLuint) { unsafe { glEnableVertexAttribArray(index); } } +#[fixed_stack_segment] pub fn disable_vertex_attrib_array(index: GLuint) { unsafe { glDisableVertexAttribArray(index); } } +#[fixed_stack_segment] pub fn finish() { unsafe { return glFinish(); } } +#[fixed_stack_segment] pub fn flush() { unsafe { return glFlush(); } } +#[fixed_stack_segment] pub fn framebuffer_texture_2d(target: GLenum, attachment: GLenum, textarget: GLenum, @@ -661,12 +702,14 @@ pub fn framebuffer_texture_2d(target: GLenum, } } +#[fixed_stack_segment] pub fn front_face(mode: GLenum) { unsafe { glFrontFace(mode); } } +#[fixed_stack_segment] pub fn gen_buffers(n: GLsizei) -> ~[GLuint] { unsafe { let result = from_elem(n as uint, 0 as GLuint); @@ -675,6 +718,7 @@ pub fn gen_buffers(n: GLsizei) -> ~[GLuint] { } } +#[fixed_stack_segment] pub fn gen_framebuffers(n: GLsizei) -> ~[GLuint] { unsafe { let result = from_elem(n as uint, 0 as GLuint); @@ -683,6 +727,7 @@ pub fn gen_framebuffers(n: GLsizei) -> ~[GLuint] { } } +#[fixed_stack_segment] pub fn gen_textures(n: GLsizei) -> ~[GLuint] { unsafe { let result = from_elem(n as uint, 0 as GLuint); @@ -693,6 +738,7 @@ pub fn gen_textures(n: GLsizei) -> ~[GLuint] { #[cfg(not(target_os="android"), not(target_os="macos"))] #[cfg(not(target_os="android"), not(mac_10_6))] +#[fixed_stack_segment] pub fn gen_vertex_arrays(n: GLsizei) -> ~[GLuint] { unsafe { let result = from_elem(n as uint, 0 as GLuint); @@ -701,6 +747,7 @@ pub fn gen_vertex_arrays(n: GLsizei) -> ~[GLuint] { } } +#[fixed_stack_segment] pub fn get_attrib_location(program: GLuint, name: ~str) -> c_int { unsafe { do name.to_c_str().with_ref |name_bytes| { @@ -709,18 +756,21 @@ pub fn get_attrib_location(program: GLuint, name: ~str) -> c_int { } } +#[fixed_stack_segment] pub fn get_error() -> GLenum { unsafe { return glGetError(); } } +#[fixed_stack_segment] pub fn get_integer_v(pname: GLenum, result: &mut [GLint]) { unsafe { glGetIntegerv(pname, to_unsafe_ptr(&result[0])); } } +#[fixed_stack_segment] pub fn get_program_info_log(program: GLuint) -> ~str { unsafe { let mut result = from_elem(1024u, 0u8); @@ -734,6 +784,7 @@ pub fn get_program_info_log(program: GLuint) -> ~str { } } +#[fixed_stack_segment] pub fn get_program_iv(program: GLuint, pname: GLenum) -> GLint { unsafe { let result: GLint = 0 as GLint; @@ -742,6 +793,7 @@ pub fn get_program_iv(program: GLuint, pname: GLenum) -> GLint { } } +#[fixed_stack_segment] pub fn get_shader_info_log(shader: GLuint) -> ~str { unsafe { let mut result = from_elem(1024u, 0u8); @@ -755,6 +807,7 @@ pub fn get_shader_info_log(shader: GLuint) -> ~str { } } +#[fixed_stack_segment] pub fn get_string(which: GLenum) -> ~str { unsafe { let llstr = glGetString(which); @@ -766,6 +819,7 @@ pub fn get_string(which: GLenum) -> ~str { } } +#[fixed_stack_segment] pub fn get_shader_iv(shader: GLuint, pname: GLenum) -> GLint { unsafe { let result: GLint = 0 as GLint; @@ -774,6 +828,7 @@ pub fn get_shader_iv(shader: GLuint, pname: GLenum) -> GLint { } } +#[fixed_stack_segment] pub fn get_uniform_location(program: GLuint, name: ~str) -> c_int { unsafe { do name.to_c_str().with_ref |name_bytes| { @@ -782,60 +837,70 @@ pub fn get_uniform_location(program: GLuint, name: ~str) -> c_int { } } +#[fixed_stack_segment] pub fn is_buffer(buffer: GLuint) -> bool { unsafe { glIsBuffer(buffer) > 0 } } +#[fixed_stack_segment] pub fn is_enabled(cap: GLenum) -> bool { unsafe { glIsEnabled(cap) > 0 } } +#[fixed_stack_segment] pub fn is_framebuffer(framebuffer: GLuint) -> bool { unsafe { glIsFramebuffer(framebuffer) > 0 } } +#[fixed_stack_segment] pub fn is_program(program: GLuint) -> bool { unsafe { glIsProgram(program) > 0 } } +#[fixed_stack_segment] pub fn is_renderbuffer(renderbuffer: GLuint) -> bool { unsafe { glIsRenderbuffer(renderbuffer) > 0 } } +#[fixed_stack_segment] pub fn is_shader(shader: GLuint) -> bool { unsafe { glIsShader(shader) > 0 } } +#[fixed_stack_segment] pub fn is_texture(texture: GLuint) -> bool { unsafe { glIsTexture(texture) > 0 } } +#[fixed_stack_segment] pub fn line_width(width: GLfloat) { unsafe { glLineWidth(width); } } +#[fixed_stack_segment] pub fn link_program(program: GLuint) { unsafe { return glLinkProgram(program); } } +#[fixed_stack_segment] pub fn pixel_store_i(pname: GLenum, param: GLint) { unsafe { glPixelStorei(pname, param); @@ -843,12 +908,14 @@ pub fn pixel_store_i(pname: GLenum, param: GLint) { } #[cfg(not(target_os = "android"))] +#[fixed_stack_segment] pub fn polygon_mode(face: GLenum, mode: GLenum) { unsafe { glPolygonMode(face, mode); } } +#[fixed_stack_segment] pub fn read_pixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, pixel_type: GLenum) -> ~[u8] { let colors = match format { RGB => 3, @@ -874,12 +941,14 @@ pub fn read_pixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: pixels } +#[fixed_stack_segment] pub fn scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) { unsafe { glScissor(x, y, width, height); } } +#[fixed_stack_segment] pub fn shader_source(shader: GLuint, strings: &[~[u8]]) { unsafe { let pointers = strings.map(|string| to_ptr(*string)); @@ -892,6 +961,7 @@ pub fn shader_source(shader: GLuint, strings: &[~[u8]]) { } // FIXME: Does not verify buffer size -- unsafe! +#[fixed_stack_segment] pub fn tex_image_2d(target: GLenum, level: GLint, internal_format: GLint, @@ -919,6 +989,7 @@ pub fn tex_image_2d(target: GLenum, } // FIXME: Does not verify buffer size -- unsafe! +#[fixed_stack_segment] pub fn tex_sub_image_2d(target: GLenum, level: GLint, xoffset: GLint, @@ -945,42 +1016,49 @@ pub fn tex_sub_image_2d(target: GLenum, } } +#[fixed_stack_segment] pub fn tex_parameter_i(target: GLenum, pname: GLenum, param: GLint) { unsafe { glTexParameteri(target, pname, param); } } +#[fixed_stack_segment] pub fn uniform_1f(location: GLint, x: GLfloat) { unsafe { glUniform1f(location, x); } } +#[fixed_stack_segment] pub fn uniform_1i(location: GLint, x: GLint) { unsafe { glUniform1i(location, x); } } +#[fixed_stack_segment] pub fn uniform_2f(location: GLint, x: GLfloat, y: GLfloat) { unsafe { glUniform2f(location, x, y); } } +#[fixed_stack_segment] pub fn uniform_3f(location: GLint, x: GLfloat, y: GLfloat, z: GLfloat) { unsafe { glUniform3f(location, x, y, z); } } +#[fixed_stack_segment] pub fn uniform_4f(location: GLint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) { unsafe { glUniform4f(location, x, y, z, w); } } +#[fixed_stack_segment] pub fn uniform_matrix_4fv(location: GLint, transpose: bool, value: &[f32]) { unsafe { glUniformMatrix4fv(location, @@ -990,18 +1068,21 @@ pub fn uniform_matrix_4fv(location: GLint, transpose: bool, value: &[f32]) { } } +#[fixed_stack_segment] pub fn use_program(program: GLuint) { unsafe { glUseProgram(program); } } +#[fixed_stack_segment] pub fn validate_program(program: GLuint) { unsafe { glValidateProgram(program); } } +#[fixed_stack_segment] pub fn vertex_attrib_pointer_f32(index: GLuint, size: GLint, normalized: bool, @@ -1017,6 +1098,7 @@ pub fn vertex_attrib_pointer_f32(index: GLuint, } } +#[fixed_stack_segment] pub fn vertex_attrib_pointer_i8(index: GLuint, size: GLint, normalized: bool, @@ -1032,6 +1114,7 @@ pub fn vertex_attrib_pointer_i8(index: GLuint, } } +#[fixed_stack_segment] pub fn vertex_attrib_pointer_i32(index: GLuint, size: GLint, normalized: bool, @@ -1047,6 +1130,7 @@ pub fn vertex_attrib_pointer_i32(index: GLuint, } } +#[fixed_stack_segment] pub fn vertex_attrib_pointer_u8(index: GLuint, size: GLint, normalized: bool, @@ -1064,12 +1148,14 @@ pub fn vertex_attrib_pointer_u8(index: GLuint, #[cfg(not(target_os="android"), not(target_os="macos"))] #[cfg(not(target_os="android"), not(mac_10_6), not(mac_10_7))] +#[fixed_stack_segment] pub fn vertex_attrib_divisor(index: GLuint, divisor: GLuint) { unsafe { glVertexAttribDivisor(index, divisor); } } +#[fixed_stack_segment] pub fn viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) { unsafe { glViewport(x, y, width, height); @@ -1083,6 +1169,7 @@ pub mod apple { use std::cast::transmute; use std::vec::raw::to_ptr; + #[fixed_stack_segment] pub unsafe fn texture_range(target: GLenum, buffer: &[u8]) { super::glTextureRangeAPPLE(target, buffer.len() as GLsizei, transmute(to_ptr(buffer))); }