mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 21:29:17 +01:00
Removed lwjgl renderer from trunk
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
|
||||
<classpathentry kind="lib" path="library/lwjgl.jar"/>
|
||||
<classpathentry kind="lib" path="library/lwjgl_util.jar"/>
|
||||
<classpathentry kind="lib" path="library/lwjgl_util_applet.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>processing-lwjgl</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,273 +0,0 @@
|
||||
#Sat Nov 12 10:56:23 CST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=36
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_line_comments=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
|
||||
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=2
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
|
||||
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=80
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=space
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=2
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
@@ -1,4 +0,0 @@
|
||||
#Fri Feb 19 16:20:47 EST 2010
|
||||
eclipse.preferences.version=1
|
||||
formatter_profile=_processing
|
||||
formatter_settings_version=11
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="Processing LWJGL Library" default="build">
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<delete file="library/lwopengl.jar" />
|
||||
</target>
|
||||
|
||||
<target name="compile" description="Compile sources">
|
||||
<condition property="core-built">
|
||||
<available file="../../../core/core.jar" />
|
||||
</condition>
|
||||
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/core.jar" />
|
||||
|
||||
<mkdir dir="bin" />
|
||||
<javac target="1.5"
|
||||
srcdir="src" destdir="bin"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
classpath="../../../core/core.jar; library/lwjgl.jar; library/lwjgl_util.jar; library/lwjgl_applet.jar" />
|
||||
|
||||
<!-- Copy the shaders to the bin folder.
|
||||
Eclipse does this automatically. -->
|
||||
<copy todir="bin">
|
||||
<fileset dir="src">
|
||||
<include name="processing/lwjgl/*.glsl" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="compile" description="Build LWJGL library">
|
||||
<jar basedir="bin" destfile="library/lwopengl.jar" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Brick Tower
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* 3D castle tower constructed out of individual bricks.
|
||||
* Uses the PVector and Cube classes.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
float bricksPerLayer = 16.0;
|
||||
float brickLayers = 18.0;
|
||||
Cube brick;
|
||||
float brickWidth = 60, brickHeight = 25, brickDepth = 25;
|
||||
float radius = 175.0;
|
||||
float angle = 0;
|
||||
|
||||
void setup(){
|
||||
size(640, 360, LWJGL);
|
||||
brick = new Cube(brickWidth, brickHeight, brickDepth);
|
||||
}
|
||||
|
||||
void draw(){
|
||||
background(0);
|
||||
float tempX = 0, tempY = 0, tempZ = 0;
|
||||
fill(182, 62, 29);
|
||||
noStroke();
|
||||
// Add basic light setup
|
||||
lights();
|
||||
translate(width/2, height*1.2, -380);
|
||||
// Tip tower to see inside
|
||||
rotateX(radians(-45));
|
||||
// Slowly rotate tower
|
||||
rotateY(frameCount * PI/600);
|
||||
for (int i = 0; i < brickLayers; i++){
|
||||
// Increment rows
|
||||
tempY-=brickHeight;
|
||||
// Alternate brick seams
|
||||
angle = 360.0 / bricksPerLayer * i/2;
|
||||
for (int j = 0; j < bricksPerLayer; j++){
|
||||
tempZ = cos(radians(angle))*radius;
|
||||
tempX = sin(radians(angle))*radius;
|
||||
pushMatrix();
|
||||
translate(tempX, tempY, tempZ);
|
||||
rotateY(radians(angle));
|
||||
// Add crenelation
|
||||
if (i==brickLayers-1){
|
||||
if (j%2 == 0){
|
||||
brick.create();
|
||||
}
|
||||
}
|
||||
// Create main tower
|
||||
else {
|
||||
brick.create();
|
||||
}
|
||||
popMatrix();
|
||||
angle += 360.0/bricksPerLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
class Cube {
|
||||
|
||||
PVector[] vertices = new PVector[24];
|
||||
PVector[] normals = new PVector[6];
|
||||
float w, h, d;
|
||||
|
||||
Cube(){ }
|
||||
|
||||
Cube(float w, float h, float d){
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.d = d;
|
||||
|
||||
// Cube composed of 6 quads
|
||||
// Front
|
||||
normals[0] = new PVector(0, 0, 1);
|
||||
vertices[0] = new PVector(-w/2, -h/2, d/2);
|
||||
vertices[1] = new PVector(w/2, -h/2, d/2);
|
||||
vertices[2] = new PVector(w/2, h/2, d/2);
|
||||
vertices[3] = new PVector(-w/2, h/2, d/2);
|
||||
|
||||
// Left
|
||||
normals[1] = new PVector(-1, 0, 0);
|
||||
vertices[4] = new PVector(-w/2, -h/2, d/2);
|
||||
vertices[5] = new PVector(-w/2, -h/2, -d/2);
|
||||
vertices[6] = new PVector(-w/2, h/2, -d/2);
|
||||
vertices[7] = new PVector(-w/2, h/2, d/2);
|
||||
|
||||
// Right
|
||||
normals[2] = new PVector(1, 0, 0);
|
||||
vertices[8] = new PVector(w/2, -h/2, d/2);
|
||||
vertices[9] = new PVector(w/2, -h/2, -d/2);
|
||||
vertices[10] = new PVector(w/2, h/2, -d/2);
|
||||
vertices[11] = new PVector(w/2, h/2, d/2);
|
||||
|
||||
// Back
|
||||
normals[3] = new PVector(0, 0, -1);
|
||||
vertices[12] = new PVector(-w/2, -h/2, -d/2);
|
||||
vertices[13] = new PVector(w/2, -h/2, -d/2);
|
||||
vertices[14] = new PVector(w/2, h/2, -d/2);
|
||||
vertices[15] = new PVector(-w/2, h/2, -d/2);
|
||||
|
||||
// Top
|
||||
normals[4] = new PVector(0, 1, 0);
|
||||
vertices[16] = new PVector(-w/2, -h/2, d/2);
|
||||
vertices[17] = new PVector(-w/2, -h/2, -d/2);
|
||||
vertices[18] = new PVector(w/2, -h/2, -d/2);
|
||||
vertices[19] = new PVector(w/2, -h/2, d/2);
|
||||
|
||||
// Bottom
|
||||
normals[5] = new PVector(0, 1, 0);
|
||||
vertices[20] = new PVector(-w/2, h/2, d/2);
|
||||
vertices[21] = new PVector(-w/2, h/2, -d/2);
|
||||
vertices[22] = new PVector(w/2, h/2, -d/2);
|
||||
vertices[23] = new PVector(w/2, h/2, d/2);
|
||||
}
|
||||
|
||||
void create(){
|
||||
for (int i=0; i<6; i++){
|
||||
beginShape(QUADS);
|
||||
normal(normals[i].x, normals[i].y, normals[i].z);
|
||||
for (int j = 0; j < 4; j++){
|
||||
vertex(vertices[j+4*i].x, vertices[j+4*i].y, vertices[j+4*i].z);
|
||||
}
|
||||
endShape();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* Cubic Grid
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* 3D translucent colored grid uses nested pushMatrix()
|
||||
* and popMatrix() functions.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
float boxSize = 40;
|
||||
float margin = boxSize*2;
|
||||
float depth = 400;
|
||||
color boxFill;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, LWJGL);
|
||||
noStroke();
|
||||
hint(DISABLE_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
|
||||
// Center and spin grid
|
||||
translate(width/2, height/2, -depth);
|
||||
rotateY(frameCount * 0.01);
|
||||
rotateX(frameCount * 0.01);
|
||||
|
||||
// Build grid using multiple translations
|
||||
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
|
||||
pushMatrix();
|
||||
for (float j =- height+margin; j <= height-margin; j += boxSize){
|
||||
pushMatrix();
|
||||
for (float k =- width+margin; k <= width-margin; k += boxSize){
|
||||
// Base fill color on counter values, abs function
|
||||
// ensures values stay within legal range
|
||||
boxFill = color(abs(i), abs(j), abs(k), 50);
|
||||
pushMatrix();
|
||||
translate(k, j, i);
|
||||
fill(boxFill);
|
||||
box(boxSize, boxSize, boxSize);
|
||||
popMatrix();
|
||||
}
|
||||
popMatrix();
|
||||
}
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* LightsGL.
|
||||
* Modified from an example by Simon Greenwold.
|
||||
*
|
||||
* Display a box with three different kinds of lights.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(1024, 768, LWJGL);
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
defineLights();
|
||||
background(0);
|
||||
|
||||
for (int x = 0; x <= width; x += 100) {
|
||||
for (int y = 0; y <= height; y += 100) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotateY(map(mouseX, 0, width, 0, PI));
|
||||
rotateX(map(mouseY, 0, height, 0, PI));
|
||||
box(90);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void defineLights() {
|
||||
// Orange point light on the right
|
||||
pointLight(150, 100, 0, // Color
|
||||
200, -150, 0); // Position
|
||||
|
||||
// Blue directional light from the left
|
||||
directionalLight(0, 102, 255, // Color
|
||||
1, 0, 0); // The x-, y-, z-axis direction
|
||||
|
||||
// Yellow spotlight from the front
|
||||
spotLight(255, 255, 109, // Color
|
||||
0, 40, 200, // Position
|
||||
0, -0.5, -0.5, // Direction
|
||||
PI / 2, 2); // Angle, concentration
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Reflection
|
||||
* by Simon Greenwold.
|
||||
*
|
||||
* Vary the specular reflection component of a material
|
||||
* with the horizontal position of the mouse.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, LWJGL);
|
||||
noStroke();
|
||||
colorMode(RGB, 1);
|
||||
fill(0.4);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
translate(width / 2, height / 2);
|
||||
// Set the specular color of lights that follow
|
||||
lightSpecular(1, 1, 1);
|
||||
directionalLight(0.8, 0.8, 0.8, 0, 0, -1);
|
||||
float s = mouseX / float(width);
|
||||
specular(s, s, s);
|
||||
sphere(120);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Spot.
|
||||
*
|
||||
* Move the mouse the change the position and concentation
|
||||
* of a blue spot light.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
int concentration = 600; // Try values 1 -> 10000
|
||||
|
||||
void setup()
|
||||
{
|
||||
//size(200, 200, LWJGL);
|
||||
size(640, 360, LWJGL);
|
||||
noStroke();
|
||||
fill(204);
|
||||
sphereDetail(60);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
// Light the bottom of the sphere
|
||||
directionalLight(51, 102, 126, 0, -1, 0);
|
||||
|
||||
// Orange light on the upper-right of the sphere
|
||||
spotLight(204, 153, 0, 360, 160, 600, 0, 0, -1, PI/2, 600);
|
||||
|
||||
// Moving spotlight that follows the mouse
|
||||
spotLight(102, 153, 204, 360, mouseY, 600, 0, 0, -1, PI/2, 600);
|
||||
|
||||
translate(width/2, height/2, 0);
|
||||
sphere(120);
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* Cubic Grid
|
||||
* by Ira Greenberg.
|
||||
*
|
||||
* 3D translucent colored grid uses nested pushMatrix()
|
||||
* and popMatrix() functions.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
float boxSize = 20;
|
||||
float margin = boxSize*2;
|
||||
float depth = 400;
|
||||
color boxFill;
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, LWJGL);
|
||||
frameRate(120);
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
|
||||
hint(DISABLE_DEPTH_TEST);
|
||||
|
||||
// Center and spin grid
|
||||
pushMatrix();
|
||||
translate(width/2, height/2, -depth);
|
||||
rotateY(frameCount * 0.01);
|
||||
rotateX(frameCount * 0.01);
|
||||
|
||||
// Build grid using multiple translations
|
||||
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
|
||||
for (float j =- height+margin; j <= height-margin; j += boxSize){
|
||||
for (float k =- width+margin; k <= width-margin; k += boxSize){
|
||||
// Base fill color on counter values, abs function
|
||||
// ensures values stay within legal range
|
||||
boxFill = color(abs(i), abs(j), abs(k), 50);
|
||||
pushMatrix();
|
||||
translate(k, j, i);
|
||||
fill(boxFill);
|
||||
box(boxSize, boxSize, boxSize);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
popMatrix();
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
fill(0);
|
||||
text("fps: " + frate, 10, 20);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
float boxSize = 20;
|
||||
float margin = boxSize*2;
|
||||
float depth = 400;
|
||||
color boxFill;
|
||||
|
||||
PShape grid;
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 360, LWJGL);
|
||||
frameRate(120);
|
||||
noStroke();
|
||||
|
||||
grid = createShape(PShape.GROUP);
|
||||
|
||||
// Build grid using multiple translations
|
||||
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
|
||||
for (float j =- height+margin; j <= height-margin; j += boxSize){
|
||||
for (float k =- width+margin; k <= width-margin; k += boxSize){
|
||||
// Base fill color on counter values, abs function
|
||||
// ensures values stay within legal range
|
||||
boxFill = color(abs(i), abs(j), abs(k), 50);
|
||||
|
||||
PShape cube = createShape(QUADS);
|
||||
cube.noStroke();
|
||||
cube.fill(boxFill);
|
||||
|
||||
float w = boxSize;
|
||||
float h = boxSize;
|
||||
float d = boxSize;
|
||||
float shiftX = k;
|
||||
float shiftY = j;
|
||||
float shiftZ = i;
|
||||
|
||||
// Front face
|
||||
cube.normal(0, 0, 1);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
|
||||
// Back face
|
||||
cube.normal(0, 0, -1);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
|
||||
// Left face
|
||||
cube.normal(1, 0, 0);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
|
||||
// Right face
|
||||
cube.normal(-1, 0, 0);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
|
||||
// Top face
|
||||
cube.normal(0, 1, 0);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, -h/2 + shiftY, +d/2 + shiftZ);
|
||||
|
||||
// Bottom face
|
||||
cube.normal(0, -1, 0);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, -d/2 + shiftZ);
|
||||
cube.vertex(+w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
cube.vertex(-w/2 + shiftX, +h/2 + shiftY, +d/2 + shiftZ);
|
||||
|
||||
cube.end();
|
||||
grid.addChild(cube);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
|
||||
hint(DISABLE_DEPTH_TEST);
|
||||
|
||||
// Center and spin grid
|
||||
pushMatrix();
|
||||
translate(width/2, height/2, -depth);
|
||||
rotateY(frameCount * 0.01);
|
||||
rotateX(frameCount * 0.01);
|
||||
|
||||
shape(grid);
|
||||
popMatrix();
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
fill(0);
|
||||
text("fps: " + frate, 10, 20);
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
PImage sprite;
|
||||
|
||||
int npartTotal = 10000;
|
||||
int npartPerFrame = 25;
|
||||
float speed = 1.0;
|
||||
float gravity = 0.05;
|
||||
float partSize = 20;
|
||||
|
||||
int partLifetime;
|
||||
PVector positions[];
|
||||
PVector velocities[];
|
||||
int lifetimes[];
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, LWJGL);
|
||||
frameRate(240);
|
||||
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
partLifetime = npartTotal / npartPerFrame;
|
||||
initPositions();
|
||||
initVelocities();
|
||||
initLifetimes();
|
||||
|
||||
// Writing to the depth buffer is disabled to avoid rendering
|
||||
// artifacts due to the fact that the particles are semi-transparent
|
||||
// but not z-sorted.
|
||||
hint(DISABLE_DEPTH_MASK);
|
||||
|
||||
// Testing some hints
|
||||
//hint(DISABLE_TRANSFORM_CACHE);
|
||||
//hint(ENABLE_ACCURATE_2D);
|
||||
}
|
||||
|
||||
void draw () {
|
||||
background(0);
|
||||
|
||||
for (int n = 0; n < npartTotal; n++) {
|
||||
lifetimes[n]++;
|
||||
if (lifetimes[n] == partLifetime) {
|
||||
lifetimes[n] = 0;
|
||||
}
|
||||
|
||||
if (0 <= lifetimes[n]) {
|
||||
float opacity = 1.0 - float(lifetimes[n]) / partLifetime;
|
||||
|
||||
if (lifetimes[n] == 0) {
|
||||
// Re-spawn dead particle
|
||||
positions[n].x = mouseX;
|
||||
positions[n].y = mouseY;
|
||||
|
||||
float angle = random(0, TWO_PI);
|
||||
float s = random(0.5 * speed, 0.5 * speed);
|
||||
velocities[n].x = s * cos(angle);
|
||||
velocities[n].y = s * sin(angle);
|
||||
} else {
|
||||
positions[n].x += velocities[n].x;
|
||||
positions[n].y += velocities[n].y;
|
||||
|
||||
velocities[n].y += gravity;
|
||||
}
|
||||
drawParticle(positions[n], opacity);
|
||||
}
|
||||
}
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
}
|
||||
|
||||
void drawParticle(PVector center, float opacity) {
|
||||
beginShape(QUAD);
|
||||
noStroke();
|
||||
tint(255, opacity * 255);
|
||||
texture(sprite);
|
||||
normal(0, 0, 1);
|
||||
vertex(center.x - partSize/2, center.y - partSize/2, 0, 0);
|
||||
vertex(center.x + partSize/2, center.y - partSize/2, sprite.width, 0);
|
||||
vertex(center.x + partSize/2, center.y + partSize/2, sprite.width, sprite.height);
|
||||
vertex(center.x - partSize/2, center.y + partSize/2, 0, sprite.height);
|
||||
endShape();
|
||||
}
|
||||
|
||||
void initPositions() {
|
||||
positions = new PVector[npartTotal];
|
||||
for (int n = 0; n < positions.length; n++) {
|
||||
positions[n] = new PVector();
|
||||
}
|
||||
}
|
||||
|
||||
void initVelocities() {
|
||||
velocities = new PVector[npartTotal];
|
||||
for (int n = 0; n < velocities.length; n++) {
|
||||
velocities[n] = new PVector();
|
||||
}
|
||||
}
|
||||
|
||||
void initLifetimes() {
|
||||
// Initializing particles with negative lifetimes so they are added
|
||||
// progressively into the screen during the first frames of the sketch
|
||||
lifetimes = new int[npartTotal];
|
||||
int t = -1;
|
||||
for (int n = 0; n < lifetimes.length; n++) {
|
||||
if (n % npartPerFrame == 0) {
|
||||
t++;
|
||||
}
|
||||
lifetimes[n] = -t;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
PShape particles;
|
||||
PImage sprite;
|
||||
|
||||
int npartTotal = 10000;
|
||||
int npartPerFrame = 25;
|
||||
float speed = 1.0;
|
||||
float gravity = 0.05;
|
||||
float partSize = 20;
|
||||
|
||||
int partLifetime;
|
||||
PVector velocities[];
|
||||
int lifetimes[];
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, LWJGL);
|
||||
frameRate(240);
|
||||
|
||||
particles = createShape(PShape.GROUP);
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
for (int n = 0; n < npartTotal; n++) {
|
||||
PShape part = createShape(QUAD);
|
||||
part.noStroke();
|
||||
part.texture(sprite);
|
||||
part.normal(0, 0, 1);
|
||||
part.vertex(-partSize/2, -partSize/2, 0, 0);
|
||||
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
|
||||
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
|
||||
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
|
||||
part.end();
|
||||
particles.addChild(part);
|
||||
}
|
||||
|
||||
partLifetime = npartTotal / npartPerFrame;
|
||||
initVelocities();
|
||||
initLifetimes();
|
||||
|
||||
// Writing to the depth buffer is disabled to avoid rendering
|
||||
// artifacts due to the fact that the particles are semi-transparent
|
||||
// but not z-sorted.
|
||||
hint(DISABLE_DEPTH_MASK);
|
||||
}
|
||||
|
||||
void draw () {
|
||||
background(0);
|
||||
|
||||
for (int n = 0; n < particles.getChildCount(); n++) {
|
||||
PShape part = particles.getChild(n);
|
||||
|
||||
lifetimes[n]++;
|
||||
if (lifetimes[n] == partLifetime) {
|
||||
lifetimes[n] = 0;
|
||||
}
|
||||
|
||||
if (0 <= lifetimes[n]) {
|
||||
float opacity = 1.0 - float(lifetimes[n]) / partLifetime;
|
||||
part.tint(255, opacity * 255);
|
||||
|
||||
if (lifetimes[n] == 0) {
|
||||
// Re-spawn dead particle
|
||||
part.center(mouseX, mouseY);
|
||||
float angle = random(0, TWO_PI);
|
||||
float s = random(0.5 * speed, 0.5 * speed);
|
||||
velocities[n].x = s * cos(angle);
|
||||
velocities[n].y = s * sin(angle);
|
||||
} else {
|
||||
part.translate(velocities[n].x, velocities[n].y);
|
||||
velocities[n].y += gravity;
|
||||
}
|
||||
} else {
|
||||
part.tint(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
shape(particles);
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
}
|
||||
|
||||
void initVelocities() {
|
||||
velocities = new PVector[npartTotal];
|
||||
for (int n = 0; n < velocities.length; n++) {
|
||||
velocities[n] = new PVector();
|
||||
}
|
||||
}
|
||||
|
||||
void initLifetimes() {
|
||||
// Initializing particles with negative lifetimes so they are added
|
||||
// progressively into the screen during the first frames of the sketch
|
||||
lifetimes = new int[npartTotal];
|
||||
int t = -1;
|
||||
for (int n = 0; n < lifetimes.length; n++) {
|
||||
if (n % npartPerFrame == 0) {
|
||||
t++;
|
||||
}
|
||||
lifetimes[n] = -t;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/**
|
||||
* Esfera
|
||||
* by David Pena.
|
||||
*
|
||||
* Distribucion aleatoria uniforme sobre la superficie de una esfera.
|
||||
*/
|
||||
|
||||
import processing.lwjgl.*;
|
||||
|
||||
int cuantos = 16000;
|
||||
pelo[] lista ;
|
||||
float[] z = new float[cuantos];
|
||||
float[] phi = new float[cuantos];
|
||||
float[] largos = new float[cuantos];
|
||||
float radio = 200;
|
||||
float rx = 0;
|
||||
float ry =0;
|
||||
|
||||
void setup() {
|
||||
size(1024, 768, LWJGL);
|
||||
radio = height/3.5;
|
||||
|
||||
lista = new pelo[cuantos];
|
||||
for (int i=0; i<cuantos; i++){
|
||||
lista[i] = new pelo();
|
||||
}
|
||||
noiseDetail(3);
|
||||
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
translate(width/2,height/2);
|
||||
|
||||
float rxp = ((mouseX-(width/2))*0.005);
|
||||
float ryp = ((mouseY-(height/2))*0.005);
|
||||
rx = (rx*0.9)+(rxp*0.1);
|
||||
ry = (ry*0.9)+(ryp*0.1);
|
||||
rotateY(rx);
|
||||
rotateX(ry);
|
||||
fill(0);
|
||||
noStroke();
|
||||
sphere(radio);
|
||||
|
||||
for (int i=0;i<cuantos;i++){
|
||||
lista[i].dibujar();
|
||||
|
||||
}
|
||||
if (frameCount % 10 == 0) {
|
||||
println(frameRate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class pelo
|
||||
{
|
||||
float z = random(-radio,radio);
|
||||
float phi = random(TWO_PI);
|
||||
float largo = random(1.15,1.2);
|
||||
float theta = asin(z/radio);
|
||||
|
||||
void dibujar(){
|
||||
|
||||
float off = (noise(millis() * 0.0005,sin(phi))-0.5) * 0.3;
|
||||
float offb = (noise(millis() * 0.0007,sin(z) * 0.01)-0.5) * 0.3;
|
||||
|
||||
float thetaff = theta+off;
|
||||
float phff = phi+offb;
|
||||
float x = radio * cos(theta) * cos(phi);
|
||||
float y = radio * cos(theta) * sin(phi);
|
||||
float z = radio * sin(theta);
|
||||
float msx= screenX(x,y,z);
|
||||
float msy= screenY(x,y,z);
|
||||
|
||||
float xo = radio * cos(thetaff) * cos(phff);
|
||||
float yo = radio * cos(thetaff) * sin(phff);
|
||||
float zo = radio * sin(thetaff);
|
||||
|
||||
float xb = xo * largo;
|
||||
float yb = yo * largo;
|
||||
float zb = zo * largo;
|
||||
|
||||
strokeWeight(1);
|
||||
beginShape(LINES);
|
||||
stroke(0);
|
||||
vertex(x,y,z);
|
||||
stroke(200,150);
|
||||
vertex(xb,yb,zb);
|
||||
endShape();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
public void setup() {
|
||||
size(800, 600, LWJGL);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(255);
|
||||
stroke(0, 10);
|
||||
for (int i = 0; i < 50000; i++) {
|
||||
float x0 = random(width);
|
||||
float y0 = random(height);
|
||||
float z0 = random(-100, 100);
|
||||
float x1 = random(width);
|
||||
float y1 = random(height);
|
||||
float z1 = random(-100, 100);
|
||||
|
||||
// purely 2D lines will trigger the GLU
|
||||
// tessellator to add accurate line caps,
|
||||
// but performance will be substantially
|
||||
// lower.
|
||||
line(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
if (frameCount % 10 == 0) println(frameRate);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
public void setup() {
|
||||
size(800, 600, LWJGL);
|
||||
|
||||
noStroke();
|
||||
fill(0, 1);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(255);
|
||||
for (int i = 0; i < 50000; i++) {
|
||||
float x = random(width);
|
||||
float y = random(height);
|
||||
rect(x, y, 30, 30);
|
||||
}
|
||||
if (frameCount % 10 == 0) println(frameRate);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
PImage sprite;
|
||||
|
||||
int npartTotal = 50000;
|
||||
float partSize = 20;
|
||||
|
||||
PVector positions[];
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(800, 600, LWJGL);
|
||||
frameRate(240);
|
||||
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
initPositions();
|
||||
|
||||
// Writing to the depth buffer is disabled to avoid rendering
|
||||
// artifacts due to the fact that the particles are semi-transparent
|
||||
// but not z-sorted.
|
||||
hint(DISABLE_DEPTH_MASK);
|
||||
}
|
||||
|
||||
void draw () {
|
||||
background(0);
|
||||
|
||||
translate(width/2, height/2);
|
||||
rotateY(frameCount * 0.01);
|
||||
|
||||
for (int n = 0; n < npartTotal; n++) {
|
||||
drawParticle(positions[n]);
|
||||
}
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
}
|
||||
|
||||
void drawParticle(PVector center) {
|
||||
beginShape(QUAD);
|
||||
noStroke();
|
||||
tint(255);
|
||||
texture(sprite);
|
||||
normal(0, 0, 1);
|
||||
vertex(center.x - partSize/2, center.y - partSize/2, center.z, 0, 0);
|
||||
vertex(center.x + partSize/2, center.y - partSize/2, center.z, sprite.width, 0);
|
||||
vertex(center.x + partSize/2, center.y + partSize/2, center.z, sprite.width, sprite.height);
|
||||
vertex(center.x - partSize/2, center.y + partSize/2, center.z, 0, sprite.height);
|
||||
endShape();
|
||||
}
|
||||
|
||||
void initPositions() {
|
||||
positions = new PVector[npartTotal];
|
||||
for (int n = 0; n < positions.length; n++) {
|
||||
positions[n] = new PVector(random(-500, +500), random(-500, +500), random(-500, +500));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
PShape particles;
|
||||
PImage sprite;
|
||||
|
||||
int npartTotal = 50000;
|
||||
float partSize = 20;
|
||||
|
||||
int fcount, lastm;
|
||||
float frate;
|
||||
int fint = 3;
|
||||
|
||||
void setup() {
|
||||
size(800, 600, LWJGL);
|
||||
frameRate(240);
|
||||
|
||||
particles = createShape(PShape.GROUP);
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
for (int n = 0; n < npartTotal; n++) {
|
||||
float cx = random(-500, +500);
|
||||
float cy = random(-500, +500);
|
||||
float cz = random(-500, +500);
|
||||
|
||||
PShape part = createShape(QUAD);
|
||||
part.noStroke();
|
||||
part.tint(255);
|
||||
part.texture(sprite);
|
||||
part.normal(0, 0, 1);
|
||||
part.vertex(cx - partSize/2, cy - partSize/2, cz, 0, 0);
|
||||
part.vertex(cx + partSize/2, cy - partSize/2, cz, sprite.width, 0);
|
||||
part.vertex(cx + partSize/2, cy + partSize/2, cz, sprite.width, sprite.height);
|
||||
part.vertex(cx - partSize/2, cy + partSize/2, cz, 0, sprite.height);
|
||||
part.end();
|
||||
particles.addChild(part);
|
||||
}
|
||||
|
||||
// Writing to the depth buffer is disabled to avoid rendering
|
||||
// artifacts due to the fact that the particles are semi-transparent
|
||||
// but not z-sorted.
|
||||
hint(DISABLE_DEPTH_MASK);
|
||||
}
|
||||
|
||||
void draw () {
|
||||
background(0);
|
||||
|
||||
translate(width/2, height/2);
|
||||
rotateY(frameCount * 0.01);
|
||||
|
||||
shape(particles);
|
||||
|
||||
fcount += 1;
|
||||
int m = millis();
|
||||
if (m - lastm > 1000 * fint) {
|
||||
frate = float(fcount) / fint;
|
||||
fcount = 0;
|
||||
lastm = m;
|
||||
println("fps: " + frate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import processing.lwjgl.*;
|
||||
|
||||
public void setup() {
|
||||
size(800, 600, LWJGL);
|
||||
fill(0);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(255);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
float x = random(width);
|
||||
float y = random(height);
|
||||
text("HELLO", x, y);
|
||||
}
|
||||
if (frameCount % 10 == 0) println(frameRate);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
# If you want to support more platforms, see the jogl.dev.java.net to get the
|
||||
# natives libraries for the platform in question (i.e. Solaris).
|
||||
|
||||
name = lwOpenGL
|
||||
|
||||
# In releases later than (but not including) 1.0.9, the applet JAR files
|
||||
# are downloaded directly from Sun, so that a single version is cached
|
||||
# on the user's computer, rather than increasing the download size with
|
||||
# the versions for each platform.
|
||||
applet = lwopengl.jar
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vertColor;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform sampler2D textureSampler;
|
||||
|
||||
uniform vec2 texcoordOffset;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexcoord;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(textureSampler, vertTexcoord.st) * vertColor;
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 projmodelviewMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
uniform mat4 texcoordMatrix;
|
||||
|
||||
uniform int lightCount;
|
||||
uniform vec4 lightPosition[8];
|
||||
uniform vec3 lightNormal[8];
|
||||
uniform vec3 lightAmbient[8];
|
||||
uniform vec3 lightDiffuse[8];
|
||||
uniform vec3 lightSpecular[8];
|
||||
uniform vec3 lightFalloffCoefficients[8];
|
||||
uniform vec2 lightSpotParameters[8];
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
attribute vec3 inNormal;
|
||||
attribute vec2 inTexcoord;
|
||||
|
||||
attribute vec4 inAmbient;
|
||||
attribute vec4 inSpecular;
|
||||
attribute vec4 inEmissive;
|
||||
attribute float inShine;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexcoord;
|
||||
|
||||
const float zero_float = 0.0;
|
||||
const float one_float = 1.0;
|
||||
const vec3 zero_vec3 = vec3(0);
|
||||
|
||||
float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
|
||||
vec3 lpv = lightPos - vertPos;
|
||||
vec3 dist = vec3(one_float);
|
||||
dist.z = dot(lpv, lpv);
|
||||
dist.y = sqrt(dist.z);
|
||||
return one_float / dot(dist, coeff);
|
||||
}
|
||||
|
||||
float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
|
||||
vec3 lpv = normalize(lightPos - vertPos);
|
||||
float spotCos = dot(-lightNorm, lpv);
|
||||
return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
|
||||
}
|
||||
|
||||
float lambertFactor(vec3 lightDir, vec3 vecNormal) {
|
||||
return max(zero_float, dot(lightDir, vecNormal));
|
||||
}
|
||||
|
||||
float blinnPhongFactor(vec3 lightDir, vec3 lightPos, vec3 vecNormal, float shine) {
|
||||
vec3 ldp = normalize(lightDir - lightPos);
|
||||
return pow(max(zero_float, dot(ldp, vecNormal)), shine);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Vertex in clip coordinates
|
||||
gl_Position = projmodelviewMatrix * inVertex;
|
||||
|
||||
// Vertex in eye coordinates
|
||||
vec3 ecVertex = vec3(modelviewMatrix * inVertex);
|
||||
|
||||
// Normal vector in eye coordinates
|
||||
vec3 ecNormal = normalize(normalMatrix * inNormal);
|
||||
|
||||
// Light calculations
|
||||
vec3 totalAmbient = vec3(0, 0, 0);
|
||||
vec3 totalDiffuse = vec3(0, 0, 0);
|
||||
vec3 totalSpecular = vec3(0, 0, 0);
|
||||
for (int i = 0; i < lightCount; i++) {
|
||||
vec3 lightPos = lightPosition[i].xyz;
|
||||
bool isDir = zero_float < lightPosition[i].w;
|
||||
float spotCos = lightSpotParameters[i].x;
|
||||
float spotExp = lightSpotParameters[i].y;
|
||||
|
||||
vec3 lightDir;
|
||||
float falloff;
|
||||
float spotf;
|
||||
|
||||
if (isDir) {
|
||||
falloff = one_float;
|
||||
lightDir = -lightNormal[i];
|
||||
} else {
|
||||
falloff = falloffFactor(lightPos, ecVertex, lightFalloffCoefficients[i]);
|
||||
lightDir = normalize(lightPos - ecVertex);
|
||||
}
|
||||
|
||||
spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i],
|
||||
spotCos, spotExp)
|
||||
: one_float;
|
||||
|
||||
if (any(greaterThan(lightAmbient[i], zero_vec3))) {
|
||||
totalAmbient += lightAmbient[i] * falloff;
|
||||
}
|
||||
|
||||
if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
|
||||
totalDiffuse += lightDiffuse[i] * falloff * spotf *
|
||||
lambertFactor(lightDir, ecNormal);
|
||||
}
|
||||
|
||||
if (any(greaterThan(lightSpecular[i], zero_vec3))) {
|
||||
totalSpecular += lightSpecular[i] * falloff * spotf *
|
||||
blinnPhongFactor(lightDir, lightPos, ecNormal, inShine);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculating final color as result of all lights (plus emissive term)
|
||||
vertColor = vec4(totalAmbient, 1) * inAmbient +
|
||||
vec4(totalDiffuse, 1) * inColor +
|
||||
vec4(totalSpecular, 1) * inSpecular +
|
||||
inEmissive;
|
||||
|
||||
// Calculating texture coordinates, with r and q set both to one
|
||||
vertTexcoord = texcoordMatrix * vec4(inTexcoord, 1.0, 1.0);
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 projmodelviewMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
|
||||
uniform int lightCount;
|
||||
uniform vec4 lightPosition[8];
|
||||
uniform vec3 lightNormal[8];
|
||||
uniform vec3 lightAmbient[8];
|
||||
uniform vec3 lightDiffuse[8];
|
||||
uniform vec3 lightSpecular[8];
|
||||
uniform vec3 lightFalloffCoefficients[8];
|
||||
uniform vec2 lightSpotParameters[8];
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
attribute vec3 inNormal;
|
||||
|
||||
attribute vec4 inAmbient;
|
||||
attribute vec4 inSpecular;
|
||||
attribute vec4 inEmissive;
|
||||
attribute float inShine;
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
const float zero_float = 0.0;
|
||||
const float one_float = 1.0;
|
||||
const vec3 zero_vec3 = vec3(0);
|
||||
|
||||
float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
|
||||
vec3 lpv = lightPos - vertPos;
|
||||
vec3 dist = vec3(one_float);
|
||||
dist.z = dot(lpv, lpv);
|
||||
dist.y = sqrt(dist.z);
|
||||
return one_float / dot(dist, coeff);
|
||||
}
|
||||
|
||||
float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
|
||||
vec3 lpv = normalize(lightPos - vertPos);
|
||||
float spotCos = dot(-lightNorm, lpv);
|
||||
return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
|
||||
}
|
||||
|
||||
float lambertFactor(vec3 lightDir, vec3 vecNormal) {
|
||||
return max(zero_float, dot(lightDir, vecNormal));
|
||||
}
|
||||
|
||||
float blinnPhongFactor(vec3 lightDir, vec3 lightPos, vec3 vecNormal, float shine) {
|
||||
vec3 ldp = normalize(lightDir - lightPos);
|
||||
return pow(max(zero_float, dot(ldp, vecNormal)), shine);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Vertex in clip coordinates
|
||||
gl_Position = projmodelviewMatrix * inVertex;
|
||||
|
||||
// Vertex in eye coordinates
|
||||
vec3 ecVertex = vec3(modelviewMatrix * inVertex);
|
||||
|
||||
// Normal vector in eye coordinates
|
||||
vec3 ecNormal = normalize(normalMatrix * inNormal);
|
||||
|
||||
// Light calculations
|
||||
vec3 totalAmbient = vec3(0, 0, 0);
|
||||
vec3 totalDiffuse = vec3(0, 0, 0);
|
||||
vec3 totalSpecular = vec3(0, 0, 0);
|
||||
for (int i = 0; i < lightCount; i++) {
|
||||
vec3 lightPos = lightPosition[i].xyz;
|
||||
bool isDir = zero_float < lightPosition[i].w;
|
||||
float spotCos = lightSpotParameters[i].x;
|
||||
float spotExp = lightSpotParameters[i].y;
|
||||
|
||||
vec3 lightDir;
|
||||
float falloff;
|
||||
float spotf;
|
||||
|
||||
if (isDir) {
|
||||
falloff = one_float;
|
||||
lightDir = -lightNormal[i];
|
||||
} else {
|
||||
falloff = falloffFactor(lightPos, ecVertex, lightFalloffCoefficients[i]);
|
||||
lightDir = normalize(lightPos - ecVertex);
|
||||
}
|
||||
|
||||
spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i],
|
||||
spotCos, spotExp)
|
||||
: one_float;
|
||||
|
||||
if (any(greaterThan(lightAmbient[i], zero_vec3))) {
|
||||
totalAmbient += lightAmbient[i] * falloff;
|
||||
}
|
||||
|
||||
if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
|
||||
totalDiffuse += lightDiffuse[i] * falloff * spotf *
|
||||
lambertFactor(lightDir, ecNormal);
|
||||
}
|
||||
|
||||
if (any(greaterThan(lightSpecular[i], zero_vec3))) {
|
||||
totalSpecular += lightSpecular[i] * falloff * spotf *
|
||||
blinnPhongFactor(lightDir, lightPos, ecNormal, inShine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Calculating final color as result of all lights (plus emissive term)
|
||||
vertColor = vec4(totalAmbient, 1) * inAmbient +
|
||||
vec4(totalDiffuse, 1) * inColor +
|
||||
vec4(totalSpecular, 1) * inSpecular +
|
||||
inEmissive;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 projmodelviewMatrix;
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = projmodelviewMatrix * inVertex;
|
||||
|
||||
vertColor = inColor;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 projmodelviewMatrix;
|
||||
uniform mat4 texcoordMatrix;
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
attribute vec2 inTexcoord;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexcoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = projmodelviewMatrix * inVertex;
|
||||
|
||||
vertColor = inColor;
|
||||
vertTexcoord = texcoordMatrix * vec4(inTexcoord, 1.0, 1.0);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vertColor;
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Based on glsl code from the dpix library:
|
||||
http://gfx.cs.princeton.edu/proj/dpix/
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 modelviewMatrix;
|
||||
uniform mat4 projectionMatrix;
|
||||
|
||||
uniform vec4 viewport;
|
||||
uniform int perspective;
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
attribute vec4 inDirWidth;
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
vec3 clipToWindow(vec4 clip, vec4 viewport) {
|
||||
vec3 post_div = clip.xyz / clip.w;
|
||||
vec2 xypos = (post_div.xy + vec2(1.0, 1.0)) * 0.5 * viewport.zw;
|
||||
return vec3(xypos, post_div.z * 0.5 + 0.5);
|
||||
}
|
||||
|
||||
vec4 windowToClipVector(vec2 window, vec4 viewport, float clip_w) {
|
||||
vec2 xypos = (window / viewport.zw) * 2.0;
|
||||
return vec4(xypos, 0.0, 0.0) * clip_w;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 pos_p = inVertex;
|
||||
vec4 pos_q = vec4(inDirWidth.xyz, 1);
|
||||
|
||||
vec4 v_p = modelviewMatrix * pos_p;
|
||||
vec4 clip_p = projectionMatrix * v_p;
|
||||
|
||||
vec4 v_q = modelviewMatrix * pos_q;
|
||||
vec4 clip_q = projectionMatrix * v_q;
|
||||
|
||||
vec3 window_p = clipToWindow(clip_p, viewport);
|
||||
vec3 window_q = clipToWindow(clip_q, viewport);
|
||||
vec3 tangent = window_q - window_p;
|
||||
|
||||
float segment_length = length(tangent.xy);
|
||||
vec2 perp = normalize(vec2(-tangent.y, tangent.x));
|
||||
float thickness = inDirWidth.w;
|
||||
vec2 window_offset = perp * thickness;
|
||||
|
||||
if (0 < perspective) {
|
||||
// Perspective correction (lines will look thiner as they move away
|
||||
// from the view position).
|
||||
gl_Position.xy = clip_p.xy + window_offset.xy;
|
||||
gl_Position.zw = clip_p.zw;
|
||||
} else {
|
||||
// No perspective correction.
|
||||
float clip_p_w = clip_p.w;
|
||||
vec4 offset_p = windowToClipVector(window_offset, viewport, clip_p_w);
|
||||
gl_Position = clip_p + offset_p;
|
||||
}
|
||||
|
||||
vertColor = inColor;
|
||||
}
|
||||
@@ -1,354 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
import processing.core.PFont;
|
||||
import processing.core.PImage;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* All the infrastructure needed for optimized font rendering
|
||||
* in OpenGL. Basically, this special class is needed because
|
||||
* fonts in Processing are handled by a separate PImage for each
|
||||
* gyph. For performance reasons, all these glyphs should be
|
||||
* stored in a single OpenGL texture (otherwise, rendering a
|
||||
* string of text would involve binding and unbinding several
|
||||
* textures.
|
||||
* PFontTexture manages the correspondence between individual
|
||||
* glyphs and the large OpenGL texture containing them. Also,
|
||||
* in the case that the font size is very large, one single
|
||||
* OpenGL texture might not be enough to store all the glyphs,
|
||||
* so PFontTexture also takes care of spreading a single font
|
||||
* over several textures.
|
||||
* By Andres Colubri
|
||||
*
|
||||
*/
|
||||
class PFontTexture implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsLWJGL pg;
|
||||
protected PGL pgl;
|
||||
protected PGL.Context context;
|
||||
protected PFont font;
|
||||
|
||||
protected int maxTexWidth;
|
||||
protected int maxTexHeight;
|
||||
protected int offsetX;
|
||||
protected int offsetY;
|
||||
protected int lineHeight;
|
||||
protected PTexture[] textures = null;
|
||||
protected PImage[] images = null;
|
||||
protected int currentTex;
|
||||
protected int lastTex;
|
||||
protected TextureInfo[] glyphTexinfos;
|
||||
protected HashMap<PFont.Glyph, TextureInfo> texinfoMap;
|
||||
|
||||
public PFontTexture(PApplet parent, PFont font, int maxw, int maxh) {
|
||||
this.parent = parent;
|
||||
this.font = font;
|
||||
pg = (PGraphicsLWJGL)parent.g;
|
||||
pgl = pg.pgl;
|
||||
context = pgl.getContext();
|
||||
|
||||
initTexture(maxw, maxh);
|
||||
}
|
||||
|
||||
|
||||
protected void allocate() {
|
||||
// Nothing to do here: the font textures will allocate
|
||||
// themselves.
|
||||
}
|
||||
|
||||
|
||||
protected void initTexture(int w, int h) {
|
||||
maxTexWidth = w;
|
||||
maxTexHeight = h;
|
||||
|
||||
currentTex = -1;
|
||||
lastTex = -1;
|
||||
|
||||
addTexture();
|
||||
|
||||
offsetX = 0;
|
||||
offsetY = 0;
|
||||
lineHeight = 0;
|
||||
|
||||
texinfoMap = new HashMap<PFont.Glyph, TextureInfo>();
|
||||
glyphTexinfos = new TextureInfo[font.getGlyphCount()];
|
||||
addAllGlyphsToTexture();
|
||||
}
|
||||
|
||||
|
||||
public boolean addTexture() {
|
||||
int w, h;
|
||||
boolean resize;
|
||||
|
||||
w = maxTexWidth;
|
||||
if (-1 < currentTex && textures[currentTex].glHeight < maxTexHeight) {
|
||||
// The height of the current texture is less than the maximum, this
|
||||
// means we can replace it with a larger texture.
|
||||
h = PApplet.min(2 * textures[currentTex].glHeight, maxTexHeight);
|
||||
resize = true;
|
||||
} else {
|
||||
h = PApplet.min(PGraphicsLWJGL.maxTextureSize, 512, maxTexHeight / 4);
|
||||
resize = false;
|
||||
}
|
||||
|
||||
PTexture tex = new PTexture(parent, w, h, new PTexture.Parameters(ARGB, BILINEAR));
|
||||
|
||||
if (textures == null) {
|
||||
textures = new PTexture[1];
|
||||
textures[0] = tex;
|
||||
images = new PImage[1];
|
||||
images[0] = pg.wrapTexture(tex);
|
||||
currentTex = 0;
|
||||
} else if (resize) {
|
||||
// Replacing old smaller texture with larger one.
|
||||
// But first we must copy the contents of the older
|
||||
// texture into the new one.
|
||||
PTexture tex0 = textures[currentTex];
|
||||
tex.put(tex0);
|
||||
textures[currentTex] = tex;
|
||||
|
||||
images[currentTex].setCache(pg, tex);
|
||||
images[currentTex].width = tex.width;
|
||||
images[currentTex].height = tex.height;
|
||||
} else {
|
||||
// Adding new texture to the list.
|
||||
PTexture[] tempTex = textures;
|
||||
textures = new PTexture[textures.length + 1];
|
||||
PApplet.arrayCopy(tempTex, textures, tempTex.length);
|
||||
textures[tempTex.length] = tex;
|
||||
currentTex = textures.length - 1;
|
||||
|
||||
PImage[] tempImg = images;
|
||||
images = new PImage[textures.length + 1];
|
||||
PApplet.arrayCopy(tempImg, images, tempImg.length);
|
||||
images[tempImg.length] = pg.wrapTexture(tex);
|
||||
}
|
||||
lastTex = currentTex;
|
||||
|
||||
// Make sure that the current texture is bound.
|
||||
//tex.bind();
|
||||
|
||||
return resize;
|
||||
}
|
||||
|
||||
|
||||
public void setFirstTexture() {
|
||||
setTexture(0);
|
||||
}
|
||||
|
||||
|
||||
public void setTexture(int idx) {
|
||||
if (0 <= idx && idx < textures.length) {
|
||||
currentTex = idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PImage getTexture(int idx) {
|
||||
if (0 <= idx && idx < images.length) {
|
||||
return images[idx];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public PImage getCurrentTexture() {
|
||||
return getTexture(currentTex);
|
||||
}
|
||||
|
||||
|
||||
// Add all the current glyphs to opengl texture.
|
||||
public void addAllGlyphsToTexture() {
|
||||
// loop over current glyphs.
|
||||
for (int i = 0; i < font.getGlyphCount(); i++) {
|
||||
addToTexture(i, font.getGlyph(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateGlyphsTexCoords() {
|
||||
// loop over current glyphs.
|
||||
for (int i = 0; i < font.getGlyphCount(); i++) {
|
||||
TextureInfo tinfo = glyphTexinfos[i];
|
||||
if (tinfo != null && tinfo.texIndex == currentTex) {
|
||||
tinfo.updateUV();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TextureInfo getTexInfo(PFont.Glyph glyph) {
|
||||
TextureInfo info = texinfoMap.get(glyph);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
public TextureInfo addToTexture(PFont.Glyph glyph) {
|
||||
int n = glyphTexinfos.length;
|
||||
if (n == 0) {
|
||||
glyphTexinfos = new TextureInfo[1];
|
||||
}
|
||||
addToTexture(n, glyph);
|
||||
return glyphTexinfos[n];
|
||||
}
|
||||
|
||||
|
||||
// Adds this glyph to the opengl texture in PFont.
|
||||
protected void addToTexture(int idx, PFont.Glyph glyph) {
|
||||
// We add one pixel to avoid issues when sampling the font texture at fractional
|
||||
// screen positions. I.e.: the pixel on the screen only contains half of the
|
||||
// font rectangle, so it would sample half of the color from the glyph
|
||||
// area in the texture, and the other half from the contiguous pixel. If the
|
||||
// later contains a portion of the neighbor glyph and former doesn't, this
|
||||
// would result in a shaded pixel when the correct output is blank.
|
||||
// This is a consequence of putting all the glyphs in a common texture with
|
||||
// bilinear sampling.
|
||||
int w = 1 + glyph.width + 1;
|
||||
int h = 1 + glyph.height + 1;
|
||||
|
||||
// Converting the pixels array from the PImage into a valid RGBA array for OpenGL.
|
||||
int[] rgba = new int[w * h];
|
||||
int t = 0;
|
||||
int p = 0;
|
||||
if (PGraphicsLWJGL.BIG_ENDIAN) {
|
||||
java.util.Arrays.fill(rgba, 0, w, 0xFFFFFF00); // Set the first row to blank pixels.
|
||||
t = w;
|
||||
for (int y = 0; y < glyph.height; y++) {
|
||||
rgba[t++] = 0xFFFFFF00; // Set the leftmost pixel in this row as blank
|
||||
for (int x = 0; x < glyph.width; x++) {
|
||||
rgba[t++] = 0xFFFFFF00 | glyph.image.pixels[p++];
|
||||
}
|
||||
rgba[t++] = 0xFFFFFF00; // Set the rightmost pixel in this row as blank
|
||||
}
|
||||
java.util.Arrays.fill(rgba, (h - 1) * w, h * w, 0xFFFFFF00); // Set the last row to blank pixels.
|
||||
} else {
|
||||
java.util.Arrays.fill(rgba, 0, w, 0x00FFFFFF); // Set the first row to blank pixels.
|
||||
t = w;
|
||||
for (int y = 0; y < glyph.height; y++) {
|
||||
rgba[t++] = 0x00FFFFFF; // Set the leftmost pixel in this row as blank
|
||||
for (int x = 0; x < glyph.width; x++) {
|
||||
rgba[t++] = (glyph.image.pixels[p++] << 24) | 0x00FFFFFF;
|
||||
}
|
||||
rgba[t++] = 0x00FFFFFF; // Set the rightmost pixel in this row as blank
|
||||
}
|
||||
java.util.Arrays.fill(rgba, (h - 1) * w, h * w, 0x00FFFFFF); // Set the last row to blank pixels.
|
||||
}
|
||||
|
||||
// Is there room for this glyph in the current line?
|
||||
if (offsetX + w > textures[currentTex].glWidth) {
|
||||
// No room, go to the next line:
|
||||
offsetX = 0;
|
||||
offsetY += lineHeight;
|
||||
lineHeight = 0;
|
||||
}
|
||||
lineHeight = Math.max(lineHeight, h);
|
||||
|
||||
boolean resized = false;
|
||||
if (offsetY + lineHeight > textures[currentTex].glHeight) {
|
||||
// We run out of space in the current texture, so we add a new texture:
|
||||
resized = addTexture();
|
||||
if (resized) {
|
||||
// Because the current texture has been resized, we need to
|
||||
// update the UV coordinates of all the glyphs associated to it:
|
||||
updateGlyphsTexCoords();
|
||||
} else {
|
||||
// A new texture has been created. Reseting texture coordinates
|
||||
// and line.
|
||||
offsetX = 0;
|
||||
offsetY = 0;
|
||||
lineHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastTex == -1) {
|
||||
lastTex = 0;
|
||||
}
|
||||
|
||||
if (currentTex != lastTex || resized) {
|
||||
currentTex = idx;
|
||||
}
|
||||
|
||||
TextureInfo tinfo = new TextureInfo(currentTex, offsetX, offsetY, w, h, rgba);
|
||||
offsetX += w;
|
||||
|
||||
if (idx == glyphTexinfos.length) {
|
||||
TextureInfo[] temp = new TextureInfo[glyphTexinfos.length + 1];
|
||||
System.arraycopy(glyphTexinfos, 0, temp, 0, glyphTexinfos.length);
|
||||
glyphTexinfos = temp;
|
||||
}
|
||||
|
||||
glyphTexinfos[idx] = tinfo;
|
||||
texinfoMap.put(glyph, tinfo);
|
||||
}
|
||||
|
||||
|
||||
public class TextureInfo {
|
||||
public int texIndex;
|
||||
public int width;
|
||||
public int height;
|
||||
public int[] crop;
|
||||
public float u0, u1;
|
||||
public float v0, v1;
|
||||
public int[] pixels;
|
||||
|
||||
|
||||
public TextureInfo(int tidx, int cropX, int cropY, int cropW, int cropH, int[] pix) {
|
||||
texIndex = tidx;
|
||||
crop = new int[4];
|
||||
// The region of the texture corresponding to the glyph is surrounded by a
|
||||
// 1-pixel wide border to avoid artifacts due to bilinear sampling. This is
|
||||
// why the additions and subtractions to the crop values.
|
||||
crop[0] = cropX + 1;
|
||||
crop[1] = cropY + 1 + cropH - 2;
|
||||
crop[2] = cropW - 2;
|
||||
crop[3] = -cropH + 2;
|
||||
pixels = pix;
|
||||
updateUV();
|
||||
updateTex();
|
||||
}
|
||||
|
||||
|
||||
void updateUV() {
|
||||
width = textures[texIndex].glWidth;
|
||||
height = textures[texIndex].glHeight;
|
||||
u0 = (float)crop[0] / (float)width;
|
||||
u1 = u0 + (float)crop[2] / (float)width;
|
||||
v0 = (float)(crop[1] + crop[3]) / (float)height;
|
||||
v1 = v0 - (float)crop[3] / (float)height;
|
||||
}
|
||||
|
||||
|
||||
void updateTex() {
|
||||
textures[texIndex].bind();
|
||||
textures[texIndex].setTexels(pixels, 0, crop[0] - 1, crop[1] + crop[3] - 1, crop[2] + 2, -crop[3] + 2);
|
||||
textures[texIndex].unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,547 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* Encapsulates a Frame Buffer Object for offscreen rendering.
|
||||
* When created with onscreen == true, it represents the normal
|
||||
* framebuffer. Needed by the stack mechanism in OPENGL2 to return
|
||||
* to onscreen rendering after a sequence of pushFramebuffer calls.
|
||||
* It transparently handles the situations when the FBO extension is
|
||||
* not available.
|
||||
*
|
||||
* By Andres Colubri.
|
||||
*/
|
||||
public class PFramebuffer implements PConstants {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsLWJGL pg;
|
||||
protected PGL pgl;
|
||||
|
||||
public int glFboID;
|
||||
public int glDepthBufferID;
|
||||
public int glStencilBufferID;
|
||||
public int glDepthStencilBufferID;
|
||||
public int glColorBufferMultisampleID;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
protected int depthBits;
|
||||
protected int stencilBits;
|
||||
protected boolean combinedDepthStencil;
|
||||
|
||||
protected boolean multisample;
|
||||
protected int nsamples;
|
||||
|
||||
protected int numColorBuffers;
|
||||
protected PTexture[] colorBufferTex;
|
||||
|
||||
protected boolean screenFb;
|
||||
protected boolean noDepth;
|
||||
protected boolean fboMode;
|
||||
|
||||
protected PTexture backupTexture;
|
||||
protected IntBuffer pixelBuffer;
|
||||
|
||||
PFramebuffer(PApplet parent, int w, int h) {
|
||||
this(parent, w, h, 1, 1, 0, 0, false, false);
|
||||
}
|
||||
|
||||
PFramebuffer(PApplet parent, int w, int h, boolean screen) {
|
||||
this(parent, w, h, 1, 1, 0, 0, false, screen);
|
||||
}
|
||||
|
||||
PFramebuffer(PApplet parent, int w, int h, int samples, int colorBuffers,
|
||||
int depthBits, int stencilBits, boolean combinedDepthStencil,
|
||||
boolean screen) {
|
||||
this.parent = parent;
|
||||
pg = (PGraphicsLWJGL)parent.g;
|
||||
pgl = pg.pgl;
|
||||
|
||||
glFboID = 0;
|
||||
glDepthBufferID = 0;
|
||||
glStencilBufferID = 0;
|
||||
glDepthStencilBufferID = 0;
|
||||
glColorBufferMultisampleID = 0;
|
||||
|
||||
fboMode = PGraphicsLWJGL.fboSupported;
|
||||
|
||||
if (screen) {
|
||||
// If this framebuffer is used to represent a on-screen buffer,
|
||||
// then it doesn't make it sense for it to have multisampling,
|
||||
// color, depth or stencil buffers.
|
||||
depthBits = stencilBits = samples = colorBuffers = 0;
|
||||
}
|
||||
|
||||
width = w;
|
||||
height = h;
|
||||
|
||||
if (1 < samples) {
|
||||
multisample = true;
|
||||
nsamples = samples;
|
||||
} else {
|
||||
multisample = false;
|
||||
nsamples = 1;
|
||||
}
|
||||
|
||||
numColorBuffers = colorBuffers;
|
||||
colorBufferTex = new PTexture[numColorBuffers];
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
colorBufferTex[i] = null;
|
||||
}
|
||||
|
||||
if (depthBits < 1 && stencilBits < 1) {
|
||||
this.depthBits = 0;
|
||||
this.stencilBits = 0;
|
||||
this.combinedDepthStencil = false;
|
||||
} else {
|
||||
if (combinedDepthStencil) {
|
||||
// When combined depth/stencil format is required, the depth and stencil bits
|
||||
// are overriden and the 24/8 combination for a 32 bits surface is used.
|
||||
this.depthBits = 24;
|
||||
this.stencilBits = 8;
|
||||
this.combinedDepthStencil = true;
|
||||
} else {
|
||||
this.depthBits = depthBits;
|
||||
this.stencilBits = stencilBits;
|
||||
this.combinedDepthStencil = false;
|
||||
}
|
||||
}
|
||||
|
||||
screenFb = screen;
|
||||
|
||||
allocate();
|
||||
noDepth = false;
|
||||
|
||||
pixelBuffer = null;
|
||||
|
||||
if (!screenFb && !fboMode) {
|
||||
// When FBOs are not available, rendering to texture is implemented by saving a portion of
|
||||
// the screen, doing the "offscreen" rendering on this portion, copying the screen color
|
||||
// buffer to the texture bound as color buffer to this PFramebuffer object and then drawing
|
||||
// the backup texture back on the screen.
|
||||
backupTexture = new PTexture(parent, width, height, new PTexture.Parameters(ARGB, POINT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (glFboID != 0) {
|
||||
pg.finalizeFrameBufferObject(glFboID);
|
||||
}
|
||||
if (glDepthBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glDepthBufferID);
|
||||
}
|
||||
if (glStencilBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glStencilBufferID);
|
||||
}
|
||||
if (glColorBufferMultisampleID != 0) {
|
||||
pg.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
}
|
||||
if (glDepthStencilBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
pgl.glClearColor(0, 0, 0, 0);
|
||||
pgl.glClear(PGL.GL_COLOR_BUFFER_BIT | PGL.GL_DEPTH_BUFFER_BIT | PGL.GL_STENCIL_BUFFER_BIT);
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
|
||||
public void copy(PFramebuffer dest) {
|
||||
pgl.glBindFramebuffer(PGL.GL_READ_FRAMEBUFFER, this.glFboID);
|
||||
pgl.glBindFramebuffer(PGL.GL_DRAW_FRAMEBUFFER, dest.glFboID);
|
||||
pgl.glBlitFramebuffer(0, 0,this.width, this.height, 0, 0, dest.width, dest.height, PGL.GL_COLOR_BUFFER_BIT, PGL.GL_NEAREST);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
if (screenFb) {
|
||||
if (PGraphicsLWJGL.fboSupported) {
|
||||
pgl.glBindFramebuffer(PGL.GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
} else if (fboMode) {
|
||||
pgl.glBindFramebuffer(PGL.GL_FRAMEBUFFER, glFboID);
|
||||
} else {
|
||||
backupScreen();
|
||||
|
||||
if (0 < numColorBuffers) {
|
||||
// Drawing the current contents of the first color buffer to emulate
|
||||
// front-back buffer swap.
|
||||
pg.drawTexture(colorBufferTex[0].glTarget, colorBufferTex[0].glID, width, height, 0, 0, width, height, 0, 0, width, height);
|
||||
}
|
||||
|
||||
if (noDepth) {
|
||||
pgl.glDisable(PGL.GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableDepthTest() {
|
||||
noDepth = true;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
if (noDepth) {
|
||||
// No need to clear depth buffer because depth testing was disabled.
|
||||
if (pg.hintEnabled(DISABLE_DEPTH_TEST)) {
|
||||
pgl.glDisable(PGL.GL_DEPTH_TEST);
|
||||
} else {
|
||||
pgl.glEnable(PGL.GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
if (!screenFb && !fboMode) {
|
||||
copyToColorBuffers();
|
||||
restoreBackup();
|
||||
if (!noDepth) {
|
||||
// Reading the contents of the depth buffer is not possible in OpenGL ES:
|
||||
// http://www.idevgames.com/forum/archive/index.php?t-15828.html
|
||||
// so if this framebuffer uses depth and is offscreen with no FBOs, then
|
||||
// the depth buffer is cleared to avoid artifacts when rendering more stuff
|
||||
// after this offscreen render.
|
||||
// A consequence of this behavior is that all the offscreen rendering when
|
||||
// no FBOs are available should be done before any onscreen drawing.
|
||||
pgl.glClearColor(0, 0, 0, 0);
|
||||
pgl.glClear(PGL.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Saves content of the screen into the backup texture.
|
||||
public void backupScreen() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
copyToTexture(pixelBuffer, backupTexture.glID, backupTexture.glTarget);
|
||||
}
|
||||
|
||||
// Draws the contents of the backup texture to the screen.
|
||||
public void restoreBackup() {
|
||||
pg.drawTexture(backupTexture, 0, 0, width, height, 0, 0, width, height);
|
||||
}
|
||||
|
||||
// Copies current content of screen to color buffers.
|
||||
public void copyToColorBuffers() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
copyToTexture(pixelBuffer, colorBufferTex[i].glID, colorBufferTex[i].glTarget);
|
||||
}
|
||||
}
|
||||
|
||||
public void readPixels() {
|
||||
if (pixelBuffer == null) createPixelBuffer();
|
||||
pixelBuffer.rewind();
|
||||
pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
}
|
||||
|
||||
public void getPixels(int[] pixels) {
|
||||
if (pixelBuffer != null) {
|
||||
pixelBuffer.get(pixels);
|
||||
pixelBuffer.rewind();
|
||||
}
|
||||
}
|
||||
|
||||
public IntBuffer getPixelBuffer() {
|
||||
return pixelBuffer;
|
||||
}
|
||||
|
||||
public boolean hasDepthBuffer() {
|
||||
return 0 < depthBits;
|
||||
}
|
||||
|
||||
public boolean hasStencilBuffer() {
|
||||
return 0 < stencilBits;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Color buffer setters.
|
||||
|
||||
|
||||
public void setColorBuffer(PTexture tex) {
|
||||
setColorBuffers(new PTexture[] { tex }, 1);
|
||||
}
|
||||
|
||||
|
||||
public void setColorBuffers(PTexture[] textures) {
|
||||
setColorBuffers(textures, textures.length);
|
||||
}
|
||||
|
||||
|
||||
public void setColorBuffers(PTexture[] textures, int n) {
|
||||
if (screenFb) return;
|
||||
|
||||
if (numColorBuffers != PApplet.min(n, textures.length)) {
|
||||
throw new RuntimeException("Wrong number of textures to set the color buffers.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
colorBufferTex[i] = textures[i];
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
// Making sure nothing is attached.
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
pgl.glFramebufferTexture2D(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, PGL.GL_TEXTURE_2D, 0, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numColorBuffers; i++) {
|
||||
pgl.glFramebufferTexture2D(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, colorBufferTex[i].glTarget, colorBufferTex[i].glID, 0);
|
||||
}
|
||||
|
||||
validateFbo();
|
||||
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Allocate/release framebuffer.
|
||||
|
||||
|
||||
protected void allocate() {
|
||||
release(); // Just in the case this object is being re-allocated.
|
||||
|
||||
if (screenFb) {
|
||||
glFboID = 0;
|
||||
} else if (fboMode) {
|
||||
//glFboID = ogl.createGLResource(PGraphicsAndroid3D.GL_FRAME_BUFFER);
|
||||
glFboID = pg.createFrameBufferObject();
|
||||
} else {
|
||||
glFboID = 0;
|
||||
}
|
||||
|
||||
// create the rest of the stuff...
|
||||
if (multisample) {
|
||||
createColorBufferMultisample();
|
||||
}
|
||||
|
||||
if (combinedDepthStencil) {
|
||||
createCombinedDepthStencilBuffer();
|
||||
} else {
|
||||
if (0 < depthBits) {
|
||||
createDepthBuffer();
|
||||
}
|
||||
if (0 < stencilBits) {
|
||||
createStencilBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void release() {
|
||||
if (glFboID != 0) {
|
||||
pg.finalizeFrameBufferObject(glFboID);
|
||||
glFboID = 0;
|
||||
}
|
||||
if (glDepthBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glDepthBufferID);
|
||||
glDepthBufferID = 0;
|
||||
}
|
||||
if (glStencilBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glStencilBufferID);
|
||||
glStencilBufferID = 0;
|
||||
}
|
||||
if (glColorBufferMultisampleID != 0) {
|
||||
pg.finalizeRenderBufferObject(glColorBufferMultisampleID);
|
||||
glColorBufferMultisampleID = 0;
|
||||
}
|
||||
if (glDepthStencilBufferID != 0) {
|
||||
pg.finalizeRenderBufferObject(glDepthStencilBufferID);
|
||||
glDepthStencilBufferID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createColorBufferMultisample() {
|
||||
if (screenFb) return;
|
||||
|
||||
if (fboMode) {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
glColorBufferMultisampleID = pg.createRenderBufferObject();
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, PGL.GL_RGBA8, width, height);
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0, PGL.GL_RENDERBUFFER, glColorBufferMultisampleID);
|
||||
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createCombinedDepthStencilBuffer() {
|
||||
if (screenFb) return;
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
throw new RuntimeException("PFramebuffer: size undefined.");
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
glDepthStencilBufferID = pg.createRenderBufferObject();
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
|
||||
if (multisample) {
|
||||
pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, PGL.GL_DEPTH24_STENCIL8, width, height);
|
||||
} else {
|
||||
pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, PGL.GL_DEPTH24_STENCIL8, width, height);
|
||||
}
|
||||
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_DEPTH_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_STENCIL_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepthStencilBufferID);
|
||||
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createDepthBuffer() {
|
||||
if (screenFb) return;
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
throw new RuntimeException("PFramebuffer: size undefined.");
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
glDepthBufferID = pg.createRenderBufferObject();
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glDepthBufferID);
|
||||
|
||||
int glConst = PGL.GL_DEPTH_COMPONENT16;
|
||||
if (depthBits == 16) {
|
||||
glConst = PGL.GL_DEPTH_COMPONENT16;
|
||||
} else if (depthBits == 24) {
|
||||
glConst = PGL.GL_DEPTH_COMPONENT24;
|
||||
} else if (depthBits == 32) {
|
||||
glConst = PGL.GL_DEPTH_COMPONENT32;
|
||||
}
|
||||
|
||||
if (multisample) {
|
||||
pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, glConst, width, height);
|
||||
} else {
|
||||
pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, glConst, width, height);
|
||||
}
|
||||
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_DEPTH_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepthBufferID);
|
||||
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createStencilBuffer() {
|
||||
if (screenFb) return;
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
throw new RuntimeException("PFramebuffer: size undefined.");
|
||||
}
|
||||
|
||||
if (fboMode) {
|
||||
pg.pushFramebuffer();
|
||||
pg.setFramebuffer(this);
|
||||
|
||||
glStencilBufferID = pg.createRenderBufferObject();
|
||||
pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glStencilBufferID);
|
||||
|
||||
int glConst = PGL.GL_STENCIL_INDEX1;
|
||||
if (stencilBits == 1) {
|
||||
glConst = PGL.GL_STENCIL_INDEX1;
|
||||
} else if (stencilBits == 4) {
|
||||
glConst = PGL.GL_STENCIL_INDEX4;
|
||||
} else if (stencilBits == 8) {
|
||||
glConst = PGL.GL_STENCIL_INDEX8;
|
||||
}
|
||||
if (multisample) {
|
||||
pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, glConst, width, height);
|
||||
} else {
|
||||
pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, glConst, width, height);
|
||||
}
|
||||
|
||||
pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_STENCIL_ATTACHMENT, PGL.GL_RENDERBUFFER, glStencilBufferID);
|
||||
|
||||
pg.popFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createPixelBuffer() {
|
||||
pixelBuffer = IntBuffer.allocate(width * height);
|
||||
pixelBuffer.rewind();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// Utilities.
|
||||
|
||||
// Internal copy to texture method.
|
||||
protected void copyToTexture(IntBuffer buffer, int glid, int gltarget) {
|
||||
pgl.enableTexturing(gltarget);
|
||||
pgl.glBindTexture(gltarget, glid);
|
||||
pgl.glTexSubImage2D(gltarget, 0, 0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, buffer);
|
||||
pgl.glBindTexture(gltarget, 0);
|
||||
pgl.disableTexturing(gltarget);
|
||||
}
|
||||
|
||||
public boolean validateFbo() {
|
||||
int status = pgl.glCheckFramebufferStatus(PGL.GL_FRAMEBUFFER);
|
||||
if (status == PGL.GL_FRAMEBUFFER_COMPLETE) {
|
||||
return true;
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_FORMATS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_UNSUPPORTED) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_UNSUPPORTED" + Integer.toHexString(status));
|
||||
} else {
|
||||
throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,955 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
import java.nio.Buffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import org.lwjgl.util.glu.GLUtessellator;
|
||||
import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.PixelFormat;
|
||||
|
||||
/**
|
||||
* Processing-OpenGL abstraction layer.
|
||||
*
|
||||
*/
|
||||
public class PGL {
|
||||
/** Size of a short (in bytes). */
|
||||
static final int SIZEOF_SHORT = Short.SIZE / 8;
|
||||
|
||||
/** Size of an int (in bytes). */
|
||||
static final int SIZEOF_INT = Integer.SIZE / 8;
|
||||
|
||||
/** Size of a float (in bytes). */
|
||||
static final int SIZEOF_FLOAT = Float.SIZE / 8;
|
||||
|
||||
/** Size of a vertex index. */
|
||||
static final int SIZEOF_INDEX = SIZEOF_INT;
|
||||
|
||||
/** Type of a vertex index. */
|
||||
static final int INDEX_TYPE = GL11.GL_UNSIGNED_INT;
|
||||
|
||||
/** Initial sizes for arrays of input and tessellated data. */
|
||||
public static final int DEFAULT_IN_VERTICES = 64;
|
||||
public static final int DEFAULT_IN_EDGES = 128;
|
||||
public static final int DEFAULT_IN_TEXTURES = 64;
|
||||
public static final int DEFAULT_TESS_VERTICES = 64;
|
||||
public static final int DEFAULT_TESS_INDICES = 128;
|
||||
|
||||
/** Initial sizes for vertex cache used in PShape3D. */
|
||||
public static final int DEFAULT_VERTEX_CACHE_SIZE = 512;
|
||||
|
||||
/** Maximum lights by default is 8, the minimum defined by OpenGL. */
|
||||
public static final int MAX_LIGHTS = 8;
|
||||
|
||||
/** Maximum number of tessellated vertices, using 2^20 for Mac/PC. */
|
||||
public static final int MAX_TESS_VERTICES = 524288;
|
||||
|
||||
/** Maximum number of indices. 2 times the max number of
|
||||
* vertices to have good room for vertex reuse. */
|
||||
public static final int MAX_TESS_INDICES = 2 * MAX_TESS_VERTICES;
|
||||
|
||||
/** Maximum dimension of a texture used to hold font data. **/
|
||||
public static final int MAX_FONT_TEX_SIZE = 256;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// OpenGL constants
|
||||
|
||||
public static final int GL_LESS = GL11.GL_LESS;
|
||||
public static final int GL_LEQUAL = GL11.GL_LEQUAL;
|
||||
public static final int GL_CCW = GL11.GL_CCW;
|
||||
public static final int GL_CW = GL11.GL_CW;
|
||||
public static final int GL_FRONT = GL11.GL_FRONT;
|
||||
public static final int GL_BACK = GL11.GL_BACK;
|
||||
|
||||
public static final int GL_VIEWPORT = GL11.GL_VIEWPORT;
|
||||
|
||||
public static final int GL_SCISSOR_TEST = GL11.GL_SCISSOR_TEST;
|
||||
public static final int GL_DEPTH_TEST = GL11.GL_DEPTH_TEST;
|
||||
|
||||
public static final int GL_COLOR_BUFFER_BIT = GL11.GL_COLOR_BUFFER_BIT;
|
||||
public static final int GL_DEPTH_BUFFER_BIT = GL11.GL_DEPTH_BUFFER_BIT;
|
||||
public static final int GL_STENCIL_BUFFER_BIT = GL11.GL_STENCIL_BUFFER_BIT;
|
||||
|
||||
public static final int GL_FUNC_ADD = 0x8006;
|
||||
public static final int GL_FUNC_MIN = 0x8007;
|
||||
public static final int GL_FUNC_MAX = 0x8008;
|
||||
public static final int GL_FUNC_REVERSE_SUBTRACT = 0x800b;
|
||||
|
||||
public static final int GL_TEXTURE_2D = GL11.GL_TEXTURE_2D;
|
||||
public static final int GL_RGB = GL11.GL_RGB;
|
||||
public static final int GL_RGBA = GL11.GL_RGBA;
|
||||
public static final int GL_ALPHA = GL11.GL_ALPHA;
|
||||
public static final int GL_UNSIGNED_INT = GL11.GL_UNSIGNED_INT;
|
||||
public static final int GL_UNSIGNED_BYTE = GL11.GL_UNSIGNED_BYTE;
|
||||
public static final int GL_UNSIGNED_SHORT = GL11.GL_UNSIGNED_SHORT;
|
||||
public static final int GL_FLOAT = GL11.GL_FLOAT;
|
||||
|
||||
public static final int GL_NEAREST = GL11.GL_NEAREST;
|
||||
public static final int GL_LINEAR = GL11.GL_LINEAR;
|
||||
public static final int GL_LINEAR_MIPMAP_LINEAR = GL11.GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
public static final int GL_CLAMP_TO_EDGE = GL12.GL_CLAMP_TO_EDGE;
|
||||
public static final int GL_REPEAT = GL11.GL_REPEAT;
|
||||
|
||||
public static final int GL_RGBA8 = -1;
|
||||
public static final int GL_DEPTH24_STENCIL8 = -1;
|
||||
|
||||
public static final int GL_DEPTH_COMPONENT16 = GL14.GL_DEPTH_COMPONENT16;
|
||||
public static final int GL_DEPTH_COMPONENT24 = GL14.GL_DEPTH_COMPONENT24;
|
||||
public static final int GL_DEPTH_COMPONENT32 = GL14.GL_DEPTH_COMPONENT32;
|
||||
|
||||
|
||||
public static final int GL_STENCIL_INDEX1 = GL30.GL_STENCIL_INDEX1;
|
||||
public static final int GL_STENCIL_INDEX4 = GL30.GL_STENCIL_INDEX4;
|
||||
public static final int GL_STENCIL_INDEX8 = GL30.GL_STENCIL_INDEX8;
|
||||
|
||||
public static final int GL_ARRAY_BUFFER = GL15.GL_ARRAY_BUFFER;
|
||||
public static final int GL_ELEMENT_ARRAY_BUFFER = GL15.GL_ELEMENT_ARRAY_BUFFER;
|
||||
|
||||
public static final int GL_FRAMEBUFFER_COMPLETE = GL30.GL_FRAMEBUFFER_COMPLETE;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8cda;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER;
|
||||
public static final int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER;
|
||||
public static final int GL_FRAMEBUFFER_UNSUPPORTED = GL30.GL_FRAMEBUFFER_UNSUPPORTED;
|
||||
|
||||
public static final int GL_STATIC_DRAW = GL15.GL_STATIC_DRAW;
|
||||
public static final int GL_DYNAMIC_DRAW = GL15.GL_DYNAMIC_DRAW;
|
||||
public static final int GL_STREAM_DRAW = GL15.GL_STREAM_DRAW;
|
||||
|
||||
public static final int GL_READ_ONLY = GL15.GL_READ_ONLY;
|
||||
public static final int GL_WRITE_ONLY = GL15.GL_WRITE_ONLY;
|
||||
public static final int GL_READ_WRITE = GL15.GL_READ_WRITE;
|
||||
|
||||
public static final int GL_TRIANGLE_FAN = GL11.GL_TRIANGLE_FAN;
|
||||
public static final int GL_TRIANGLE_STRIP = GL11.GL_TRIANGLE_STRIP;
|
||||
public static final int GL_TRIANGLES = GL11.GL_TRIANGLES;
|
||||
|
||||
public static final int GL_VENDOR = GL11.GL_VENDOR;
|
||||
public static final int GL_RENDERER = GL11.GL_RENDERER;
|
||||
public static final int GL_VERSION = GL11.GL_VERSION;
|
||||
public static final int GL_EXTENSIONS = GL11.GL_EXTENSIONS;
|
||||
|
||||
public static final int GL_MAX_TEXTURE_SIZE = GL11.GL_MAX_TEXTURE_SIZE;
|
||||
public static final int GL_ALIASED_LINE_WIDTH_RANGE = GL12.GL_ALIASED_LINE_WIDTH_RANGE;
|
||||
public static final int GL_ALIASED_POINT_SIZE_RANGE = GL12.GL_ALIASED_POINT_SIZE_RANGE;
|
||||
public static final int GL_SAMPLES = GL13.GL_SAMPLES;
|
||||
|
||||
public static final int GLU_TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
|
||||
public static final int GLU_TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
|
||||
|
||||
public static final int GL_TEXTURE0 = GL13.GL_TEXTURE0;
|
||||
public static final int GL_TEXTURE1 = GL13.GL_TEXTURE1;
|
||||
public static final int GL_TEXTURE2 = GL13.GL_TEXTURE2;
|
||||
public static final int GL_TEXTURE3 = GL13.GL_TEXTURE3;
|
||||
public static final int GL_TEXTURE_MIN_FILTER = GL11.GL_TEXTURE_MIN_FILTER;
|
||||
public static final int GL_TEXTURE_MAG_FILTER = GL11.GL_TEXTURE_MAG_FILTER;
|
||||
public static final int GL_TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S;
|
||||
public static final int GL_TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T;
|
||||
|
||||
public static final int GL_BLEND = GL11.GL_BLEND;
|
||||
public static final int GL_ONE = GL11.GL_ONE;
|
||||
public static final int GL_ZERO = GL11.GL_ZERO;
|
||||
public static final int GL_SRC_ALPHA = GL11.GL_SRC_ALPHA;
|
||||
public static final int GL_DST_ALPHA = GL11.GL_DST_ALPHA;
|
||||
public static final int GL_ONE_MINUS_SRC_ALPHA = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
public static final int GL_ONE_MINUS_DST_COLOR = GL11.GL_ONE_MINUS_DST_COLOR;
|
||||
public static final int GL_ONE_MINUS_SRC_COLOR = GL11.GL_ONE_MINUS_SRC_COLOR;
|
||||
public static final int GL_DST_COLOR = GL11.GL_DST_COLOR;
|
||||
public static final int GL_SRC_COLOR = GL11.GL_SRC_COLOR;
|
||||
|
||||
public static final int GL_FRAMEBUFFER = GL30.GL_FRAMEBUFFER;
|
||||
public static final int GL_COLOR_ATTACHMENT0 = GL30.GL_COLOR_ATTACHMENT0;
|
||||
public static final int GL_RENDERBUFFER = GL30.GL_RENDERBUFFER;
|
||||
public static final int GL_DEPTH_ATTACHMENT = GL30.GL_DEPTH_ATTACHMENT;
|
||||
public static final int GL_STENCIL_ATTACHMENT = GL30.GL_STENCIL_ATTACHMENT;
|
||||
public static final int GL_READ_FRAMEBUFFER = GL30.GL_READ_FRAMEBUFFER;
|
||||
public static final int GL_DRAW_FRAMEBUFFER = GL30.GL_DRAW_FRAMEBUFFER;
|
||||
public static final int GL_COLOR_ATTACHMENT1 = GL30.GL_COLOR_ATTACHMENT1;
|
||||
public static final int GL_COLOR_ATTACHMENT2 = GL30.GL_COLOR_ATTACHMENT2;
|
||||
public static final int GL_COLOR_ATTACHMENT3 = GL30.GL_COLOR_ATTACHMENT3;
|
||||
|
||||
public static final int GL_VERTEX_SHADER = GL20.GL_VERTEX_SHADER;
|
||||
public static final int GL_FRAGMENT_SHADER = GL20.GL_FRAGMENT_SHADER;
|
||||
|
||||
public static final int GL_MULTISAMPLE = GL13.GL_MULTISAMPLE;
|
||||
public static final int GL_POINT_SMOOTH = GL11.GL_POINT_SMOOTH;
|
||||
public static final int GL_LINE_SMOOTH = GL11.GL_LINE_SMOOTH;
|
||||
public static final int GL_POLYGON_SMOOTH = GL11.GL_POLYGON_SMOOTH;
|
||||
|
||||
public Canvas canvas;
|
||||
|
||||
public PGraphicsLWJGL pg;
|
||||
|
||||
public GLU glu;
|
||||
|
||||
public boolean initialized;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Intialization, finalization
|
||||
|
||||
public PGL(PGraphicsLWJGL pg) {
|
||||
this.pg = pg;
|
||||
glu = new GLU();
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This static method can be called by applications that use
|
||||
* Processing+P3D inside their own GUI, so they can initialize
|
||||
* JOGL2 before anything else.
|
||||
* According to the JOGL2 documentation, applications shall call
|
||||
* GLProfile.initSingleton() ASAP, before any other UI invocation.
|
||||
* In case applications are able to initialize JOGL before any other
|
||||
* UI action, hey shall invoke this method with beforeUI=true and
|
||||
* benefit from fast native multithreading support on all platforms
|
||||
* if possible.
|
||||
*
|
||||
*/
|
||||
static public void startup(boolean beforeUI) {
|
||||
// try {
|
||||
// GLProfile.initSingleton(beforeUI);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
static public void shutdown() {
|
||||
// GLProfile.shutdown();
|
||||
}
|
||||
|
||||
public void updatePrimary() {
|
||||
// gl = context.getGL();
|
||||
// gl2 = gl.getGL2();
|
||||
}
|
||||
|
||||
public void updateOffscreen(PGL primary) {
|
||||
// gl = primary.gl;
|
||||
// gl2 = primary.gl2;
|
||||
}
|
||||
|
||||
|
||||
public void initPrimarySurface(int antialias) {
|
||||
canvas = new Canvas();
|
||||
|
||||
canvas.setBounds(0, 0, pg.parent.width, pg.parent.height);
|
||||
canvas.setFocusable(true);
|
||||
canvas.requestFocus();
|
||||
canvas.setIgnoreRepaint(true);
|
||||
pg.parent.setLayout(new BorderLayout());
|
||||
pg.parent.add(canvas, BorderLayout.CENTER);
|
||||
|
||||
try {
|
||||
Display.setParent(canvas);
|
||||
PixelFormat format = new PixelFormat(32, 0, 24, 8, antialias);
|
||||
Display.create(format);
|
||||
Display.setVSyncEnabled(false);
|
||||
} catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
canvas.addMouseListener(pg.parent);
|
||||
canvas.addMouseMotionListener(pg.parent);
|
||||
canvas.addKeyListener(pg.parent);
|
||||
canvas.addFocusListener(pg.parent);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void initOffscreenSurface(PGL primary) {
|
||||
// context = primary.context;
|
||||
// capabilities = primary.capabilities;
|
||||
// drawable = null;
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void updateOffscreenSurface(PGL primary) {
|
||||
// context = primary.context;
|
||||
// capabilities = primary.capabilities;
|
||||
// drawable = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the OpenGL rendering context current for this thread.
|
||||
*/
|
||||
protected void detainContext() {
|
||||
// try {
|
||||
// while (context.makeCurrent() == GLContext.CONTEXT_NOT_CURRENT) {
|
||||
// Thread.sleep(10);
|
||||
// }
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the context, otherwise the AWT lock on X11 will not be released
|
||||
*/
|
||||
public void releaseContext() {
|
||||
// context.release();
|
||||
}
|
||||
|
||||
public void destroyContext() {
|
||||
// context.destroy();
|
||||
// context = null;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Frame rendering
|
||||
|
||||
public boolean initOnscreenDraw() {
|
||||
// if (drawable != null) {
|
||||
// // Call setRealized() after addNotify() has been called
|
||||
// drawable.setRealized(pg.parent.isDisplayable());
|
||||
// if (pg.parent.isDisplayable()) {
|
||||
// drawable.setRealized(true);
|
||||
// return true;
|
||||
// } else {
|
||||
// return false; // Should have called canDraw() anyway
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void beginOnscreenDraw(boolean clear, int frame) {
|
||||
}
|
||||
|
||||
public void endOnscreenDraw(boolean clear0) {
|
||||
Display.update();
|
||||
// if (drawable != null) {
|
||||
// drawable.swapBuffers();
|
||||
// }
|
||||
}
|
||||
|
||||
public void beginOffscreenDraw(boolean clear, int frame) {
|
||||
}
|
||||
|
||||
public void endOffscreenDraw(boolean clear0) {
|
||||
}
|
||||
|
||||
public boolean canDraw() {
|
||||
return pg.parent.isDisplayable();
|
||||
}
|
||||
|
||||
public void requestDraw() {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Caps query
|
||||
|
||||
public String glGetString(int name) {
|
||||
return GL11.glGetString(name);
|
||||
}
|
||||
|
||||
public void glGetIntegerv(int name, IntBuffer values) {
|
||||
GL11.glGetInteger(name, values);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Enable/disable caps
|
||||
|
||||
public void glEnable(int cap) {
|
||||
if (-1 < cap) {
|
||||
GL11.glEnable(cap);
|
||||
}
|
||||
}
|
||||
|
||||
public void glDisable(int cap) {
|
||||
if (-1 < cap) {
|
||||
GL11.glDisable(cap);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Render control
|
||||
|
||||
public void glFlush() {
|
||||
GL11.glFlush();
|
||||
}
|
||||
|
||||
public void glFinish() {
|
||||
GL11.glFinish();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Error handling
|
||||
|
||||
public int glGetError() {
|
||||
return GL11.glGetError();
|
||||
}
|
||||
|
||||
public String glErrorString(int err) {
|
||||
return GLU.gluErrorString(err);
|
||||
}
|
||||
|
||||
public String gluErrorString(int err) {
|
||||
return GLU.gluErrorString(err);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Rendering options
|
||||
|
||||
public void glFrontFace(int mode) {
|
||||
GL11.glFrontFace(mode);
|
||||
}
|
||||
|
||||
public void glDepthMask(boolean flag) {
|
||||
GL11.glDepthMask(flag);
|
||||
}
|
||||
|
||||
public void glDepthFunc(int func) {
|
||||
GL11.glDepthFunc(func);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Textures
|
||||
|
||||
public void glGenTextures(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL11.glGenTextures(ids);
|
||||
}
|
||||
|
||||
public void glDeleteTextures(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL11.glDeleteTextures(ids);
|
||||
}
|
||||
|
||||
public void glActiveTexture(int unit) {
|
||||
GL13.glActiveTexture(unit);
|
||||
}
|
||||
|
||||
public void glBindTexture(int target, int id) {
|
||||
GL11.glBindTexture(target, id);
|
||||
}
|
||||
|
||||
public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, IntBuffer data) {
|
||||
GL11.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
|
||||
}
|
||||
|
||||
public void glTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, IntBuffer data) {
|
||||
GL11.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data);
|
||||
}
|
||||
|
||||
public void glTexParameterf(int target, int param, int value) {
|
||||
GL11.glTexParameterf(target, param, value);
|
||||
}
|
||||
|
||||
public void glGenerateMipmap(int target) {
|
||||
GL30.glGenerateMipmap(target);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Vertex Buffers
|
||||
|
||||
public void glGenBuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL15.glGenBuffers(ids);
|
||||
}
|
||||
|
||||
public void glDeleteBuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL15.glDeleteBuffers(ids);
|
||||
}
|
||||
|
||||
public void glBindBuffer(int target, int id) {
|
||||
GL15.glBindBuffer(target, id);
|
||||
}
|
||||
|
||||
public void glBufferData(int target, int size, Buffer data, int usage) {
|
||||
if (data == null) {
|
||||
FloatBuffer empty = BufferUtils.createFloatBuffer(size);
|
||||
GL15.glBufferData(target, empty, usage);
|
||||
} else {
|
||||
if (data instanceof ByteBuffer) {
|
||||
GL15.glBufferData(target, (ByteBuffer)data, usage);
|
||||
} else if (data instanceof IntBuffer) {
|
||||
GL15.glBufferData(target, (IntBuffer)data, usage);
|
||||
} else if (data instanceof FloatBuffer) {
|
||||
GL15.glBufferData(target, (FloatBuffer)data, usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void glBufferSubData(int target, int offset, int size, Buffer data) {
|
||||
if (data instanceof ByteBuffer) {
|
||||
GL15.glBufferSubData(target, offset, (ByteBuffer)data);
|
||||
} else if (data instanceof IntBuffer) {
|
||||
GL15.glBufferSubData(target, offset, (IntBuffer)data);
|
||||
} else if (data instanceof FloatBuffer) {
|
||||
GL15.glBufferSubData(target, offset, (FloatBuffer)data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void glDrawElements(int mode, int count, int type, int offset) {
|
||||
GL11.glDrawElements(mode, count, type, offset);
|
||||
}
|
||||
|
||||
|
||||
public void glEnableVertexAttribArray(int loc) {
|
||||
GL20.glEnableVertexAttribArray(loc);
|
||||
}
|
||||
|
||||
public void glDisableVertexAttribArray(int loc) {
|
||||
GL20.glDisableVertexAttribArray(loc);
|
||||
}
|
||||
|
||||
public void glVertexAttribPointer(int loc, int size, int type, boolean normalized, int stride, int offset) {
|
||||
GL20.glVertexAttribPointer(loc, size, type, normalized, stride, offset);
|
||||
}
|
||||
|
||||
|
||||
public ByteBuffer glMapBuffer(int target, int access) {
|
||||
return GL15.glMapBuffer(target, access, null);
|
||||
}
|
||||
|
||||
public ByteBuffer glMapBufferRange(int target, int offset, int length, int access) {
|
||||
return GL30.glMapBufferRange(target, offset, length, access, null);
|
||||
}
|
||||
|
||||
public void glUnmapBuffer(int target) {
|
||||
GL15.glUnmapBuffer(target);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Framebuffers, renderbuffers
|
||||
|
||||
public void glGenFramebuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL30.glGenFramebuffers(ids);
|
||||
}
|
||||
|
||||
public void glDeleteFramebuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL30.glDeleteFramebuffers(ids);
|
||||
}
|
||||
|
||||
public void glGenRenderbuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL30.glGenRenderbuffers(ids);
|
||||
}
|
||||
|
||||
public void glDeleteRenderbuffers(int n, IntBuffer ids) {
|
||||
ids.limit(n);
|
||||
GL30.glDeleteRenderbuffers(ids);
|
||||
}
|
||||
|
||||
public void glBindFramebuffer(int target, int id) {
|
||||
GL30.glBindFramebuffer(target, id);
|
||||
}
|
||||
|
||||
public void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) {
|
||||
GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
public void glFramebufferTexture2D(int target, int attachment, int texTarget, int texId, int level) {
|
||||
GL30.glFramebufferTexture2D(target, attachment, texTarget, texId, level);
|
||||
}
|
||||
|
||||
public void glBindRenderbuffer(int target, int id) {
|
||||
GL30.glBindRenderbuffer(target, id);
|
||||
}
|
||||
|
||||
public void glRenderbufferStorageMultisample(int target, int samples, int format, int width, int height) {
|
||||
GL30.glRenderbufferStorageMultisample(target, samples, format, width, height);
|
||||
}
|
||||
|
||||
public void glRenderbufferStorage(int target, int format, int width, int height) {
|
||||
GL30.glRenderbufferStorage(target, format, width, height);
|
||||
}
|
||||
|
||||
public void glFramebufferRenderbuffer(int target, int attachment, int rendbufTarget, int rendbufId) {
|
||||
GL30.glFramebufferRenderbuffer(target, attachment, rendbufTarget, rendbufId);
|
||||
}
|
||||
|
||||
public int glCheckFramebufferStatus(int target) {
|
||||
return GL30.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Shaders
|
||||
|
||||
public int glCreateProgram() {
|
||||
return GL20.glCreateProgram();
|
||||
}
|
||||
|
||||
public void glDeleteProgram(int id) {
|
||||
GL20.glDeleteProgram(id);
|
||||
}
|
||||
|
||||
public int glCreateShader(int type) {
|
||||
return GL20.glCreateShader(type);
|
||||
}
|
||||
|
||||
public void glDeleteShader(int id) {
|
||||
GL20.glDeleteShader(id);
|
||||
}
|
||||
|
||||
public void glLinkProgram(int prog) {
|
||||
GL20.glLinkProgram(prog);
|
||||
}
|
||||
|
||||
public void glValidateProgram(int prog) {
|
||||
GL20.glValidateProgram(prog);
|
||||
}
|
||||
|
||||
public void glUseProgram(int prog) {
|
||||
GL20.glUseProgram(prog);
|
||||
}
|
||||
|
||||
public int glGetAttribLocation(int prog, String name) {
|
||||
return GL20.glGetAttribLocation(prog, name);
|
||||
}
|
||||
|
||||
public int glGetUniformLocation(int prog, String name) {
|
||||
return GL20.glGetUniformLocation(prog, name);
|
||||
}
|
||||
|
||||
public void glUniform1i(int loc, int value) {
|
||||
GL20.glUniform1i(loc, value);
|
||||
}
|
||||
|
||||
public void glUniform1f(int loc, float value) {
|
||||
GL20.glUniform1f(loc, value);
|
||||
}
|
||||
|
||||
public void glUniform2f(int loc, float value0, float value1) {
|
||||
GL20.glUniform2f(loc, value0, value1);
|
||||
}
|
||||
|
||||
public void glUniform3f(int loc, float value0, float value1, float value2) {
|
||||
GL20.glUniform3f(loc, value0, value1, value2);
|
||||
}
|
||||
|
||||
public void glUniform4f(int loc, float value0, float value1, float value2, float value3) {
|
||||
GL20.glUniform4f(loc, value0, value1, value2, value3);
|
||||
}
|
||||
|
||||
public void glUniform1fv(int loc, int count, FloatBuffer v) {
|
||||
GL20.glUniform1(loc, v);
|
||||
}
|
||||
|
||||
public void glUniform2fv(int loc, int count, FloatBuffer v) {
|
||||
GL20.glUniform2(loc, v);
|
||||
}
|
||||
|
||||
public void glUniform3fv(int loc, int count, FloatBuffer v) {
|
||||
GL20.glUniform3(loc, v);
|
||||
}
|
||||
|
||||
public void glUniform4fv(int loc, int count, FloatBuffer v) {
|
||||
GL20.glUniform4(loc, v);
|
||||
}
|
||||
|
||||
public void glUniformMatrix2fv(int loc, int count, boolean transpose, FloatBuffer mat) {
|
||||
GL20.glUniformMatrix2(loc, transpose, mat);
|
||||
}
|
||||
|
||||
public void glUniformMatrix3fv(int loc, int count, boolean transpose, FloatBuffer mat) {
|
||||
GL20.glUniformMatrix3(loc, transpose, mat);
|
||||
}
|
||||
|
||||
public void glUniformMatrix4fv(int loc, int count, boolean transpose, FloatBuffer mat) {
|
||||
GL20.glUniformMatrix4(loc, transpose, mat);
|
||||
}
|
||||
|
||||
public void glVertexAttrib1f(int loc, float value) {
|
||||
GL20.glVertexAttrib1f(loc, value);
|
||||
}
|
||||
|
||||
public void glVertexAttrib2f(int loc, float value0, float value1) {
|
||||
GL20.glVertexAttrib2f(loc, value0, value1);
|
||||
}
|
||||
|
||||
public void glVertexAttrib3f(int loc, float value0, float value1, float value2) {
|
||||
GL20.glVertexAttrib3f(loc, value0, value1, value2);
|
||||
}
|
||||
|
||||
public void glVertexAttrib4f(int loc, float value0, float value1, float value2, float value3) {
|
||||
GL20.glVertexAttrib4f(loc, value0, value1, value2, value3);
|
||||
}
|
||||
|
||||
public void glShaderSource(int id, String source) {
|
||||
GL20.glShaderSource(id, source);
|
||||
}
|
||||
|
||||
public void glCompileShader(int id) {
|
||||
GL20.glCompileShader(id);
|
||||
}
|
||||
|
||||
public void glAttachShader(int prog, int shader) {
|
||||
GL20.glAttachShader(prog, shader);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Viewport
|
||||
|
||||
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GL11.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Clipping (scissor test)
|
||||
|
||||
|
||||
public void glScissor(int x, int y, int w, int h) {
|
||||
GL11.glScissor(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Blending
|
||||
|
||||
|
||||
public void glBlendEquation(int eq) {
|
||||
GL14.glBlendEquation(eq);
|
||||
}
|
||||
|
||||
|
||||
public void glBlendFunc(int srcFactor, int dstFactor) {
|
||||
GL11.glBlendFunc(srcFactor, dstFactor);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Pixels
|
||||
|
||||
public void setReadBuffer(int buf) {
|
||||
GL11.glReadBuffer(buf);
|
||||
}
|
||||
|
||||
public void glReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer buffer) {
|
||||
GL11.glReadPixels(x, y, width, height, format, type, buffer);
|
||||
}
|
||||
|
||||
public void setDrawBuffer(int buf) {
|
||||
GL11.glDrawBuffer(buf);
|
||||
}
|
||||
|
||||
public void glClearColor(float r, float g, float b, float a) {
|
||||
GL11.glClearColor(r, g, b, a);
|
||||
}
|
||||
|
||||
public void glClear(int mask) {
|
||||
GL11.glClear(mask);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Context interface
|
||||
|
||||
public Context getContext() {
|
||||
return new Context(null);
|
||||
}
|
||||
|
||||
public class Context {
|
||||
protected GLContext context;
|
||||
|
||||
Context(GLContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
boolean same(GLContext context) {
|
||||
return true;
|
||||
//return this.context.hashCode() == context.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Tessellator interface
|
||||
|
||||
public Tessellator createTessellator(TessellatorCallback callback) {
|
||||
return new Tessellator(callback);
|
||||
}
|
||||
|
||||
public class Tessellator {
|
||||
protected GLUtessellator tess;
|
||||
protected TessellatorCallback callback;
|
||||
protected GLUCallback gluCallback;
|
||||
|
||||
public Tessellator(TessellatorCallback callback) {
|
||||
this.callback = callback;
|
||||
tess = GLU.gluNewTess();
|
||||
gluCallback = new GLUCallback();
|
||||
|
||||
tess.gluTessCallback(GLU.GLU_TESS_BEGIN, gluCallback);
|
||||
tess.gluTessCallback(GLU.GLU_TESS_END, gluCallback);
|
||||
tess.gluTessCallback(GLU.GLU_TESS_VERTEX, gluCallback);
|
||||
tess.gluTessCallback(GLU.GLU_TESS_COMBINE, gluCallback);
|
||||
tess.gluTessCallback(GLU.GLU_TESS_ERROR, gluCallback);
|
||||
}
|
||||
|
||||
public void beginPolygon() {
|
||||
tess.gluTessBeginPolygon(null);
|
||||
}
|
||||
|
||||
public void endPolygon() {
|
||||
tess.gluTessEndPolygon();
|
||||
}
|
||||
|
||||
public void setWindingRule(int rule) {
|
||||
tess.gluTessProperty(GLU.GLU_TESS_WINDING_RULE, rule);
|
||||
}
|
||||
|
||||
public void beginContour() {
|
||||
tess.gluTessBeginContour();
|
||||
}
|
||||
|
||||
public void endContour() {
|
||||
tess.gluTessEndContour();
|
||||
}
|
||||
|
||||
public void addVertex(double[] v) {
|
||||
tess.gluTessVertex(v, 0, v);
|
||||
}
|
||||
|
||||
protected class GLUCallback extends GLUtessellatorCallbackAdapter {
|
||||
public void begin(int type) {
|
||||
callback.begin(type);
|
||||
}
|
||||
|
||||
public void end() {
|
||||
callback.end();
|
||||
}
|
||||
|
||||
public void vertex(Object data) {
|
||||
callback.vertex(data);
|
||||
}
|
||||
|
||||
public void combine(double[] coords, Object[] data,
|
||||
float[] weight, Object[] outData) {
|
||||
callback.combine(coords, data, weight, outData);
|
||||
}
|
||||
|
||||
public void error(int errnum) {
|
||||
callback.error(errnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface TessellatorCallback {
|
||||
public void begin(int type);
|
||||
public void end();
|
||||
public void vertex(Object data);
|
||||
public void combine(double[] coords, Object[] data,
|
||||
float[] weight, Object[] outData);
|
||||
public void error(int errnum);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Utility functions
|
||||
|
||||
public FloatBuffer createFloatBuffer(int size) {
|
||||
return BufferUtils.createFloatBuffer(size);
|
||||
}
|
||||
|
||||
public IntBuffer createIntBuffer(int size) {
|
||||
return BufferUtils.createIntBuffer(size);
|
||||
}
|
||||
|
||||
public boolean contextIsCurrent(Context other) {
|
||||
return other.same(null);
|
||||
}
|
||||
|
||||
static public int makeIndex(int intIdx) {
|
||||
return intIdx;
|
||||
}
|
||||
|
||||
public void enableTexturing(int target) {
|
||||
GL11.glEnable(target);
|
||||
}
|
||||
|
||||
public void disableTexturing(int target) {
|
||||
GL11.glDisable(target);
|
||||
}
|
||||
|
||||
public void initTexture(int target, int width, int height, int format, int type) {
|
||||
IntBuffer texels = createIntBuffer(width * height);
|
||||
GL11.glTexSubImage2D(target, 0, 0, 0, width, height, format, type, texels);
|
||||
}
|
||||
|
||||
public String getShaderLog(int id) {
|
||||
IntBuffer val = createIntBuffer(1);
|
||||
ARBShaderObjects.glGetObjectParameterARB(id, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, val);
|
||||
|
||||
int length = val.get();
|
||||
|
||||
if (length <= 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Some error occurred...
|
||||
ByteBuffer infoLog = ByteBuffer.allocate(length);
|
||||
val.flip();
|
||||
|
||||
ARBShaderObjects.glGetInfoLogARB(id, val, infoLog);
|
||||
|
||||
byte[] infoBytes = new byte[length];
|
||||
infoLog.get(infoBytes);
|
||||
return new String(infoBytes);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,477 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
Copyright (c) 2010 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 2.1 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* This class encapsulates a GLSL shader program, including a vertex
|
||||
* and a fragment shader. Originally based in the code by JohnG
|
||||
* (http://www.hardcorepawn.com/)
|
||||
*/
|
||||
public class PShader {
|
||||
protected PApplet parent;
|
||||
protected PGraphicsLWJGL pg;
|
||||
protected PGL pgl;
|
||||
|
||||
protected URL vertexURL;
|
||||
protected URL fragmentURL;
|
||||
|
||||
protected String vertexFilename;
|
||||
protected String fragmentFilename;
|
||||
|
||||
protected int programObject;
|
||||
protected int vertexShader;
|
||||
protected int fragmentShader;
|
||||
|
||||
protected FloatBuffer vec1f;
|
||||
protected FloatBuffer vec2f;
|
||||
protected FloatBuffer vec3f;
|
||||
protected FloatBuffer vec4f;
|
||||
protected FloatBuffer mat2x2;
|
||||
protected FloatBuffer mat3x3;
|
||||
protected FloatBuffer mat4x4;
|
||||
|
||||
public PShader() {
|
||||
parent = null;
|
||||
pg = null;
|
||||
pgl = null;
|
||||
|
||||
this.vertexURL = null;
|
||||
this.fragmentURL = null;
|
||||
this.vertexFilename = null;
|
||||
this.fragmentFilename = null;
|
||||
|
||||
programObject = 0;
|
||||
vertexShader = 0;
|
||||
fragmentShader = 0;
|
||||
}
|
||||
|
||||
public PShader(PApplet parent) {
|
||||
this();
|
||||
this.parent = parent;
|
||||
pg = (PGraphicsLWJGL) parent.g;
|
||||
pgl = pg.pgl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shader program using the specified vertex and fragment
|
||||
* shaders.
|
||||
*
|
||||
* @param parent PApplet
|
||||
* @param vertexFN String
|
||||
* @param fragmentFN String
|
||||
*/
|
||||
public PShader(PApplet parent, String vertFilename, String fragFilename) {
|
||||
this.parent = parent;
|
||||
pg = (PGraphicsLWJGL) parent.g;
|
||||
pgl = pg.pgl;
|
||||
|
||||
this.vertexURL = null;
|
||||
this.fragmentURL = null;
|
||||
this.vertexFilename = vertFilename;
|
||||
this.fragmentFilename = fragFilename;
|
||||
|
||||
programObject = 0;
|
||||
vertexShader = 0;
|
||||
fragmentShader = 0;
|
||||
}
|
||||
|
||||
public PShader(PApplet parent, URL vertURL, URL fragURL) {
|
||||
this.parent = parent;
|
||||
pg = (PGraphicsLWJGL) parent.g;
|
||||
pgl = pg.pgl;
|
||||
|
||||
this.vertexURL = vertURL;
|
||||
this.fragmentURL = fragURL;
|
||||
this.vertexFilename = null;
|
||||
this.fragmentFilename = null;
|
||||
|
||||
programObject = 0;
|
||||
vertexShader = 0;
|
||||
fragmentShader = 0;
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (vertexShader != 0) {
|
||||
pg.finalizeGLSLVertShaderObject(vertexShader);
|
||||
}
|
||||
if (fragmentShader != 0) {
|
||||
pg.finalizeGLSLFragShaderObject(fragmentShader);
|
||||
}
|
||||
if (programObject != 0) {
|
||||
pg.finalizeGLSLProgramObject(programObject);
|
||||
}
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
public void setVertexShader(String vertFilename) {
|
||||
this.vertexFilename = vertFilename;
|
||||
}
|
||||
|
||||
public void setVertexShader(URL vertURL) {
|
||||
this.vertexURL = vertURL;
|
||||
}
|
||||
|
||||
public void setFragmentShader(String fragFilename) {
|
||||
this.fragmentFilename = fragFilename;
|
||||
}
|
||||
|
||||
public void setFragmentShader(URL fragURL) {
|
||||
this.fragmentURL = fragURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the execution of the shader program.
|
||||
*/
|
||||
public void start() {
|
||||
init();
|
||||
pgl.glUseProgram(programObject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stops the execution of the shader program.
|
||||
*/
|
||||
public void stop() {
|
||||
pgl.glUseProgram(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID location of the attribute parameter given its name.
|
||||
*
|
||||
* @param name String
|
||||
* @return int
|
||||
*/
|
||||
public int getAttribLocation(String name) {
|
||||
init();
|
||||
return pgl.glGetAttribLocation(programObject, name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID location of the uniform parameter given its name.
|
||||
*
|
||||
* @param name String
|
||||
* @return int
|
||||
*/
|
||||
public int getUniformLocation(String name) {
|
||||
init();
|
||||
return pgl.glGetUniformLocation(programObject, name);
|
||||
}
|
||||
|
||||
|
||||
public void setIntUniform(int loc, int x) {
|
||||
if (-1 < loc) {
|
||||
pgl.glUniform1i(loc, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set1FloatUniform(int loc, float x) {
|
||||
if (-1 < loc) {
|
||||
pgl.glUniform1f(loc, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2FloatUniform(int loc, float x, float y) {
|
||||
if (-1 < loc) {
|
||||
pgl.glUniform2f(loc, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3FloatUniform(int loc, float x, float y, float z) {
|
||||
if (-1 < loc) {
|
||||
pgl.glUniform3f(loc, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4FloatUniform(int loc, float x, float y, float z, float w) {
|
||||
if (-1 < loc) {
|
||||
pgl.glUniform4f(loc, x, y, z, w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set1FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec1f == null || vec1f.capacity() != vec.length) {
|
||||
vec1f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec1f.rewind();
|
||||
vec1f.put(vec);
|
||||
vec1f.flip();
|
||||
pgl.glUniform1fv(loc, vec.length, vec1f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec2f == null || vec2f.capacity() != vec.length) {
|
||||
vec2f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec2f.rewind();
|
||||
vec2f.put(vec);
|
||||
vec2f.flip();
|
||||
pgl.glUniform2fv(loc, vec.length / 2, vec2f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec3f == null || vec3f.capacity() != vec.length) {
|
||||
vec3f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec3f.rewind();
|
||||
vec3f.put(vec);
|
||||
vec3f.flip();
|
||||
pgl.glUniform3fv(loc, vec.length / 3, vec3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4FloatVecUniform(int loc, float[] vec) {
|
||||
if (-1 < loc) {
|
||||
if (vec4f == null || vec4f.capacity() != vec.length) {
|
||||
vec4f = pgl.createFloatBuffer(vec.length);
|
||||
}
|
||||
vec4f.rewind();
|
||||
vec4f.put(vec);
|
||||
vec4f.flip();
|
||||
pgl.glUniform4fv(loc, vec.length / 4, vec4f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2x2MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat2x2 == null) {
|
||||
mat2x2 = pgl.createFloatBuffer(2 * 2);
|
||||
}
|
||||
mat2x2.rewind();
|
||||
mat2x2.put(mat);
|
||||
mat2x2.flip();
|
||||
pgl.glUniformMatrix2fv(loc, 1, false, mat2x2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3x3MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat3x3 == null) {
|
||||
mat3x3 = pgl.createFloatBuffer(3 * 3);
|
||||
}
|
||||
mat3x3.rewind();
|
||||
mat3x3.put(mat);
|
||||
mat3x3.flip();
|
||||
pgl.glUniformMatrix3fv(loc, 1, false, mat3x3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4x4MatUniform(int loc, float[] mat) {
|
||||
if (-1 < loc) {
|
||||
if (mat4x4 == null) {
|
||||
mat4x4 = pgl.createFloatBuffer(4 * 4);
|
||||
}
|
||||
mat4x4.rewind();
|
||||
mat4x4.put(mat);
|
||||
mat4x4.flip();
|
||||
pgl.glUniformMatrix4fv(loc, 1, false, mat4x4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set1FloatAttribute(int loc, float x) {
|
||||
if (-1 < loc) {
|
||||
pgl.glVertexAttrib1f(loc, x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set2FloatAttribute(int loc, float x, float y) {
|
||||
if (-1 < loc) {
|
||||
pgl.glVertexAttrib2f(loc, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set3FloatAttribute(int loc, float x, float y, float z) {
|
||||
if (-1 < loc) {
|
||||
pgl.glVertexAttrib3f(loc, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void set4FloatAttribute(int loc, float x, float y, float z, float w) {
|
||||
if (-1 < loc) {
|
||||
pgl.glVertexAttrib4f(loc, x, y, z, w);
|
||||
}
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
if (programObject == 0) {
|
||||
programObject = pg.createGLSLProgramObject();
|
||||
|
||||
if (vertexFilename != null) {
|
||||
loadVertexShader(vertexFilename);
|
||||
} else if (vertexURL != null) {
|
||||
loadVertexShader(vertexURL);
|
||||
} else {
|
||||
PGraphics.showException("Vertex shader filenames and URLs are both null!");
|
||||
}
|
||||
|
||||
if (fragmentFilename != null) {
|
||||
loadFragmentShader(fragmentFilename);
|
||||
} else if (fragmentURL != null) {
|
||||
loadFragmentShader(fragmentURL);
|
||||
} else {
|
||||
PGraphics.showException("Fragment shader filenames and URLs are both null!");
|
||||
}
|
||||
|
||||
checkLogInfo("Vertex shader " + vertexFilename + " compilation: ", vertexShader);
|
||||
checkLogInfo("Fragment shader " + fragmentFilename + " compilation: ", fragmentShader);
|
||||
|
||||
pgl.glLinkProgram(programObject);
|
||||
pgl.glValidateProgram(programObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads and compiles the vertex shader contained in file.
|
||||
*
|
||||
* @param file String
|
||||
*/
|
||||
protected void loadVertexShader(String filename) {
|
||||
String shaderSource = PApplet.join(parent.loadStrings(filename), "\n");
|
||||
attachVertexShader(shaderSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and compiles the vertex shader contained in the URL.
|
||||
*
|
||||
* @param file String
|
||||
*/
|
||||
protected void loadVertexShader(URL url) {
|
||||
try {
|
||||
String shaderSource = PApplet.join(PApplet.loadStrings(url.openStream()), "\n");
|
||||
attachVertexShader(shaderSource);
|
||||
} catch (IOException e) {
|
||||
PGraphics.showException("Cannot load shader " + url.getFile());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and compiles the fragment shader contained in file.
|
||||
*
|
||||
* @param file String
|
||||
*/
|
||||
protected void loadFragmentShader(String filename) {
|
||||
String shaderSource = PApplet.join(parent.loadStrings(filename), "\n");
|
||||
attachFragmentShader(shaderSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and compiles the fragment shader contained in the URL.
|
||||
*
|
||||
* @param url URL
|
||||
*/
|
||||
protected void loadFragmentShader(URL url) {
|
||||
try {
|
||||
String shaderSource = PApplet.join(PApplet.loadStrings(url.openStream()), "\n");
|
||||
attachFragmentShader(shaderSource);
|
||||
} catch (IOException e) {
|
||||
PGraphics.showException("Cannot load shader " + url.getFile());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shaderSource a string containing the shader's code
|
||||
*/
|
||||
protected void attachVertexShader(String shaderSource) {
|
||||
vertexShader = pg.createGLSLVertShaderObject();
|
||||
|
||||
pgl.glShaderSource(vertexShader, shaderSource);
|
||||
pgl.glCompileShader(vertexShader);
|
||||
|
||||
pgl.glAttachShader(programObject, vertexShader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param shaderSource a string containing the shader's code
|
||||
*/
|
||||
protected void attachFragmentShader(String shaderSource) {
|
||||
fragmentShader = pg.createGLSLFragShaderObject();
|
||||
|
||||
pgl.glShaderSource(fragmentShader, shaderSource);
|
||||
pgl.glCompileShader(fragmentShader);
|
||||
|
||||
pgl.glAttachShader(programObject, fragmentShader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the log error for the opengl object obj. Prints error
|
||||
* message if needed.
|
||||
*/
|
||||
protected void checkLogInfo(String title, int obj) {
|
||||
String log = pgl.getShaderLog(obj);
|
||||
if (!log.equals("")) {
|
||||
System.out.println(title);
|
||||
System.out.println(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void release() {
|
||||
if (vertexShader != 0) {
|
||||
pg.deleteGLSLVertShaderObject(vertexShader);
|
||||
vertexShader = 0;
|
||||
}
|
||||
if (fragmentShader != 0) {
|
||||
pg.deleteGLSLFragShaderObject(fragmentShader);
|
||||
fragmentShader = 0;
|
||||
}
|
||||
if (programObject != 0) {
|
||||
pg.deleteGLSLProgramObject(programObject);
|
||||
programObject = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vertColor;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2011 Andres Colubri
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General
|
||||
Public License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelviewMatrix;
|
||||
|
||||
attribute vec4 inVertex;
|
||||
attribute vec4 inColor;
|
||||
attribute vec2 inSize;
|
||||
|
||||
varying vec4 vertColor;
|
||||
|
||||
void main() {
|
||||
vec4 pos = modelviewMatrix * inVertex;
|
||||
pos.xy += inSize.xy;
|
||||
gl_Position = projectionMatrix * pos;
|
||||
|
||||
vertColor = inColor;
|
||||
}
|
||||
Reference in New Issue
Block a user