You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(531) |
Nov
(322) |
Dec
(620) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(672) |
Feb
(420) |
Mar
(614) |
Apr
(560) |
May
(315) |
Jun
(257) |
Jul
(222) |
Aug
(328) |
Sep
(46) |
Oct
(203) |
Nov
(297) |
Dec
(196) |
2003 |
Jan
(216) |
Feb
(471) |
Mar
(234) |
Apr
(308) |
May
(280) |
Jun
(232) |
Jul
(155) |
Aug
(412) |
Sep
(906) |
Oct
(440) |
Nov
(269) |
Dec
(415) |
2004 |
Jan
(525) |
Feb
(320) |
Mar
(113) |
Apr
(205) |
May
(217) |
Jun
(43) |
Jul
(29) |
Aug
|
Sep
(80) |
Oct
(74) |
Nov
|
Dec
(13) |
2005 |
Jan
(10) |
Feb
(44) |
Mar
(57) |
Apr
(42) |
May
(51) |
Jun
(41) |
Jul
(65) |
Aug
(31) |
Sep
(51) |
Oct
(79) |
Nov
(94) |
Dec
(113) |
2006 |
Jan
(47) |
Feb
(40) |
Mar
(29) |
Apr
(41) |
May
(33) |
Jun
(51) |
Jul
(28) |
Aug
(56) |
Sep
(45) |
Oct
(7) |
Nov
(3) |
Dec
(1) |
From: Changes to t. C. r. <cla...@li...> - 2006-09-20 21:51:19
|
Author: harry Date: 2006-09-20 23:52:26 +0200 (Wed, 20 Sep 2006) New Revision: 1081 Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp Log: - Fixed null gc crash. Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-20 21:50:14 UTC (rev 1080) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-20 21:52:26 UTC (rev 1081) @@ -80,7 +80,7 @@ void CL_Sprite_Impl::init(const CL_StringRef &resource_id, CL_ResourceManager *resources, CL_SharedPtr<CL_SpriteData> sprite_data, CL_GraphicContext gc) { - gc = gc; + this->gc = gc; data = sprite_data; // bool pack_texture = resource.get_element().get_attribute("pack_texture", "yes") == "yes"; @@ -316,7 +316,7 @@ int texture_height = 1; while (texture_width < image.get_width()) texture_width *= 2; while (texture_height < image.get_height()) texture_height *= 2; - + CL_Texture texture(texture_width, texture_height, 1, 0, gc); texture.set_image(image); |
From: Changes to t. C. r. <cla...@li...> - 2006-09-20 21:49:12
|
Author: harry Date: 2006-09-20 23:50:14 +0200 (Wed, 20 Sep 2006) New Revision: 1080 Modified: Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp Development/ClanLib-0.9/Sources/GUI/gui_theme_default.cpp Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp Log: - More work on CL_LineEdit. Modified: Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp 2006-09-19 20:54:15 UTC (rev 1079) +++ Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp 2006-09-20 21:50:14 UTC (rev 1080) @@ -50,13 +50,22 @@ { public: CL_LineEdit_Impl() : + alignment(CL_LineEdit::Alignment::align_left), cursor_pos(0), max_length(-1), lowercase(false), uppercase(false), password_mode(false), selection_start(0), - selection_length(0) + selection_end(0), + cursor_blink_visible(true), + readonly(false), + text_start_offset(0), + selecting(false), + keyboard_selects(false), + jump_words(false), + next_move_starts_selection(false), + next_move_resets_selection(false) { } @@ -75,35 +84,42 @@ CL_Callback_v1<int> func_cursor_changed; CL_String text; - CL_Font font; - + CL_LineEdit::Alignment alignment; int cursor_pos; - int max_length; - bool lowercase; - bool uppercase; - bool password_mode; - + bool readonly; int selection_start; + int selection_end; + bool selecting; + bool keyboard_selects; + bool jump_words; + bool next_move_starts_selection; + bool next_move_resets_selection; - int selection_length; + CL_Rect content_rect; + static CL_String break_characters; private: void left(int count); - void right(int count); - void insert_text(int pos, const CL_StringRef &str); - void backspace(); - void del(); + int get_character_index(int mouse_x_wincoords); + int find_next_break_character(int pos); + int find_previous_break_character(int pos); + CL_Rect get_cursor_rect(); + CL_Rect get_selection_rect(); + void update_text_clipping(); + bool cursor_blink_visible; + unsigned int blink_timer; + int text_start_offset; }; ///////////////////////////////////////////////////////////////////////////// @@ -122,6 +138,12 @@ set_state("pressed", false); set_state("defaulted", false); set_state("disabled", false); + + // unsigned int blink_time_on = CL_StringHelp::text_to_int(lineedit->get_property("blink_time_on", "800")); + // unsigned int blink_time_off = CL_StringHelp::text_to_int(lineedit->get_property("blink_time_off", "300")); + + CL_GUIThemePart part_bg(this); + impl->content_rect = part_bg.get_content_box(get_geometry()); } CL_LineEdit::~CL_LineEdit() @@ -143,17 +165,17 @@ bool CL_LineEdit::is_lowercase() const { - return false; + return impl->lowercase; } bool CL_LineEdit::is_uppercase() const { - return false; + return impl->uppercase; } bool CL_LineEdit::is_password_mode() const { - return false; + return impl->password_mode; } int CL_LineEdit::get_max_length() const @@ -173,17 +195,17 @@ int CL_LineEdit::get_selection_start() const { - return 0; + return impl->selection_start; } int CL_LineEdit::get_selection_length() const { - return 0; + return impl->selection_end - impl->selection_start; } int CL_LineEdit::get_cursor_pos() const { - return 0; + return impl->cursor_pos; } ///////////////////////////////////////////////////////////////////////////// @@ -191,26 +213,32 @@ void CL_LineEdit::set_read_only(bool enable) { + impl->readonly = enable; } void CL_LineEdit::set_alignment(Alignment alignment) { + impl->alignment = alignment; } void CL_LineEdit::set_lowercase(bool enable) { + impl->lowercase = enable; } void CL_LineEdit::set_uppercase(bool enable) { + impl->uppercase = enable; } void CL_LineEdit::set_password_mode(bool enable) { + impl->password_mode = enable; } void CL_LineEdit::set_max_length(int length) { + impl->max_length = length; } void CL_LineEdit::set_text(const CL_StringRef &text) @@ -221,10 +249,13 @@ void CL_LineEdit::set_selection(int pos, int length) { + impl->selection_start = pos; + impl->selection_end = pos + length; } void CL_LineEdit::set_cursor_pos(int pos) { + impl->cursor_pos = pos; } ///////////////////////////////////////////////////////////////////////////// @@ -280,20 +311,75 @@ { del(); } + else if (e.id == CL_KEY_HOME) + { + cursor_pos = 0; + if (selecting) + selection_end = 0; + update_text_clipping(); + lineedit->invalidate_rect(); + } + else if (e.id == CL_KEY_END) + { + cursor_pos = text.size(); + if (selecting) + selection_end = text.size(); + update_text_clipping(); + lineedit->invalidate_rect(); + } + else if (e.id == CL_KEY_SHIFT) + { + keyboard_selects = true; + if (e.repeat_count == 0) + next_move_starts_selection = true; + } + else if (e.id == CL_KEY_CONTROL) + { + jump_words = true; + } else { insert_text(cursor_pos, e.str); cursor_pos += e.str.size(); + update_text_clipping(); } } + else if (e.type == CL_InputEvent::released) + { + if (e.id == CL_KEY_SHIFT) + { + keyboard_selects = false; + next_move_resets_selection = true; + } + else if (e.id == CL_KEY_CONTROL) + { + jump_words = false; + } + } } else if (e.device.get_type() == CL_InputDevice::mouse) { + if (e.type == CL_InputEvent::pressed && e.id == CL_MOUSE_LEFT) + { + selecting = true; + cursor_pos = get_character_index(e.mouse_pos.x); + selection_start = cursor_pos; + selection_end = selection_start; + lineedit->set_focus(); + lineedit->invalidate_rect(); + } if (e.type == CL_InputEvent::released && e.id == CL_MOUSE_LEFT) { + selecting = false; + selection_end = get_character_index(e.mouse_pos.x); lineedit->set_focus(); lineedit->invalidate_rect(); } + if (e.type == CL_InputEvent::pointer_moved && selecting) + { + selection_end = get_character_index(e.mouse_pos.x); + lineedit->invalidate_rect(); + } } } } @@ -301,32 +387,50 @@ void CL_LineEdit_Impl::on_render(CL_GraphicContext &gc, const CL_Rect &update_rect) { CL_GUIThemePart part_background(lineedit); - + CL_Rect rect = lineedit->get_geometry(); - CL_Rect content_rect = part_background.get_content_box(rect); part_background.render_box(gc, rect, update_rect); - + CL_Font old_font = gc.get_font(); gc.set_font(font); CL_Sized text_size = gc.get_text_size(text); - int padding_left = CL_StringHelp::text_to_int(lineedit->get_property("padding-left", "10")); - int padding_top = CL_StringHelp::text_to_int(lineedit->get_property("padding-top", "5")); + // draw selection + if( lineedit->get_selection_length() != 0 ) + { + CL_GUIThemePart part_selection(lineedit, "selection"); + CL_Rect selection_rect = get_selection_rect(); + part_selection.render_box(gc, selection_rect, update_rect); + } + + // draw text gc.draw_text( - content_rect.left + padding_left, + content_rect.left, content_rect.top + content_rect.get_height()/2 + text_size.height/2 - 2, - text, + text.substr(text_start_offset), CL_Colord::black); + + // draw cursor + if (lineedit->has_focus()) + { - if( lineedit->has_focus() ) - { - double cursor_x = content_rect.left + padding_left; - int substr_end = cursor_pos; - CL_Sized cursor_text_size = gc.get_text_size(text.substr(0, substr_end)); - cursor_x += cursor_text_size.width; - double cursor_y = content_rect.top + content_rect.get_height()/2.0 + text_size.height/2.0; - CL_Draw::line(cursor_x, cursor_y, cursor_x, cursor_y - text_size.height, CL_Colord::black, gc); + CL_GUIThemePart part_cursor(lineedit, "cursor"); + + if( cursor_blink_visible ) + { + part_cursor.set_state("blink_on", true); + part_cursor.set_state("blink_off", false); + } + else + { + part_cursor.set_state("blink_on", false); + part_cursor.set_state("blink_off", true); + } + + CL_Rect cursor_rect = get_cursor_rect(); + + part_cursor.render_box(gc, cursor_rect, update_rect); } gc.set_font(old_font); @@ -334,17 +438,66 @@ void CL_LineEdit_Impl::left(int count) { - cursor_pos -= count; + if (next_move_starts_selection) + { + selection_start = cursor_pos; + selection_end = cursor_pos; + next_move_starts_selection = false; + } + + if (next_move_resets_selection) + { + selection_start = 0; + selection_end = 0; + next_move_resets_selection = false; + } + + if (jump_words) + cursor_pos = find_previous_break_character(cursor_pos-1); + else + cursor_pos -= count; + + if (keyboard_selects) + { + selection_end = cursor_pos; + } + if (cursor_pos < 0) cursor_pos = 0; + + update_text_clipping(); lineedit->invalidate_rect(); } void CL_LineEdit_Impl::right(int count) { - cursor_pos += count; + if (next_move_starts_selection) + { + selection_start = cursor_pos; + selection_end = cursor_pos; + next_move_starts_selection = false; + } + + if (next_move_resets_selection) + { + selection_start = 0; + selection_end = 0; + next_move_resets_selection = false; + } + + if (jump_words) + cursor_pos = find_next_break_character(cursor_pos+1); + else + cursor_pos += count; + + if (keyboard_selects) + { + selection_end = cursor_pos; + } + if (cursor_pos > (int)text.size()) cursor_pos = text.size(); + update_text_clipping(); lineedit->invalidate_rect(); } @@ -372,3 +525,126 @@ lineedit->invalidate_rect(); } } + +int CL_LineEdit_Impl::get_character_index(int mouse_x_wincoords) +{ + CL_GraphicContext gc = lineedit->get_gc(); + CL_Font old_font = lineedit->get_gc().get_font(); + gc.set_font(font); + + CL_GUIThemePart part_background(lineedit); + CL_Rect rect = lineedit->get_geometry(); + + int mouse_x = mouse_x_wincoords - content_rect.left ; + + int seek_start = text_start_offset; + int seek_end = text.size(); + int seek_center = (seek_start + seek_end) / 2; + + while ((seek_end-seek_start) > 1) + { + CL_Sized text_size = gc.get_text_size(text.substr(text_start_offset, seek_center - text_start_offset)); + if (text_size.width > mouse_x) + seek_end = seek_center; + else + seek_start = seek_center; + seek_center = (seek_start+seek_end)/2; + } + + if (seek_center == text.size()-1 && mouse_x > gc.get_text_size(text.substr(text_start_offset, seek_center - text_start_offset)).width) + seek_center = text.size(); + + gc.set_font(old_font); + + return seek_center; +} + +void CL_LineEdit_Impl::update_text_clipping() +{ + CL_GUIThemePart part_background(lineedit); + CL_Rect rect = lineedit->get_geometry(); + + CL_GraphicContext gc = lineedit->get_gc(); + + CL_Sized text_size = gc.get_text_size(text.substr(text_start_offset)); + + CL_Rect cursor_rect = get_cursor_rect(); + + while (cursor_rect.right > content_rect.right) + { + text_start_offset++; + cursor_rect = get_cursor_rect(); + } + + if (cursor_pos < text_start_offset) + text_start_offset = cursor_pos; + +} + +CL_Rect CL_LineEdit_Impl::get_cursor_rect() +{ + CL_GUIThemePart part_background(lineedit); + CL_Rect rect = lineedit->get_geometry(); + + CL_GraphicContext gc = lineedit->get_gc(); + CL_Font old_font = lineedit->get_gc().get_font(); + gc.set_font(font); + + CL_GUIThemePart part_cursor(lineedit, "cursor"); + CL_Rect cursor_rect; + cursor_rect.top = content_rect.top; + cursor_rect.bottom = content_rect.bottom; + cursor_rect.left = content_rect.left; + int substr_end = cursor_pos - text_start_offset; + CL_Sized text_size_before_cursor = lineedit->get_gc().get_text_size(text.substr(text_start_offset, substr_end)); + cursor_rect.left += (int)(text_size_before_cursor.width+0.5); + cursor_rect.right = cursor_rect.left + part_cursor.get_preferred_width(); + + gc.set_font(old_font); + + return cursor_rect; +} + +CL_Rect CL_LineEdit_Impl::get_selection_rect() +{ + CL_GraphicContext gc = lineedit->get_gc(); + CL_Font old_font = lineedit->get_gc().get_font(); + gc.set_font(font); + + CL_GUIThemePart part_background(lineedit); + CL_Rect rect = lineedit->get_geometry(); + + int sel_start = min(selection_start, selection_end); + int sel_end = max(selection_start, selection_end); + + CL_Sized text_size_before_selection = lineedit->get_gc().get_text_size(text.substr(text_start_offset, sel_start-text_start_offset)); + CL_Sized text_size_selection = lineedit->get_gc().get_text_size(text.substr(sel_start,sel_end-sel_start)); + + CL_Rect selection_rect; + selection_rect.top = content_rect.top; + selection_rect.left = content_rect.left + (int)text_size_before_selection.width; + selection_rect.right = content_rect.left + (int)text_size_before_selection.width + (int)text_size_selection.width; + selection_rect.bottom = content_rect.bottom; + + gc.set_font(old_font); + return selection_rect; +} + +CL_String CL_LineEdit_Impl::break_characters = cl_text(" ::;,.-"); + +int CL_LineEdit_Impl::find_next_break_character(int search_start) +{ + int pos = text.find_first_of(break_characters, search_start); + if (pos == CL_String::npos) + return text.size(); + return pos; +} + +int CL_LineEdit_Impl::find_previous_break_character(int search_start) +{ + int pos = text.find_last_of(break_characters, search_start); + if (pos == CL_String::npos) + return 0; + return pos; +} + Modified: Development/ClanLib-0.9/Sources/GUI/gui_theme_default.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/gui_theme_default.cpp 2006-09-19 20:54:15 UTC (rev 1079) +++ Development/ClanLib-0.9/Sources/GUI/gui_theme_default.cpp 2006-09-20 21:50:14 UTC (rev 1080) @@ -84,7 +84,29 @@ CL_Rect CL_GUIThemeDefault::get_content_box(const CL_GUIThemePart &part, const CL_Rect &render_box_rect) const { - return render_box_rect; + CL_Rect content_box = render_box_rect; + + int margin_top = CL_StringHelp::text_to_int(part.get_property("margin-top", "0")); + int margin_left = CL_StringHelp::text_to_int(part.get_property("margin-left", "0")); + int margin_right = CL_StringHelp::text_to_int(part.get_property("margin-right", "0")); + int margin_bottom = CL_StringHelp::text_to_int(part.get_property("margin-bottom", "0")); + + int border_top = CL_StringHelp::text_to_int(part.get_property("border-top", "0")); + int border_left = CL_StringHelp::text_to_int(part.get_property("border-left", "0")); + int border_right = CL_StringHelp::text_to_int(part.get_property("border-right", "0")); + int border_bottom = CL_StringHelp::text_to_int(part.get_property("border-bottom", "0")); + + int padding_top = CL_StringHelp::text_to_int(part.get_property("padding-top", "0")); + int padding_left = CL_StringHelp::text_to_int(part.get_property("padding-left", "0")); + int padding_right = CL_StringHelp::text_to_int(part.get_property("padding-right", "0")); + int padding_bottom = CL_StringHelp::text_to_int(part.get_property("padding-bottom", "0")); + + content_box.left += margin_left + border_left + padding_left; + content_box.right -= (margin_right + border_right + padding_right); + content_box.top += margin_top + border_top + padding_top; + content_box.bottom -= (margin_bottom + border_bottom + padding_bottom); + + return content_box; } CL_Rect CL_GUIThemeDefault::get_render_box(const CL_GUIThemePart &part, const CL_Rect &content_box_rect) const Modified: Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp 2006-09-19 20:54:15 UTC (rev 1079) +++ Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp 2006-09-20 21:50:14 UTC (rev 1080) @@ -124,9 +124,9 @@ } else { - CL_String default_padding(cl_text("3")); + CL_String default_padding(cl_text("0")); CL_String default_margin(cl_text("0")); - CL_String default_border(cl_text("1")); + CL_String default_border(cl_text("0")); int margin_top = CL_StringHelp::text_to_int(part.get_property("margin-top", default_margin)); int margin_left = CL_StringHelp::text_to_int(part.get_property("margin-left", default_margin)); @@ -150,7 +150,7 @@ tmp_rect.right -= margin_right; tmp_rect.bottom -= margin_bottom; - CL_Colord bg_color( part.get_property("background-color") ); + CL_Colord bg_color( part.get_property("bg-color") ); CL_Colord border_color( part.get_property("border-color") ); CL_Rect rleft(tmp_rect.left, tmp_rect.top, tmp_rect.left+border_left, tmp_rect.bottom); |
From: Changes to t. C. r. <cla...@li...> - 2006-09-20 00:49:37
|
Hi Tom, A while back I was let go from my employment I held for 25 plus years. I can't thank you enough for starting me in this new profession. You have given me a exciting lease on life. Already taking home twice as much as I earned in my old job. I purchased a brand new Mercedes. Taking home 6 digit level in 18 months. Having a great time in this business. It is a blast and I am a hero to the judges and to my clients. What an outstanding business to be in. Doing exactly what your training recommends me to do, is proceeding better than I ever dreamed possible. I go to the local court house and locate all of the clients I can handle. I avail myself of your advanced reporting services to find all items which can be garnished. Using your fill in the blank forms I send them thru the post office to the appropriate firms. Then the funds arrive to my PO Box. Its like magic. I love it. I can take a holiday when ever I have the impulse to do so. France and Holland this year. Please provide this letter to others. This profession is so massive it needs many more of us assisting the courts and the people who have been damaged. Sincerely, N. Virginia This may well be you! Call 3*0*3***3-9-5***3-9-0-0 Above line to study more or to end receiving additional information and then to see location Hurrah! away he sped at a fair rate of speed, while all his anxiety changed to a feeling of sweet contentment. His success had greatly surprised him, but he concluded that the jar caused by dropping the instrument had relieved the pressure upon the works, and so helped rather than harmed the free action of the electric currents |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 20:53:12
|
Author: sphair Date: 2006-09-19 22:54:15 +0200 (Tue, 19 Sep 2006) New Revision: 1079 Modified: Development/ClanLib-0.9/Tests/Display/Sprites1/ Log: Property changes on: Development/ClanLib-0.9/Tests/Display/Sprites1 ___________________________________________________________________ Name: svn:ignore + *.ncb *.suo *.user |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 20:51:53
|
Author: sphair Date: 2006-09-19 22:52:56 +0200 (Tue, 19 Sep 2006) New Revision: 1078 Added: Development/ClanLib-0.9/Tests/Display/Sprites1/ Development/ClanLib-0.9/Tests/Display/Sprites1/Images/ Development/ClanLib-0.9/Tests/Display/Sprites1/Images/pacman.pcx Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.sln Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.vcproj Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.sln Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.vcproj Development/ClanLib-0.9/Tests/Display/Sprites1/test.cpp Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp Log: Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-19 20:52:56 UTC (rev 1078) @@ -274,20 +274,16 @@ double pixelcenter_x = 0.38 / tex_width; double pixelcenter_y = 0.38 / tex_height; -/* double tc_x1 = (frame.position.left) / tex_width; - double tc_y1 = (frame.position.top) / tex_height; - double tc_x2 = (frame.position.left + width) / tex_width; - double tc_y2 = (frame.position.top + height) / tex_height; -*/ double tc_x1 = (frame.position.left) / tex_width + pixelcenter_x; double tc_y1 = (frame.position.top) / tex_height + pixelcenter_y; double tc_x2 = (frame.position.left + width) / tex_width + pixelcenter_x; double tc_y2 = (frame.position.top + height) / tex_height + pixelcenter_y; // Apply translation alignment - // TODO: Should this truncate decimals, or use decimals (can cause blurring with even sizes) ? -// CL_Pointd pos = calc_origin(impl->translation_origin, CL_Sized(dest_width, dest_height)); + // TODO: Should this truncate decimals: CL_Point pos = calc_origin(impl->translation_origin, CL_Size((int)dest_width, (int)dest_height)); + // TODO: or use decimals (can cause blurring with odd sizes and center alignments) ? + // CL_Pointd pos = calc_origin(impl->translation_origin, CL_Sized(dest_width, dest_height)); x -= pos.x + impl->translation_hotspot.x; y -= pos.y + impl->translation_hotspot.y; Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-19 20:52:56 UTC (rev 1078) @@ -324,7 +324,7 @@ frame.position = rect; // frame.position = CL_Rect(0, 0, width, height); frame.texture = texture; - frame.delay = 0.1f; + frame.delay = 150.0f; frame.offset = CL_Point(0, 0); frames.push_back(frame); Added: Development/ClanLib-0.9/Tests/Display/Sprites1/Images/pacman.pcx =================================================================== (Binary files differ) Property changes on: Development/ClanLib-0.9/Tests/Display/Sprites1/Images/pacman.pcx ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.sln =================================================================== --- Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.sln 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.sln 2006-09-19 20:52:56 UTC (rev 1078) @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sprites1-vc71", "Sprites1-vc71.vcproj", "{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug.ActiveCfg = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug.Build.0 = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release.ActiveCfg = Release|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Added: Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.vcproj =================================================================== --- Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.vcproj 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc71.vcproj 2006-09-19 20:52:56 UTC (rev 1078) @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="Sprites1-vc71" + ProjectGUID="{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Sprites1.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Sprites1.pdb" + SubSystem="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Sprites1.exe" + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\test.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.sln =================================================================== --- Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.sln 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.sln 2006-09-19 20:52:56 UTC (rev 1078) @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sprites1-vc80", "Sprites1-vc80.vcproj", "{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug|Win32.ActiveCfg = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug|Win32.Build.0 = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release|Win32.ActiveCfg = Release|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.vcproj =================================================================== --- Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.vcproj 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Tests/Display/Sprites1/Sprites1-vc80.vcproj 2006-09-19 20:52:56 UTC (rev 1078) @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="Sprites1-vc80" + ProjectGUID="{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Sprites1.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/Sprites1.pdb" + SubSystem="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/Sprites1.exe" + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\test.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: Development/ClanLib-0.9/Tests/Display/Sprites1/test.cpp =================================================================== --- Development/ClanLib-0.9/Tests/Display/Sprites1/test.cpp 2006-09-19 20:48:22 UTC (rev 1077) +++ Development/ClanLib-0.9/Tests/Display/Sprites1/test.cpp 2006-09-19 20:52:56 UTC (rev 1078) @@ -0,0 +1,84 @@ +#include <ClanLib/core.h> +#include <ClanLib/application.h> +#include <ClanLib/display.h> +#include <ClanLib/gl.h> + +class App : public CL_ClanApplication +{ + int main(int argc, char** argv) + { + CL_ConsoleWindow console("Console"); + console.redirect_stdio(); + + try + { + CL_SetupCore setup_core; + CL_SetupDisplay setup_disp; + CL_SetupGL setup_gl; + + CL_DisplayWindow window("Hello", 640, 480); + CL_GraphicContext gc = window.get_gc(); + + CL_BlendMode blend_mode1; + blend_mode1.enable_blending(true); + gc.set_blend_mode(blend_mode1); + + gc.set_map_mode(cl_map_2d_upper_left); + + CL_PixelBuffer buffer = CL_ImageProviderFactory::load("Images\\pacman.pcx"); + + int texture_width = 1; + int texture_height = 1; + while (texture_width < buffer.get_width()) texture_width *= 2; + while (texture_height < buffer.get_height()) texture_height *= 2; + + CL_Texture texture(texture_width, texture_height, 1, 0, gc); + texture.set_image(buffer); + + CL_SpriteDescription desc_pacman; + desc_pacman.add_gridclipped_frames(texture, 126, 93, 26, 30, 12, 2, 2, 2); + + CL_Sprite spr_pacman(desc_pacman); + + bool quit = false; + int count = 0; + while(!quit) + { + CL_Draw::fill( + 0, 0, + 640, 480, + CL_Color::green); + + CL_Draw::line(10,0,100,100, CL_Color::yellow); + + spr_pacman.set_frame(0); + spr_pacman.draw(0, 0); + + CL_Draw::line(0,0,100,100, CL_Color::yellow); + + spr_pacman.set_frame(1); + spr_pacman.draw(50, 0); + + spr_pacman.set_frame(2); + spr_pacman.draw(100, 0); + + window.flip(); + window.process_messages(); + + CL_System::sleep(10); + + if(count++ == 100) + quit = true; + } + + return 0; + } + catch (CL_Exception e) + { + CL_Console::write_line(e.message); + console.display_close_message(); + } + + return 0; + } +} app; |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 20:47:19
|
Author: mbn Date: 2006-09-19 22:48:22 +0200 (Tue, 19 Sep 2006) New Revision: 1077 Modified: Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp Log: - Added button state update stuff. Modified: Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp 2006-09-19 20:44:25 UTC (rev 1076) +++ Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp 2006-09-19 20:48:22 UTC (rev 1077) @@ -1052,6 +1052,8 @@ key.type = CL_InputEvent::released; // Emit message: + if (id >= 0 && id < 32) + mouse->key_states[id] = down; mouse->sig_provider_event->invoke(key); } |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 20:43:26
|
Author: mbn Date: 2006-09-19 22:44:25 +0200 (Tue, 19 Sep 2006) New Revision: 1076 Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp Log: - Added missing body for CL_SpriteData constructor. Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-19 20:33:19 UTC (rev 1075) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-19 20:44:25 UTC (rev 1076) @@ -36,6 +36,13 @@ #include <list> ///////////////////////////////////////////////////////////////////////////// +// CL_SpriteData implementation: + +CL_SpriteData::CL_SpriteData(const CL_StringRef &resource_id, CL_ResourceManager *resources, CL_GraphicContext gc) +{ +} + +///////////////////////////////////////////////////////////////////////////// // CL_Sprite_Impl construction: CL_Sprite_Impl::CL_Sprite_Impl() : |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 20:32:18
|
Author: mbn Date: 2006-09-19 22:33:19 +0200 (Tue, 19 Sep 2006) New Revision: 1075 Modified: Development/ClanLib-0.9/Sources/API/Display/graphic_context.h Development/ClanLib-0.9/Sources/API/Display/graphic_context_provider.h Development/ClanLib-0.9/Sources/Display/graphic_context.cpp Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.h Log: - Implemented setting light sources. - Added reset functions for textures, program objects and light sources. Modified: Development/ClanLib-0.9/Sources/API/Display/graphic_context.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/graphic_context.h 2006-09-19 19:56:05 UTC (rev 1074) +++ Development/ClanLib-0.9/Sources/API/Display/graphic_context.h 2006-09-19 20:33:19 UTC (rev 1075) @@ -162,12 +162,21 @@ //: Select texture into unit. void set_texture(int unit_index, const CL_Texture &texture); + //: Remove texture from unit. + void reset_texture(int unit_index); + //: Set active program object. void set_program_object(const CL_ProgramObject &program); + //: Remove active program object. + void reset_program_object(); + //: Set light source. void set_light(int light_index, const CL_LightSource &light); + //: Remove light source. + void reset_light(int light_index); + //: Set blending modes. void set_blend_mode(const CL_BlendMode &blend_mode); Modified: Development/ClanLib-0.9/Sources/API/Display/graphic_context_provider.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/graphic_context_provider.h 2006-09-19 19:56:05 UTC (rev 1074) +++ Development/ClanLib-0.9/Sources/API/Display/graphic_context_provider.h 2006-09-19 20:33:19 UTC (rev 1075) @@ -112,17 +112,26 @@ virtual CL_ShaderObjectProvider *alloc_shader_object() = 0; //: Set active program object. - virtual void set_program_object(const CL_ProgramObject &program)=0; + virtual void set_program_object(const CL_ProgramObject &program) = 0; + //: Remove active program object. + virtual void reset_program_object() = 0; + //: Setup texture unit. virtual void set_texture_unit(int unit_index, const CL_TextureUnit &unit) = 0; //: Select texture into unit. virtual void set_texture(int unit_index, const CL_Texture &texture) = 0; + //: Remove texture from unit. + virtual void reset_texture(int unit_index) = 0; + //: Set light source. virtual void set_light(int light_index, const CL_LightSource &light) = 0; + //: Remove light source. + virtual void reset_light(int light_index) = 0; + //: Set blending modes. virtual void set_blend_mode(const CL_BlendMode &blendmode) = 0; Modified: Development/ClanLib-0.9/Sources/Display/graphic_context.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/graphic_context.cpp 2006-09-19 19:56:05 UTC (rev 1074) +++ Development/ClanLib-0.9/Sources/Display/graphic_context.cpp 2006-09-19 20:33:19 UTC (rev 1075) @@ -163,16 +163,31 @@ impl->provider->set_texture(unit_index, texture); } +void CL_GraphicContext::reset_texture(int unit_index) +{ + impl->provider->reset_texture(unit_index); +} + void CL_GraphicContext::set_program_object(const CL_ProgramObject &program) { impl->provider->set_program_object(program); } +void CL_GraphicContext::reset_program_object() +{ + impl->provider->reset_program_object(); +} + void CL_GraphicContext::set_light(int light_index, const CL_LightSource &light) { impl->provider->set_light(light_index, light); } +void CL_GraphicContext::reset_light(int light_index) +{ + impl->provider->reset_light(light_index); +} + void CL_GraphicContext::set_buffer_control(const CL_BufferControl &buffer_control) { impl->provider->set_buffer_control(buffer_control); Modified: Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 19:56:05 UTC (rev 1074) +++ Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 20:33:19 UTC (rev 1075) @@ -38,6 +38,7 @@ #include "opengl_shader_object_provider.h" #include "API/Core/IOData/cl_endian.h" #include "API/Core/System/databuffer.h" +#include "API/Core/Math/cl_vector.h" #include "API/Display/texture.h" #include "API/Display/primitives_array.h" #include "API/Display/pixel_buffer.h" @@ -47,6 +48,7 @@ #include "API/Display/polygon_rasterizer.h" #include "API/Display/program_object.h" #include "API/Display/texture_unit.h" +#include "API/Display/light_source.h" #include "API/GL/opengl_state.h" #include "API/GL/opengl.h" #include "API/GL/opengl_wrap.h" @@ -300,6 +302,24 @@ } } +void CL_OpenGLGraphicContextProvider::reset_texture(int unit_index) +{ + render_state->set_active(); + + if (clActiveTexture != 0) + { + clActiveTexture( CL_TEXTURE0 + unit_index ); + } + else if (unit_index > 0) + { + return; + } + + clDisable(CL_TEXTURE_1D); + clDisable(CL_TEXTURE_2D); + clDisable(CL_TEXTURE_3D); +} + void CL_OpenGLGraphicContextProvider::set_program_object(const CL_ProgramObject &program) { if (clUseProgram == 0) @@ -312,10 +332,59 @@ clUseProgram(program.get_handle()); } +void CL_OpenGLGraphicContextProvider::reset_program_object() +{ + render_state->set_active(); + clUseProgram(0); +} + void CL_OpenGLGraphicContextProvider::set_light(int light_index, const CL_LightSource &light) { + render_state->set_active(); + clEnable(CL_LIGHT0 + light_index); + + clLightf(CL_LIGHT0 + light_index, CL_SPOT_EXPONENT, (CLfloat) light.get_spot_exponent()); + clLightf(CL_LIGHT0 + light_index, CL_SPOT_CUTOFF, (CLfloat) light.get_spot_cutoff()); + clLightf(CL_LIGHT0 + light_index, CL_CONSTANT_ATTENUATION, (CLfloat) light.get_constant_attenuation()); + clLightf(CL_LIGHT0 + light_index, CL_LINEAR_ATTENUATION, (CLfloat) light.get_linear_attenuation()); + clLightf(CL_LIGHT0 + light_index, CL_QUADRATIC_ATTENUATION, (CLfloat) light.get_quadratic_attenuation()); + + double c[4]; + CLfloat cf[4]; + + light.get_ambient_intensity(c[0], c[1], c[2], c[3]); + cf[0] = (CLfloat) c[0]; cf[1] = (CLfloat) c[1]; cf[2] = (CLfloat) c[2]; cf[3] = (CLfloat) c[3]; + clLightfv(CL_LIGHT0 + light_index, CL_AMBIENT, cf); + + light.get_diffuse_intensity(c[0], c[1], c[2], c[3]); + cf[0] = (CLfloat) c[0]; cf[1] = (CLfloat) c[1]; cf[2] = (CLfloat) c[2]; cf[3] = (CLfloat) c[3]; + clLightfv(CL_LIGHT0 + light_index, CL_DIFFUSE, cf); + + light.get_specular_intensity(c[0], c[1], c[2], c[3]); + cf[0] = (CLfloat) c[0]; cf[1] = (CLfloat) c[1]; cf[2] = (CLfloat) c[2]; cf[3] = (CLfloat) c[3]; + clLightfv(CL_LIGHT0 + light_index, CL_SPECULAR, cf); + + CL_Vector v = light.get_position(); + cf[0] = (CLfloat) v.x; + cf[1] = (CLfloat) v.y; + cf[2] = (CLfloat) v.z; + cf[3] = (CLfloat) v.w; + clLightfv(CL_LIGHT0 + light_index, CL_POSITION, cf); + + v = light.get_spot_direction(); + cf[0] = (CLfloat) v.x; + cf[1] = (CLfloat) v.y; + cf[2] = (CLfloat) v.z; + cf[3] = (CLfloat) v.w; + clLightfv(CL_LIGHT0 + light_index, CL_SPOT_DIRECTION, cf); } +void CL_OpenGLGraphicContextProvider::reset_light(int light_index) +{ + render_state->set_active(); + clDisable(CL_LIGHT0 + light_index); +} + void CL_OpenGLGraphicContextProvider::draw_primitives(CL_PrimitivesType type, const CL_PrimitivesArray &array) { render_state->set_active(); Modified: Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.h =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.h 2006-09-19 19:56:05 UTC (rev 1074) +++ Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.h 2006-09-19 20:33:19 UTC (rev 1075) @@ -121,10 +121,16 @@ void set_texture(int unit_index, const CL_Texture &texture); + void reset_texture(int unit_index); + void set_program_object(const CL_ProgramObject &program); + void reset_program_object(); + void set_light(int light_index, const CL_LightSource &light); + void reset_light(int light_index); + void set_buffer_control(const CL_BufferControl &buffer_control); void draw_primitives(CL_PrimitivesType type, const CL_PrimitivesArray &array); |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 19:55:03
|
Author: mbn Date: 2006-09-19 21:56:05 +0200 (Tue, 19 Sep 2006) New Revision: 1074 Modified: Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp Development/ClanLib-0.9/Sources/GL/opengl_state_impl.cpp Log: - Implemented gc user projection mapping mode. Modified: Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 19:51:28 UTC (rev 1073) +++ Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 19:56:05 UTC (rev 1074) @@ -537,6 +537,7 @@ { map_mode = mode; + render_state->set_active(); render_state->set_map_mode(mode); switch (map_mode) @@ -548,6 +549,8 @@ render_state->setup_2d(true); break; case cl_user_projection: + clMatrixMode(CL_PROJECTION); + clLoadMatrixd(projection.matrix); break; } } @@ -555,6 +558,12 @@ void CL_OpenGLGraphicContextProvider::set_projection(const CL_Matrix4x4 &matrix) { projection = matrix; + if (map_mode == cl_user_projection) + { + render_state->set_active(); + clMatrixMode(CL_PROJECTION); + clLoadMatrixd(projection.matrix); + } } void CL_OpenGLGraphicContextProvider::set_modelview(const CL_Matrix4x4 &matrix) @@ -645,6 +654,8 @@ void CL_OpenGLGraphicContextProvider::set_polygon_rasterizer(const CL_PolygonRasterizer &raster) { + render_state->set_active(); + if (raster.is_antialiased()) clEnable(CL_POLYGON_SMOOTH); else @@ -678,6 +689,8 @@ void CL_OpenGLGraphicContextProvider::set_buffer_control(const CL_BufferControl &bc) { + render_state->set_active(); + if( bc.is_alpha_test_enabled() ) clEnable(CL_ALPHA_TEST); else Modified: Development/ClanLib-0.9/Sources/GL/opengl_state_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_state_impl.cpp 2006-09-19 19:51:28 UTC (rev 1073) +++ Development/ClanLib-0.9/Sources/GL/opengl_state_impl.cpp 2006-09-19 19:56:05 UTC (rev 1074) @@ -146,6 +146,8 @@ void CL_OpenGLState_Impl::set_map_mode(CL_MapMode mode) { map_mode = mode; + if (mode == cl_user_projection) + in_2d = false; } ///////////////////////////////////////////////////////////////////////////// |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 19:50:25
|
Author: sphair Date: 2006-09-19 21:51:28 +0200 (Tue, 19 Sep 2006) New Revision: 1073 Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp Log: - workaround for translation offset causing blurry sprites (need better solution later) Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-19 19:43:14 UTC (rev 1072) +++ Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-19 19:51:28 UTC (rev 1073) @@ -274,33 +274,38 @@ double pixelcenter_x = 0.38 / tex_width; double pixelcenter_y = 0.38 / tex_height; +/* double tc_x1 = (frame.position.left) / tex_width; + double tc_y1 = (frame.position.top) / tex_height; + double tc_x2 = (frame.position.left + width) / tex_width; + double tc_y2 = (frame.position.top + height) / tex_height; +*/ double tc_x1 = (frame.position.left) / tex_width + pixelcenter_x; double tc_y1 = (frame.position.top) / tex_height + pixelcenter_y; double tc_x2 = (frame.position.left + width) / tex_width + pixelcenter_x; double tc_y2 = (frame.position.top + height) / tex_height + pixelcenter_y; // Apply translation alignment - CL_Pointd pos = calc_origin(impl->translation_origin, CL_Sized(dest_width, dest_height)); + // TODO: Should this truncate decimals, or use decimals (can cause blurring with even sizes) ? +// CL_Pointd pos = calc_origin(impl->translation_origin, CL_Sized(dest_width, dest_height)); + CL_Point pos = calc_origin(impl->translation_origin, CL_Size((int)dest_width, (int)dest_height)); x -= pos.x + impl->translation_hotspot.x; y -= pos.y + impl->translation_hotspot.y; - double alpha = impl->alpha; - CL_TexturedRectPrimitive quad; - quad.color(1.0, 1.0, 1.0, alpha); + quad.color(1.0, 1.0, 1.0, impl->alpha); quad.tex_coord(0, tc_x1, tc_y1); quad.vertex(x, y); - quad.color(1.0, 1.0, 1.0, alpha); + quad.color(1.0, 1.0, 1.0, impl->alpha); quad.tex_coord(0, tc_x2, tc_y1); quad.vertex(x + dest_width, y); - quad.color(1.0, 1.0, 1.0, alpha); + quad.color(1.0, 1.0, 1.0, impl->alpha); quad.tex_coord(0, tc_x1, tc_y2); quad.vertex(x, y + dest_height); - quad.color(1.0, 1.0, 1.0, alpha); + quad.color(1.0, 1.0, 1.0, impl->alpha); quad.tex_coord(0, tc_x2, tc_y2); quad.vertex(x + dest_width, y + dest_height); |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 19:42:18
|
Author: mbn Date: 2006-09-19 21:43:14 +0200 (Tue, 19 Sep 2006) New Revision: 1072 Modified: Development/ClanLib-0.9/Sources/Display/graphic_context.cpp Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.cpp Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.h Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.cpp Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.h Log: - Program and shader object OpenGL state improvements. Modified: Development/ClanLib-0.9/Sources/Display/graphic_context.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/graphic_context.cpp 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/Display/graphic_context.cpp 2006-09-19 19:43:14 UTC (rev 1072) @@ -216,115 +216,6 @@ void CL_GraphicContext::draw_text(double dest_x, double dest_y, const CL_StringRef &text, const CL_Colord &color) { impl->provider->draw_text(dest_x, dest_y, text, color); -/* -#ifdef WIN32 - HFONT font = CreateFont( - 20, // height - 0, // width - 0, // escapement - 0, // orientation - FW_NORMAL, // weight - FALSE, // italic - FALSE, // underline - FALSE, // strikeout - DEFAULT_CHARSET, // charset - OUT_DEFAULT_PRECIS, // output precision - CLIP_DEFAULT_PRECIS, // clipping precision - ANTIALIASED_QUALITY, // output quality - DEFAULT_PITCH, // pitch and family - TEXT("Tahoma")); - - HDC reference_dc = GetDC(0); - HFONT orig_font = (HFONT) SelectObject(reference_dc, font); - - CL_DataBuffer spacing_buffer(text.length()*2*sizeof(int)); - int *spacing = (int *) spacing_buffer.get_data(); - CL_DataBuffer glyphs_buffer(text.length()*2*sizeof(WCHAR)); - WCHAR *glyphs = (WCHAR *) glyphs_buffer.get_data(); - - GCP_RESULTS placement_results; - memset(&placement_results, 0, sizeof(GCP_RESULTS)); - placement_results.nGlyphs = text.length() * 2; - placement_results.lpDx = spacing; - placement_results.lpGlyphs = glyphs; - DWORD size = GetCharacterPlacement( - reference_dc, - text.data(), - text.length(), - 0, - &placement_results, - GCP_USEKERNING); - if (size != 0) - { - int pos = 0; - for (DWORD index = 0; index < placement_results.nGlyphs; index++) - { - MAT2 mat2; - memset(&mat2, 0, sizeof(MAT2)); - mat2.eM11.value = 1; - mat2.eM22.value = 1; - GLYPHMETRICS glyph_metrics; - DWORD buffer_size = GetGlyphOutline( - reference_dc, - (UINT) glyphs[index], - GGO_GRAY8_BITMAP, - &glyph_metrics, - 0, - 0, - &mat2); - if (buffer_size == 0) - continue; - - CL_DataBuffer buffer(buffer_size); - DWORD result = GetGlyphOutline( - reference_dc, - (UINT) glyphs[index], - GGO_GRAY8_BITMAP, - &glyph_metrics, - buffer_size, - buffer.get_data(), - &mat2); - if (result == 0) - continue; - - DWORD s_pitch = (glyph_metrics.gmBlackBoxX + 3) / 4; - s_pitch *= 4; - unsigned char *s = (unsigned char *) buffer.get_data(); - - DWORD d_pitch = glyph_metrics.gmBlackBoxX * sizeof(DWORD); - CL_PixelBuffer pb(glyph_metrics.gmBlackBoxX, glyph_metrics.gmBlackBoxY, d_pitch, CL_PixelFormat::rgba8888); - DWORD *d = (DWORD *) pb.get_data(); - for (DWORD y = 0; y < glyph_metrics.gmBlackBoxY; y++) - { - for (DWORD x = 0; x < glyph_metrics.gmBlackBoxX; x++) - { - unsigned int gray = s[x + y*s_pitch]; - d[x + y*d_pitch] = (gray << 24) + (gray << 16) + (gray << 8) + gray; - } - } - - draw_pixels((int) (dest_x + pos), (int) dest_y, 1.0, 1.0, pb); - pos += glyph_metrics.gmCellIncX; - } - } - - SelectObject(reference_dc, orig_font); - - -// HDC bitmap_dc = CreateCompatibleDC(reference_dc); -// HBITMAP bitmap = CreateCompatibleBitmap(ref_dc, width, height); -// HBITMAP orig_bitmap = (HBITMAP) SelectObject(bitmap_dc, bitmap); -// -// CL_PixelBuffer pb( -// -// SelectObject(bitmap_dc, orig_bitmap); -// DeleteObject(bitmap); -// DeleteDC(bitmap_dc); - - DeleteDC(reference_dc); - DeleteObject(font); -#endif -*/ } CL_Sized CL_GraphicContext::get_text_size(const CL_StringRef &text) Modified: Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/GL/opengl_graphic_context_provider.cpp 2006-09-19 19:43:14 UTC (rev 1072) @@ -305,13 +305,13 @@ if (clUseProgram == 0) return; - if( program.is_null() ) + render_state->set_active(); + if (program.is_null()) clUseProgram(0); else clUseProgram(program.get_handle()); } - void CL_OpenGLGraphicContextProvider::set_light(int light_index, const CL_LightSource &light) { } Modified: Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.cpp 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.cpp 2006-09-19 19:43:14 UTC (rev 1072) @@ -33,7 +33,6 @@ #include "API/Display/program_uniform.h" #include "API/Display/shader_object.h" #include "API/GL/opengl_wrap.h" -#include "API/GL/opengl_state.h" #include "API/Core/System/exception.h" #include "API/Core/Text/string_types.h" #include "API/Core/Text/string_format.h" @@ -42,14 +41,14 @@ // CL_OpenGLProgramObjectProvider Construction: CL_OpenGLProgramObjectProvider::CL_OpenGLProgramObjectProvider(CL_OpenGLGraphicContextProvider *gc_provider) -: gc_provider(gc_provider), handle(0) +: handle(0), gc_provider(gc_provider), state(gc_provider) { + state.set_active(); handle = clCreateProgram(); } CL_OpenGLProgramObjectProvider::~CL_OpenGLProgramObjectProvider() { - CL_OpenGLState state(gc_provider); state.set_active(); clDeleteProgram(handle); } @@ -69,6 +68,7 @@ bool CL_OpenGLProgramObjectProvider::get_link_status() const { + state.set_active(); CLint status = 0; clGetProgramiv(handle, CL_LINK_STATUS, &status); return (status != CL_FALSE); @@ -76,6 +76,7 @@ bool CL_OpenGLProgramObjectProvider::get_validate_status() const { + state.set_active(); CLint status = 0; clGetProgramiv(handle, CL_VALIDATE_STATUS, &status); return (status != CL_FALSE); @@ -88,6 +89,7 @@ CL_String CL_OpenGLProgramObjectProvider::get_info_log() const { + state.set_active(); CL_String result; CLsizei buffer_size = 16*1024; while (buffer_size < 2*1024*1024) @@ -107,6 +109,7 @@ int CL_OpenGLProgramObjectProvider::get_uniform_count() const { + state.set_active(); CLint count = 0; clGetProgramiv(handle, CL_ACTIVE_UNIFORMS, &count); return count; @@ -114,6 +117,7 @@ std::vector<CL_ProgramUniform> CL_OpenGLProgramObjectProvider::get_uniforms() const { + state.set_active(); std::vector<CL_ProgramUniform> uniforms; int count = get_uniform_count(); CLint name_size = 0; @@ -137,16 +141,16 @@ int CL_OpenGLProgramObjectProvider::get_uniform_location(const CL_StringRef &name) const { + state.set_active(); int loc = clGetUniformLocation(handle, name.c_str()); - if( loc == -1 ) throw CL_Exception(cl_format("CL_OpenGLProgramObjectProvider::set_uniform: uniform '%1' not found.", name.c_str())); - return loc; } int CL_OpenGLProgramObjectProvider::get_attribute_count() const { + state.set_active(); CLint count = 0; clGetProgramiv(handle, CL_ACTIVE_ATTRIBUTES, &count); return count; @@ -154,6 +158,7 @@ std::vector<CL_ProgramAttribute> CL_OpenGLProgramObjectProvider::get_attributes() const { + state.set_active(); std::vector<CL_ProgramAttribute> attributes; int count = get_attribute_count(); CLint name_size = 0; @@ -177,6 +182,7 @@ int CL_OpenGLProgramObjectProvider::get_attribute_location(const CL_StringRef &name) const { + state.set_active(); return clGetAttribLocation(handle, name.c_str()); } @@ -186,6 +192,7 @@ void CL_OpenGLProgramObjectProvider::attach(const CL_ShaderObject &obj) { shaders.push_back(obj); + state.set_active(); clAttachShader(handle, (CLuint) obj.get_handle()); } @@ -199,51 +206,59 @@ break; } } + state.set_active(); clDetachShader(handle, (CLuint) obj.get_handle()); } void CL_OpenGLProgramObjectProvider::bind_attribute_location(int index, const CL_StringRef &name) { + state.set_active(); clBindAttribLocation(handle, index, name.c_str()); } void CL_OpenGLProgramObjectProvider::link() { + state.set_active(); clLinkProgram(handle); } void CL_OpenGLProgramObjectProvider::validate() { + state.set_active(); clValidateProgram(handle); } - void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int p1) { + state.set_active(); int loc = get_uniform_location(name); clUniform1i(loc, p1); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int p1, int p2) { + state.set_active(); int loc = get_uniform_location(name); clUniform2i(loc, p1, p2); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int p1, int p2, int p3) { + state.set_active(); int loc = get_uniform_location(name); clUniform3i(loc, p1, p2, p3); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int p1, int p2, int p3, int p4) { + state.set_active(); int loc = get_uniform_location(name); clUniform4i(loc, p1, p2, p3, p4); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int size, int count, int *data) { + state.set_active(); int loc = get_uniform_location(name); if( size == 1 ) clUniform1iv(loc, count, data); else if( size == 2 ) clUniform2iv(loc, count, data); @@ -252,33 +267,37 @@ else throw CL_Exception(cl_format("CL_OpenGLProgramObjectProvider::set_uniform: unsupported size given to uniform '%1'.", name.c_str())); } - void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, float p1) { + state.set_active(); int loc = get_uniform_location(name); clUniform1f(loc, p1); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, float p1, float p2) { + state.set_active(); int loc = get_uniform_location(name); clUniform2f(loc, p1, p2); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, float p1, float p2, float p3) { + state.set_active(); int loc = get_uniform_location(name); clUniform3f(loc, p1, p2, p3); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, float p1, float p2, float p3, float p4) { + state.set_active(); int loc = clGetUniformLocation( handle, name.c_str()); clUniform4f(loc, p1, p2, p3, p4); } void CL_OpenGLProgramObjectProvider::set_uniform(const CL_StringRef &name, int size, int count, float *data) { + state.set_active(); int loc = get_uniform_location(name); if( size == 1 ) clUniform1fv(loc, count, data); else if( size == 2 ) clUniform2fv(loc, count, data); @@ -287,17 +306,15 @@ else throw CL_Exception(cl_format("CL_OpenGLProgramObjectProvider::set_uniform: unsupported size given to uniform '%1'.", name.c_str())); } - void CL_OpenGLProgramObjectProvider::set_uniform_matrix(const CL_StringRef &name, int size, int count, bool transpose, float *data) { + state.set_active(); int loc = get_uniform_location(name); if( size == 2 ) clUniformMatrix2fv(loc, count, transpose, data); else if( size == 3 ) clUniformMatrix3fv(loc, count, transpose, data); else if( size == 4 ) clUniformMatrix4fv(loc, count, transpose, data); else throw CL_Exception(cl_format("CL_OpenGLProgramObjectProvider::set_uniform_matrix: unsupported size given to uniform '%1'.", name.c_str())); - } - ///////////////////////////////////////////////////////////////////////////// // CL_OpenGLProgramObjectProvider Implementation: Modified: Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.h =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.h 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/GL/opengl_program_object_provider.h 2006-09-19 19:43:14 UTC (rev 1072) @@ -31,6 +31,7 @@ #define header_opengl_program_object_provider #include "API/GL/opengl_wrap.h" +#include "API/GL/opengl_state.h" #include "API/Display/program_object_provider.h" class CL_OpenGLGraphicContextProvider; @@ -118,12 +119,13 @@ //! Implementation: private: - CLuint handle; std::vector<CL_ShaderObject> shaders; CL_OpenGLGraphicContextProvider *gc_provider; + + mutable CL_OpenGLState state; }; #endif Modified: Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.cpp 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.cpp 2006-09-19 19:43:14 UTC (rev 1072) @@ -33,26 +33,21 @@ #include "API/Core/System/exception.h" #include "API/GL/opengl_state.h" - ///////////////////////////////////////////////////////////////////////////// // CL_OpenGLShaderObjectProvider Construction: CL_OpenGLShaderObjectProvider::CL_OpenGLShaderObjectProvider(CL_OpenGLGraphicContextProvider *gc_provider) -: gc_provider(gc_provider), handle(0) +: gc_provider(gc_provider), state(gc_provider), handle(0) { - } void CL_OpenGLShaderObjectProvider::create( CL_ShaderType shader_type, const CL_StringRef &source) { + state.set_active(); if (handle) - { - CL_OpenGLState state(gc_provider); - state.set_active(); clDeleteShader(handle); - } type = shader_type; handle = clCreateShader(shadertype_to_opengl(type)); @@ -69,12 +64,9 @@ CL_ShaderType shader_type, const std::vector<CL_StringRef> &sources) { + state.set_active(); if (handle) - { - CL_OpenGLState state(gc_provider); - state.set_active(); clDeleteShader(handle); - } type = shader_type; handle = clCreateShader(shadertype_to_opengl(type)); @@ -103,10 +95,8 @@ clCompileShader(handle); } - CL_OpenGLShaderObjectProvider::~CL_OpenGLShaderObjectProvider() { - CL_OpenGLState state(gc_provider); state.set_active(); clDeleteShader(handle); } @@ -127,6 +117,7 @@ bool CL_OpenGLShaderObjectProvider::get_compile_status() const { + state.set_active(); CLint status = 0; clGetShaderiv(handle, CL_COMPILE_STATUS, &status); return (status != CL_FALSE); @@ -139,6 +130,7 @@ CL_String CL_OpenGLShaderObjectProvider::get_info_log() const { + state.set_active(); CL_String result; CLsizei buffer_size = 16*1024; while (buffer_size < 2*1024*1024) @@ -158,6 +150,7 @@ CL_String CL_OpenGLShaderObjectProvider::get_shader_source() const { + state.set_active(); CL_String result; CLsizei buffer_size = 16*1024; while (buffer_size < 2*1024*1024) Modified: Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.h =================================================================== --- Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.h 2006-09-19 06:46:24 UTC (rev 1071) +++ Development/ClanLib-0.9/Sources/GL/opengl_shader_object_provider.h 2006-09-19 19:43:14 UTC (rev 1072) @@ -31,6 +31,7 @@ #include "API/Display/shader_object_provider.h" #include "API/GL/opengl_wrap.h" +#include "API/GL/opengl_state.h" class CL_OpenGLGraphicContextProvider; @@ -74,6 +75,8 @@ CL_OpenGLGraphicContextProvider *gc_provider; + mutable CL_OpenGLState state; + CLuint handle; CL_ShaderType type; |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 18:44:40
|
We purchase un-collected Judgments Receive the funds you are owed and see that justice happens Please call us at: 1-3 0 3-480-5712 We process uncollected Judgments Additional info or to un-register or to see our address. Just before he reached Tokio he came to a military fort, and for nearly an hour watched the skilful maneuvers of a regiment of soldiers at their morning drill They were not very big people, compared with other nations, but they seemed alert and well trained, and the boy decided it would require a brave enemy to face them on a field of battlem10 |
From: Changes to t. C. r. <cla...@li...> - 2006-09-19 06:45:29
|
Author: mrfun Date: 2006-09-19 08:46:24 +0200 (Tue, 19 Sep 2006) New Revision: 1071 Modified: Development/ClanLib-0.8/Sources/API/GL/opengl.h Development/ClanLib-0.8/Sources/GL/opengl.cpp Log: This patch makes CL more compatible with outdated GL drivers. It now checks for the existence of GL_EXT_abgr before using it. Also, it is now possible to query if an extension exists, and also explicitly ignore an extension. (this fixes my game on my laptop's outdated drivers, for instance) (only applicable to GL_EXT_abgr at this time) It's a little confusing as to when these functions can be used, but I've setup asserts for when you do it wrong. Functions added: CL_OpenGL::extension_exists CL_OpenGL::ignore_extension Modified: Development/ClanLib-0.8/Sources/API/GL/opengl.h =================================================================== --- Development/ClanLib-0.8/Sources/API/GL/opengl.h 2006-09-18 21:10:12 UTC (rev 1070) +++ Development/ClanLib-0.8/Sources/API/GL/opengl.h 2006-09-19 06:46:24 UTC (rev 1071) @@ -48,6 +48,7 @@ #endif #include <string> +#include <vector> #include <utility> #include "../Display/pixel_format.h" @@ -126,6 +127,19 @@ //- <p>The function returns false if pixelformat color depth is not convertible to //- OpenGL pixel format, otherwise the format and type are returned with values in format and type.</p> static bool to_opengl_pixelformat(const CL_PixelFormat &pf, CLenum &format, CLenum &type); + + //: Ignore OpenGL extensions by name, causing ClanLib to not attempt to use them + //- <p>Due to buggy OpenGL drivers it may be useful to pretend that certain extensions don't exist, causes + //- ClanLib to work around them. The only extension this would apply to right now is GL_EXT_abgr. extension_exists() + //- will always return false when an extension is specified here.</p> Note: You must call this BEFORE initting openGL. + static void ignore_extension( const std::string &extension_name); + + //: Test to see if a certain OGL Extension is present or not. It's slow, don't call it in a main loop. + static bool extension_exists( const char * extension_name); + +private: + + static std::vector<std::string> m_ignored_gl_extension; }; #endif Modified: Development/ClanLib-0.8/Sources/GL/opengl.cpp =================================================================== --- Development/ClanLib-0.8/Sources/GL/opengl.cpp 2006-09-18 21:10:12 UTC (rev 1070) +++ Development/ClanLib-0.8/Sources/GL/opengl.cpp 2006-09-19 06:46:24 UTC (rev 1071) @@ -32,6 +32,7 @@ #include "API/GL/opengl_wrap.h" #include "API/Core/System/error.h" #include "API/Core/IOData/cl_endian.h" +#include "API/core.h" #ifdef __APPLE__ #include <OpenGL/gl.h> @@ -50,6 +51,8 @@ #endif #endif +std::vector<std::string> CL_OpenGL::m_ignored_gl_extension; + CL_ProcAddress *CL_OpenGL::get_proc_address(const std::string& function_name) { #ifdef WIN32 @@ -208,6 +211,9 @@ bool CL_OpenGL::to_opengl_pixelformat(const CL_PixelFormat &pf, CLenum &format, CLenum &type) { + //Using CL_ABGR requires a GL extension to use it, we'll do a one time test to see if it's available or not + static const bool bHasEXT_abgr = extension_exists("GL_EXT_abgr"); + // indexed modes and colorkey requires special conversion to alpha and // therefore no OpenGL mode has a direct conversion format if (pf.has_colorkey() || pf.get_type() == pixelformat_index) @@ -256,6 +262,7 @@ if (rm && gm && bm && am) { + // the bit number must be 8, 16 or 32 for component // they all must have the same number of bits if ((!(rmb == 8 || rmb == 16 || rmb == 32)) || @@ -271,7 +278,7 @@ if (!big && rms == 0*bits && gms == 1*bits && bms == 2*bits && ams == 3*bits) format = CL_RGBA; - else if (!big && ams == 0*bits && bms == 1*bits && gms == 2*bits && rms == 3*bits) + else if (!big && ams == 0*bits && bms == 1*bits && gms == 2*bits && rms == 3*bits && bHasEXT_abgr) format = CL_ABGR; else if (big && rms == 3*bits && gms == 2*bits && bms == 1*bits && ams == 0*bits) format = CL_RGBA; @@ -350,3 +357,61 @@ return true; } + +bool CL_OpenGL::extension_exists( const char * extension_name ) +{ + /* + ** Search for extName in the extensions string. Use of strstr() + ** is not sufficient because extension names can be prefixes of + ** other extension names. Could use strtok() but the constant + ** string returned by glGetString can be in read-only memory. + */ + char *p = (char *) glGetString(GL_EXTENSIONS); + + if (!p) + { + cl_assert(!"setup_binds() hasn't been run, load something onto a GL surface first before trying to call this."); + return false; + } + + //is it on our ignore list? + + for (unsigned int i=0; i < m_ignored_gl_extension.size(); i++) + { + if (m_ignored_gl_extension.at(i) == extension_name) return false; + } + char *end; + int extNameLen; + + extNameLen = strlen(extension_name); + end = p + strlen(p); + + while (p < end) + { + int n = strcspn(p, " "); + if ((extNameLen == n) && (strncmp(extension_name, p, n) == 0)) + { + return true; + } + p += (n + 1); + } + + return false; +} + + +void CL_OpenGL::ignore_extension(const std::string &extension_name) +{ + +#ifdef DEBUG + char *p = (char *) glGetString(GL_EXTENSIONS); + + if (p) + { + cl_assert(!"ignore_extension should be used earlier, before OGL has been initialized."); + } + +#endif + + m_ignored_gl_extension.push_back(extension_name); +} \ No newline at end of file |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 21:09:14
|
Author: mbn Date: 2006-09-18 23:10:12 +0200 (Mon, 18 Sep 2006) New Revision: 1070 Modified: Development/ClanLib-0.9/Sources/Display/sprite_description.cpp Log: - Texture sources for sprite frames. Modified: Development/ClanLib-0.9/Sources/Display/sprite_description.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_description.cpp 2006-09-18 21:03:32 UTC (rev 1069) +++ Development/ClanLib-0.9/Sources/Display/sprite_description.cpp 2006-09-18 21:10:12 UTC (rev 1070) @@ -85,13 +85,22 @@ CL_DomElement cur_element = cur_node.to_element(); if (cur_element.get_tag_name() == "image") { + CL_String texture_name = cur_element.get_attribute("texture"); CL_String image_name = cur_element.get_attribute("file"); - CL_PixelBuffer image = CL_ImageProviderFactory::load(image_name, "", resources->get_directory()); + CL_PixelBuffer image; + CL_Texture texture; + if (texture_name.empty()) + image = CL_ImageProviderFactory::load(image_name, "", resources->get_directory()); + else + texture = CL_Texture(texture_name, resources, gc); CL_DomNode cur_child(cur_element.get_first_child()); if(cur_child.is_null()) { - add_frame(image); + if (texture_name.empty()) + add_frame(image); + else + add_frame(texture); } else { @@ -149,15 +158,24 @@ yspacing = atoi(image_spacing[1].c_str()); } - add_gridclipped_frames( - image, - xpos, ypos, - width, height, - xarray, yarray, - array_skipframes, - xspacing, yspacing); + if (texture_name.empty()) + add_gridclipped_frames( + image, + xpos, ypos, + width, height, + xarray, yarray, + array_skipframes, + xspacing, yspacing); + else + add_gridclipped_frames( + texture, + xpos, ypos, + width, height, + xarray, yarray, + array_skipframes, + xspacing, yspacing); } - else if( cur_child.get_node_name() == "palette") + else if( cur_child.get_node_name() == "palette" && texture_name.empty()) { int xpos = 0; int ypos = 0; @@ -173,7 +191,7 @@ image, xpos, ypos); } - else if( cur_child.get_node_name() == "alpha") + else if( cur_child.get_node_name() == "alpha" && texture_name.empty()) { int xpos = 0; int ypos = 0; |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 21:02:36
|
Author: mbn Date: 2006-09-18 23:03:32 +0200 (Mon, 18 Sep 2006) New Revision: 1069 Modified: Development/ClanLib-0.9/Sources/API/Display/sprite.h Development/ClanLib-0.9/Sources/Display/sprite.cpp Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp Development/ClanLib-0.9/Sources/Display/sprite_impl.h Log: - Improved resource loading stuff in sprite. Modified: Development/ClanLib-0.9/Sources/API/Display/sprite.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/sprite.h 2006-09-18 20:17:57 UTC (rev 1068) +++ Development/ClanLib-0.9/Sources/API/Display/sprite.h 2006-09-18 21:03:32 UTC (rev 1069) @@ -39,6 +39,7 @@ #include "../Core/Math/rect.h" #include "../Core/Signals/signal_v0.h" #include "../Core/IOData/virtual_directory.h" +#include "../Core/Resources/resource_data_session.h" #include "graphic_context.h" #include "color.h" #include "blend_mode.h" @@ -102,10 +103,10 @@ //: Returns blending functions. CL_BlendMode CL_Sprite::get_blend_mode() const; - //: Returns translation hotspot. + //: Returns translation hot-spot. void get_alignment(CL_Origin &origin, int &x, int &y) const; - //: Returns rotation hotspot. + //: Returns rotation hot-spot. void get_rotation_hotspot(CL_Origin &origin, int &x, int &y) const; //: Returns current frame in animation. 0 is first frame. @@ -267,8 +268,9 @@ //! Implementation: private: -// CL_ResourceDataSession session; CL_SharedPtr<CL_Sprite_Impl> impl; + + CL_ResourceDataSession resource_data_session; }; #endif Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-18 20:17:57 UTC (rev 1068) +++ Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-18 21:03:32 UTC (rev 1069) @@ -32,6 +32,7 @@ #include "API/Core/Resources/resource.h" #include "API/Core/XML/dom_element.h" #include "API/Core/Text/string_help.h" +#include "API/Core/Text/string_format.h" #include "API/Display/sprite.h" #include "API/Display/sprite_description.h" #include "API/Display/primitives_array.h" @@ -65,172 +66,34 @@ CL_Sprite::CL_Sprite(const CL_StringRef &resource_id, CL_ResourceManager *resources, CL_GraphicContext gc) : impl(new CL_Sprite_Impl) { - impl->gc = gc; - CL_Resource resource = resources->get_resource(resource_id); CL_String type = resource.get_element().get_tag_name(); - if(type != "sprite") - throw CL_Exception("Resource '" + resource_id + "' is not of type 'sprite'"); + if (type != "sprite") + throw CL_Exception(cl_format("Resource '%1' is not of type 'sprite'", resource_id)); -// bool pack_texture = resource.get_element().get_attribute("pack_texture", "yes") == "yes"; - - // Create sprite from spritedescription - CL_SpriteDescription desc(resource_id, resources, gc); - impl->create_textures(desc); - - // Load base angle - float base_angle = CL_StringHelp::text_to_float(resource.get_element().get_attribute("base_angle", "0")); - set_base_angle(base_angle); - - // Load id - int id = CL_StringHelp::text_to_int(resource.get_element().get_attribute("id", "0")); - set_id(id); - - // Load play options - CL_DomNode cur_node = resource.get_element().get_first_child(); - while (!cur_node.is_null()) + resource_data_session = CL_ResourceDataSession("sprite", resource); + CL_SharedPtr<CL_SpriteData> data(resource.get_data("sprite")); + if (data.is_null()) { - if (!cur_node.is_element()) - continue; - - CL_DomElement cur_element = cur_node.to_element(); - - CL_String tag_name = cur_element.get_tag_name(); - - // <color red="float" green="float" blue="float" alpha="float" /> - if (tag_name == "color") - { - float r = CL_StringHelp::text_to_float(cur_element.get_attribute("red", "1.0")); - float g = CL_StringHelp::text_to_float(cur_element.get_attribute("green","1.0")); - float b = CL_StringHelp::text_to_float(cur_element.get_attribute("blue", "1.0")); - float a = CL_StringHelp::text_to_float(cur_element.get_attribute("alpha", "1.0")); - set_color(r,g,b,a); - } - // <animation speed="integer" loop="[yes,no]" pingpong="[yes,no]" direction="[backward,forward]" on_finish="[blank,last_frame,first_frame]"/> - else if (tag_name == "animation") - { - float delay = CL_StringHelp::text_to_float(cur_element.get_attribute("speed", "60")) / 1000.0f; - int frame_count = get_frame_count(); - for(int i=0; i<frame_count; ++i) - set_frame_delay(i, delay); - - set_play_loop((cur_element.get_attribute("loop", "yes")) == "yes"); - set_play_pingpong((cur_element.get_attribute("pingpong", "no")) == "yes"); - set_play_backward((cur_element.get_attribute("direction", "forward")) == "backward"); - - CL_String on_finish = cur_element.get_attribute("on_finish", "blank"); - if(on_finish == "first_frame") - set_show_on_finish(CL_Sprite::show_first_frame); - else if(on_finish == "last_frame") - set_show_on_finish(CL_Sprite::show_last_frame); - else - set_show_on_finish(CL_Sprite::show_blank); - } - // <scale x="float" y="float /> - else if (tag_name == "scale") - { - float x = CL_StringHelp::text_to_float(cur_element.get_attribute("x", "1.0")); - float y = CL_StringHelp::text_to_float(cur_element.get_attribute("y", "1.0")); - set_scale(x, y); - } - // <translation origin="string" x="integer" y="integer" /> - else if (tag_name == "translation") - { - CL_String hotspot = cur_element.get_attribute("origin", "top_left"); - CL_Origin origin; - - if(hotspot == "center") - origin = origin_center; - else if(hotspot == "top_center") - origin = origin_top_center; - else if(hotspot == "top_right") - origin = origin_top_right; - else if(hotspot == "center_left") - origin = origin_center_left; - else if(hotspot == "center_right") - origin = origin_center_right; - else if(hotspot == "bottom_left") - origin = origin_bottom_left; - else if(hotspot == "bottom_center") - origin = origin_bottom_center; - else if(hotspot == "bottom_right") - origin = origin_bottom_right; - else - origin = origin_top_left; - - int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); - int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); - - set_alignment(origin, xoffset, yoffset); - } - // <rotation origin="string" x="integer" y="integer" /> - else if (tag_name == "rotation") - { - CL_String hotspot = cur_element.get_attribute("origin", "center"); - CL_Origin origin; - - if(hotspot == "top_left") - origin = origin_top_left; - else if(hotspot == "top_center") - origin = origin_top_center; - else if(hotspot == "top_right") - origin = origin_top_right; - else if(hotspot == "center_left") - origin = origin_center_left; - else if(hotspot == "center_right") - origin = origin_center_right; - else if(hotspot == "bottom_left") - origin = origin_bottom_left; - else if(hotspot == "bottom_center") - origin = origin_bottom_center; - else if(hotspot == "bottom_right") - origin = origin_bottom_right; - else - origin = origin_center; - - int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); - int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); - - set_rotation_hotspot(origin, xoffset, yoffset); - } - // <frame nr="integer" speed="integer" x="integer" y="integer" /> - else if (tag_name == "frame") - { - int nr = CL_StringHelp::text_to_int(cur_element.get_attribute("nr", "0")); - float delay = CL_StringHelp::text_to_float(cur_element.get_attribute("speed", "60")) / 1000.0f; - int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); - int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); - - set_frame_delay(nr, delay); - set_frame_offset(nr, CL_Point(xoffset, yoffset)); - } - - cur_node = cur_node.get_next_sibling(); + data = CL_SharedPtr<CL_SpriteData>(new CL_SpriteData(resource_id, resources, gc)); + resource.set_data("sprite", data); } - /*CL_Resource res = resources->get_resource(resource_id); -CL_SharedPtr<MyObject> p(new MyObject); -res.set_data("my-object", p); -CL_SharedPtr<MyObject> p2 = res.get_data("my-object"); -res.clear_data("my-object"); -*/ + impl->init(resource_id, resources, data, gc); } CL_Sprite::CL_Sprite(const CL_SpriteDescription &description, CL_GraphicContext gc) : impl(new CL_Sprite_Impl) { impl->gc = gc; - impl->create_textures(description); - restart(); } CL_Sprite::CL_Sprite(const CL_Sprite ©) -: impl(copy.impl) +: impl(copy.impl), resource_data_session(copy.resource_data_session) { -// resource_data_session = sprite.resource_data_session; } CL_Sprite::~CL_Sprite() Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-18 20:17:57 UTC (rev 1068) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-18 21:03:32 UTC (rev 1069) @@ -24,13 +24,15 @@ ** File Author(s): ** ** Kenneth Gangst (if your name is missing here, please add it) */ #include "Display/precomp.h" #include "sprite_impl.h" #include "API/Display/sprite_description.h" #include "API/Display/pixel_buffer.h" +#include "API/Core/Text/string_help.h" +#include "API/Core/Text/string_format.h" +#include "API/Core/XML/dom_element.h" #include <list> ///////////////////////////////////////////////////////////////////////////// @@ -69,6 +71,149 @@ { } +void CL_Sprite_Impl::init(const CL_StringRef &resource_id, CL_ResourceManager *resources, CL_SharedPtr<CL_SpriteData> sprite_data, CL_GraphicContext gc) +{ + gc = gc; + data = sprite_data; + +// bool pack_texture = resource.get_element().get_attribute("pack_texture", "yes") == "yes"; + CL_Resource resource = resources->get_resource(resource_id); + + // Create sprite from sprite description + CL_SpriteDescription desc(resource_id, resources, gc); + create_textures(desc); + + // Load base angle + base_angle = CL_StringHelp::text_to_double(resource.get_element().get_attribute("base_angle", "0")); + + // Load id + id = CL_StringHelp::text_to_int(resource.get_element().get_attribute("id", "0")); + + // Load play options + CL_DomNode cur_node = resource.get_element().get_first_child(); + while (!cur_node.is_null()) + { + if (!cur_node.is_element()) + continue; + + CL_DomElement cur_element = cur_node.to_element(); + + CL_String tag_name = cur_element.get_tag_name(); + + // <color red="float" green="float" blue="float" alpha="float" /> + if (tag_name == "color") + { + red = CL_StringHelp::text_to_double(cur_element.get_attribute("red", "1.0")); + green = CL_StringHelp::text_to_double(cur_element.get_attribute("green","1.0")); + blue = CL_StringHelp::text_to_double(cur_element.get_attribute("blue", "1.0")); + alpha = CL_StringHelp::text_to_double(cur_element.get_attribute("alpha", "1.0")); + } + // <animation speed="integer" loop="[yes,no]" pingpong="[yes,no]" direction="[backward,forward]" on_finish="[blank,last_frame,first_frame]"/> + else if (tag_name == "animation") + { + float delay = CL_StringHelp::text_to_float(cur_element.get_attribute("speed", "60")) / 1000.0f; + int frame_count = frames.size(); + for(int i=0; i<frame_count; ++i) + get_frame(i)->delay = delay; + + play_loop = ((cur_element.get_attribute("loop", "yes")) == "yes"); + play_pingpong = ((cur_element.get_attribute("pingpong", "no")) == "yes"); + play_backward = ((cur_element.get_attribute("direction", "forward")) == "backward"); + + CL_String on_finish = cur_element.get_attribute("on_finish", "blank"); + if (on_finish == "first_frame") + show_on_finish = CL_Sprite::show_first_frame; + else if(on_finish == "last_frame") + show_on_finish = CL_Sprite::show_last_frame; + else + show_on_finish = CL_Sprite::show_blank; + } + // <scale x="float" y="float /> + else if (tag_name == "scale") + { + scale_x = CL_StringHelp::text_to_double(cur_element.get_attribute("x", "1.0")); + scale_y = CL_StringHelp::text_to_double(cur_element.get_attribute("y", "1.0")); + } + // <translation origin="string" x="integer" y="integer" /> + else if (tag_name == "translation") + { + CL_String hotspot = cur_element.get_attribute("origin", "top_left"); + CL_Origin origin; + + if(hotspot == "center") + origin = origin_center; + else if(hotspot == "top_center") + origin = origin_top_center; + else if(hotspot == "top_right") + origin = origin_top_right; + else if(hotspot == "center_left") + origin = origin_center_left; + else if(hotspot == "center_right") + origin = origin_center_right; + else if(hotspot == "bottom_left") + origin = origin_bottom_left; + else if(hotspot == "bottom_center") + origin = origin_bottom_center; + else if(hotspot == "bottom_right") + origin = origin_bottom_right; + else + origin = origin_top_left; + + int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); + int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); + + translation_origin = origin; + translation_hotspot.x = xoffset; + translation_hotspot.y = yoffset; + } + // <rotation origin="string" x="integer" y="integer" /> + else if (tag_name == "rotation") + { + CL_String hotspot = cur_element.get_attribute("origin", "center"); + CL_Origin origin; + + if(hotspot == "top_left") + origin = origin_top_left; + else if(hotspot == "top_center") + origin = origin_top_center; + else if(hotspot == "top_right") + origin = origin_top_right; + else if(hotspot == "center_left") + origin = origin_center_left; + else if(hotspot == "center_right") + origin = origin_center_right; + else if(hotspot == "bottom_left") + origin = origin_bottom_left; + else if(hotspot == "bottom_center") + origin = origin_bottom_center; + else if(hotspot == "bottom_right") + origin = origin_bottom_right; + else + origin = origin_center; + + int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); + int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); + + rotation_origin = origin; + rotation_hotspot.x = xoffset; + rotation_hotspot.y = yoffset; + } + // <frame nr="integer" speed="integer" x="integer" y="integer" /> + else if (tag_name == "frame") + { + int nr = CL_StringHelp::text_to_int(cur_element.get_attribute("nr", "0")); + float delay = CL_StringHelp::text_to_float(cur_element.get_attribute("speed", "60")) / 1000.0f; + int yoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("y", "0")); + int xoffset = CL_StringHelp::text_to_int(cur_element.get_attribute("x", "0")); + + get_frame(nr)->delay = delay; + get_frame(nr)->offset = CL_Point(xoffset, yoffset); + } + + cur_node = cur_node.get_next_sibling(); + } +} + ///////////////////////////////////////////////////////////////////////////// // CL_Sprite_Impl attributes: Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.h =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.h 2006-09-18 20:17:57 UTC (rev 1068) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.h 2006-09-18 21:03:32 UTC (rev 1069) @@ -40,6 +40,13 @@ #include <vector> +//: Shared data between sprites from same resource +class CL_SpriteData +{ +public: + CL_SpriteData(const CL_StringRef &resource_id, CL_ResourceManager *resources, CL_GraphicContext gc); +}; + class CL_Sprite_Impl { //! Construction: @@ -48,6 +55,12 @@ virtual ~CL_Sprite_Impl(); + void init( + const CL_StringRef &resource_id, + CL_ResourceManager *resources, + CL_SharedPtr<CL_SpriteData> sprite_data, + CL_GraphicContext gc); + public: class SpriteFrame { @@ -69,6 +82,8 @@ public: const SpriteFrame *get_frame(unsigned int index) const; SpriteFrame *get_frame(unsigned int index); + + CL_SharedPtr<CL_SpriteData> data; double angle, angle_pitch, angle_yaw; double base_angle; |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 20:17:00
|
Author: mbn Date: 2006-09-18 22:17:57 +0200 (Mon, 18 Sep 2006) New Revision: 1068 Modified: Development/ClanLib-0.9/Sources/API/Display/texture.h Development/ClanLib-0.9/Sources/Display/texture.cpp Log: - Added texture resource. Modified: Development/ClanLib-0.9/Sources/API/Display/texture.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-18 19:59:51 UTC (rev 1067) +++ Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-18 20:17:57 UTC (rev 1068) @@ -37,6 +37,7 @@ #include "../Core/System/sharedptr.h" #include "../Core/Text/string_types.h" #include "../Core/IOData/virtual_directory.h" +#include "../Core/Resources/resource_data_session.h" #include "graphic_context.h" #include "compare_function.h" @@ -115,6 +116,11 @@ bool make_texture_nearest_power_of_two = true, CL_GraphicContext context = CL_GraphicContext()); + CL_Texture( + const CL_StringRef &resource_id, + CL_ResourceManager *resources, + CL_GraphicContext gc = CL_GraphicContext()); + virtual ~CL_Texture(); //! Attributes: @@ -328,6 +334,8 @@ //! Implementation: private: CL_SharedPtr<CL_Texture_Impl> impl; + + CL_ResourceDataSession resource_data_session; }; #endif Modified: Development/ClanLib-0.9/Sources/Display/texture.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-18 19:59:51 UTC (rev 1067) +++ Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-18 20:17:57 UTC (rev 1068) @@ -34,6 +34,8 @@ #include "API/Display/pixel_format.h" #include "API/Display/color.h" #include "API/Display/ImageProviders/provider_factory.h" +#include "API/Core/XML/dom_element.h" +#include "API/Core/Text/string_format.h" #include "graphic_context_impl.h" ///////////////////////////////////////////////////////////////////////////// @@ -142,6 +144,30 @@ set_subimage(CL_Point(0, 0), pb, 0); } +CL_Texture::CL_Texture( + const CL_StringRef &resource_id, + CL_ResourceManager *resources, + CL_GraphicContext gc) +{ + CL_Resource resource = resources->get_resource(resource_id); + CL_String type = resource.get_element().get_tag_name(); + + if (type != "texture") + throw CL_Exception(cl_format("Resource '%1' is not of type 'texture'", resource_id)); + + resource_data_session = CL_ResourceDataSession("texture", resource); + CL_SharedPtr<CL_Texture> data(resource.get_data("texture")); + if (data.is_null()) + { + CL_String filename = resource.get_element().get_attribute(cl_text("file")); + CL_VirtualDirectory directory = resource.get_manager().get_directory(); + bool power_of_two = resource.get_element().get_attribute(cl_text("power-of-two"), cl_text("true")) == cl_text("true"); + data = CL_SharedPtr<CL_Texture>(new CL_Texture(filename, directory, power_of_two, gc)); + resource.set_data("texture", data); + } + impl = data->impl; +} + CL_Texture::~CL_Texture() { } |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 19:59:13
|
Author: sphair Date: 2006-09-18 21:59:51 +0200 (Mon, 18 Sep 2006) New Revision: 1067 Added: Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.sln Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.vcproj Modified: Development/ClanLib-0.9/Sources/API/Display/draw.h Development/ClanLib-0.9/Sources/API/Display/gradient.h Development/ClanLib-0.9/Sources/Core/System/system.cpp Development/ClanLib-0.9/Sources/Display/draw.cpp Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp Development/ClanLib-0.9/Tests/GUI/LineEdit1/ Log: - reorganized CL_Draw (renamed CL_Draw::rectangle to CL_Draw::fill and added/fixed some parameters for other functions) Modified: Development/ClanLib-0.9/Sources/API/Display/draw.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/draw.h 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Sources/API/Display/draw.h 2006-09-18 19:59:51 UTC (rev 1067) @@ -64,15 +64,24 @@ static void line(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); static void line(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); - //: Draw a rectangle. - static void rectangle(const CL_Rect &rect, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); - static void rectangle(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); - static void rectangle(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); - static void rectangle(double x1, double y1, double x2, double y2, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); - static void rectangle(const CL_Pointd &start, const CL_Pointd &end, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); + //: Draw a box / rectangle. + static void box(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + static void box(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + static void box(const CL_Rectd &rect, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + //: Draw a filled box / rectangle. + static void fill(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + static void fill(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + static void fill(const CL_Rectd &rect, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + + static void gradient_fill(double x1, double y1, double x2, double y2, const CL_Gradient &color, CL_GraphicContext gc = CL_GraphicContext()); + static void gradient_fill(const CL_Pointd &start, const CL_Pointd &end, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); + static void gradient_fill(const CL_Rectd &rect, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); + //: Draw a circle. + static void circle(double center_x, double center_y, double radius, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); static void circle(const CL_Pointd ¢er, double radius, const CL_Colord &color, CL_GraphicContext gc = CL_GraphicContext()); + static void gradient_circle(const CL_Pointd ¢er, double radius, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); static void gradient_circle(const CL_Pointd ¢er, const CL_Pointd ¢ergradient, double radius, const CL_Gradient &gradient, CL_GraphicContext gc = CL_GraphicContext()); Modified: Development/ClanLib-0.9/Sources/API/Display/gradient.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/gradient.h 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Sources/API/Display/gradient.h 2006-09-18 19:59:51 UTC (rev 1067) @@ -95,7 +95,6 @@ { return !(*this == other); } - }; #endif Modified: Development/ClanLib-0.9/Sources/Core/System/system.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/System/system.cpp 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Sources/Core/System/system.cpp 2006-09-18 19:59:51 UTC (rev 1067) @@ -50,8 +50,6 @@ select(0, 0, 0, 0, &tv); #endif } - - CL_Mutex *CL_System::get_sharedptr_mutex() { static CL_Mutex *sharedptr_mutex = new CL_Mutex; Modified: Development/ClanLib-0.9/Sources/Display/draw.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/draw.cpp 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Sources/Display/draw.cpp 2006-09-18 19:59:51 UTC (rev 1067) @@ -99,16 +99,68 @@ gc.draw_primitives(cl_lines, line_array); } -void CL_Draw::rectangle(const CL_Rect &rect, const CL_Colord &color, CL_GraphicContext gc) +void CL_Draw::box(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc) { - rectangle(rect.left, rect.top, rect.right, rect.bottom, color, gc); + CL_RectPrimitive quad; + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(x1, y1); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(x2, y1); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(x2, y2); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(x1, y2); + + gc.draw_primitives(cl_line_loop, quad); } -void CL_Draw::rectangle(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc) +void CL_Draw::box(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc) { CL_RectPrimitive quad; quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(start.x, start.y); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(end.x, start.y); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(start.x, end.y); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(end.x, end.y); + + gc.draw_primitives(cl_line_loop, quad); +} + +void CL_Draw::box(const CL_Rectd &rect, const CL_Colord &color, CL_GraphicContext gc) +{ + CL_RectPrimitive quad; + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.left, rect.top); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.right, rect.top); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.left, rect.bottom); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.right, rect.bottom); + + gc.draw_primitives(cl_line_loop, quad); +} + +void CL_Draw::fill(double x1, double y1, double x2, double y2, const CL_Colord &color, CL_GraphicContext gc) +{ + CL_RectPrimitive quad; + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); quad.vertex(x1, y1); quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); @@ -123,7 +175,7 @@ gc.draw_primitives(cl_triangles, quad); } -void CL_Draw::rectangle(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc) +void CL_Draw::fill(const CL_Pointd &start, const CL_Pointd &end, const CL_Colord &color, CL_GraphicContext gc) { CL_RectPrimitive quad; @@ -142,10 +194,29 @@ gc.draw_primitives(cl_triangles, quad); } -void CL_Draw::rectangle(double x1, double y1, double x2, double y2, const CL_Gradient &gradient, CL_GraphicContext gc) +void CL_Draw::fill(const CL_Rectd &rect, const CL_Colord &color, CL_GraphicContext gc) { CL_RectPrimitive quad; + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.left, rect.top); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.right, rect.top); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.left, rect.bottom); + + quad.color(color.get_red(), color.get_green(), color.get_blue(), color.get_alpha()); + quad.vertex(rect.right, rect.bottom); + + gc.draw_primitives(cl_triangles, quad); +} + +void CL_Draw::gradient_fill(double x1, double y1, double x2, double y2, const CL_Gradient &gradient, CL_GraphicContext gc) +{ + CL_RectPrimitive quad; + quad.color(gradient.top_left.get_red(), gradient.top_left.get_green(), gradient.top_left.get_blue(), gradient.top_left.get_alpha()); quad.vertex(x1, y1); @@ -161,25 +232,49 @@ gc.draw_primitives(cl_triangles, quad); } -void CL_Draw::rectangle(const CL_Pointd &start, const CL_Pointd &end, const CL_Gradient &gradient, CL_GraphicContext gc) +void CL_Draw::gradient_fill(const CL_Pointd &start, const CL_Pointd &end, const CL_Gradient &gradient, CL_GraphicContext gc) { -/* CL_RectPrimitive quad; + CL_RectPrimitive quad; quad.color(gradient.top_left.get_red(), gradient.top_left.get_green(), gradient.top_left.get_blue(), gradient.top_left.get_alpha()); - quad.vertex(x1, y1); + quad.vertex(start.y, start.y); quad.color(gradient.top_right.get_red(), gradient.top_right.get_green(), gradient.top_right.get_blue(), gradient.top_right.get_alpha()); - quad.vertex(x2, y1); + quad.vertex(end.x, start.y); quad.color(gradient.bottom_left.get_red(), gradient.bottom_left.get_green(), gradient.bottom_left.get_blue(), gradient.bottom_left.get_alpha()); - quad.vertex(x1, y2); + quad.vertex(start.x, end.y); quad.color(gradient.bottom_right.get_red(), gradient.bottom_right.get_green(), gradient.bottom_right.get_blue(), gradient.bottom_right.get_alpha()); - quad.vertex(x2, y2); + quad.vertex(end.x, end.y); gc.draw_primitives(cl_triangles, quad); -*/} +} +void CL_Draw::gradient_fill(const CL_Rectd &rect, const CL_Gradient &gradient, CL_GraphicContext gc) +{ + CL_RectPrimitive quad; + + quad.color(gradient.top_left.get_red(), gradient.top_left.get_green(), gradient.top_left.get_blue(), gradient.top_left.get_alpha()); + quad.vertex(rect.left, rect.top); + + quad.color(gradient.top_right.get_red(), gradient.top_right.get_green(), gradient.top_right.get_blue(), gradient.top_right.get_alpha()); + quad.vertex(rect.right, rect.top); + + quad.color(gradient.bottom_left.get_red(), gradient.bottom_left.get_green(), gradient.bottom_left.get_blue(), gradient.bottom_left.get_alpha()); + quad.vertex(rect.left, rect.bottom); + + quad.color(gradient.bottom_right.get_red(), gradient.bottom_right.get_green(), gradient.bottom_right.get_blue(), gradient.bottom_right.get_alpha()); + quad.vertex(rect.right, rect.bottom); + + gc.draw_primitives(cl_triangles, quad); +} + +void CL_Draw::circle(double center_x, double center_y, double radius, const CL_Colord &color, CL_GraphicContext gc) +{ + gradient_circle(CL_Pointd(center_x, center_y), CL_Pointd(center_x, center_y), radius, CL_Gradient(color, color), gc); +} + void CL_Draw::circle(const CL_Pointd ¢er, double radius, const CL_Colord &color, CL_GraphicContext gc) { gradient_circle(center, center, radius, CL_Gradient(color, color), gc); @@ -192,7 +287,6 @@ void CL_Draw::gradient_circle(const CL_Pointd ¢er, const CL_Pointd ¢ergradient, double radius, const CL_Gradient &gradient, CL_GraphicContext gc) { - double offset_x = 0; double offset_y = 0; Modified: Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Sources/GUI/gui_theme_default_impl.cpp 2006-09-18 19:59:51 UTC (rev 1067) @@ -158,17 +158,17 @@ CL_Rect rtop(tmp_rect.left+border_left, tmp_rect.top, tmp_rect.right-border_right, tmp_rect.top+border_top); CL_Rect rbottom(tmp_rect.left+border_left, tmp_rect.bottom-border_bottom, tmp_rect.right-border_right, tmp_rect.bottom); - CL_Draw::rectangle(rleft, border_color, gc); - CL_Draw::rectangle(rtop, border_color, gc); - CL_Draw::rectangle(rbottom, border_color, gc); - CL_Draw::rectangle(rright, border_color, gc); + CL_Draw::fill(rleft, border_color, gc); + CL_Draw::fill(rtop, border_color, gc); + CL_Draw::fill(rbottom, border_color, gc); + CL_Draw::fill(rright, border_color, gc); tmp_rect.top += border_top; tmp_rect.left += border_left; tmp_rect.right -= (border_right); tmp_rect.bottom -= (border_bottom); - CL_Draw::rectangle(tmp_rect, bg_color, gc); + CL_Draw::fill(tmp_rect, bg_color, gc); } } Property changes on: Development/ClanLib-0.9/Tests/GUI/LineEdit1 ___________________________________________________________________ Name: svn:ignore - LineEdit1-vc71.ncb *.suo + LineEdit1-vc71.ncb *.suo Debug *.ncb *.user Added: Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.sln =================================================================== --- Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.sln 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.sln 2006-09-18 19:59:51 UTC (rev 1067) @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LineEdit1-vc80", "LineEdit1-vc80.vcproj", "{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug|Win32.ActiveCfg = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Debug|Win32.Build.0 = Debug|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release|Win32.ActiveCfg = Release|Win32 + {5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.vcproj =================================================================== --- Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.vcproj 2006-09-18 02:33:32 UTC (rev 1066) +++ Development/ClanLib-0.9/Tests/GUI/LineEdit1/LineEdit1-vc80.vcproj 2006-09-18 19:59:51 UTC (rev 1067) @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="LineEdit1-vc80" + ProjectGUID="{5C1AAF8C-7FF0-447E-B01D-AED0A0B2849F}" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/CheckBox1.exe" + LinkIncremental="2" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/CheckBox1.pdb" + SubSystem="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/CheckBox1.exe" + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\resources.xml" + > + </File> + <File + RelativePath=".\test.cpp" + > + </File> + <File + RelativePath=".\theme.css" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 02:33:06
|
Author: mrfun Date: 2006-09-18 04:33:32 +0200 (Mon, 18 Sep 2006) New Revision: 1066 Modified: Development/ClanLib-0.8/INSTALL.win32 Log: Corrected message about DX, it's only used for input Modified: Development/ClanLib-0.8/INSTALL.win32 =================================================================== --- Development/ClanLib-0.8/INSTALL.win32 2006-09-18 02:28:38 UTC (rev 1065) +++ Development/ClanLib-0.8/INSTALL.win32 2006-09-18 02:33:32 UTC (rev 1066) @@ -43,8 +43,8 @@ The Microsoft Platform SDK is available at: http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ -Windows builds of ClanLib use DirectX's for input and a few other things, so you'll also need to install -a semi recent version (8+) of the DirectX SDK. +Windows builds of ClanLib use DirectX's DirectInput8 for input, so you'll also need to install +a recent version (8+) of the DirectX SDK. DirectX SDK Downloads http://msdn.microsoft.com/directx/sdk/ |
From: Changes to t. C. r. <cla...@li...> - 2006-09-18 02:28:20
|
Author: mrfun Date: 2006-09-18 04:28:38 +0200 (Mon, 18 Sep 2006) New Revision: 1065 Modified: Development/ClanLib-0.8/INSTALL.win32 Log: Added note about requiring DirectX 8+ (suggested by Spearhead) Modified: Development/ClanLib-0.8/INSTALL.win32 =================================================================== --- Development/ClanLib-0.8/INSTALL.win32 2006-09-17 20:59:27 UTC (rev 1064) +++ Development/ClanLib-0.8/INSTALL.win32 2006-09-18 02:28:38 UTC (rev 1065) @@ -43,7 +43,12 @@ The Microsoft Platform SDK is available at: http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ +Windows builds of ClanLib use DirectX's for input and a few other things, so you'll also need to install +a semi recent version (8+) of the DirectX SDK. +DirectX SDK Downloads +http://msdn.microsoft.com/directx/sdk/ + 2. Preparing installation --------------------------------------------------------------------------- The first step in using ClanLib under Windows is to setup a sane build |
From: Changes to t. C. r. <cla...@li...> - 2006-09-17 20:58:34
|
Author: mbn Date: 2006-09-17 22:59:27 +0200 (Sun, 17 Sep 2006) New Revision: 1064 Modified: Development/ClanLib-0.9/Sources/API/Display/texture.h Development/ClanLib-0.9/Sources/Display/texture.cpp Log: - Added easy image loading constructor to CL_Texture. Modified: Development/ClanLib-0.9/Sources/API/Display/texture.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-17 20:38:03 UTC (rev 1063) +++ Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-17 20:59:27 UTC (rev 1064) @@ -35,6 +35,8 @@ #include "api_display.h" #include "../Core/System/sharedptr.h" +#include "../Core/Text/string_types.h" +#include "../Core/IOData/virtual_directory.h" #include "graphic_context.h" #include "compare_function.h" @@ -107,6 +109,12 @@ int border = 0, CL_GraphicContext context = CL_GraphicContext()); + CL_Texture( + const CL_StringRef &filename, + const CL_VirtualDirectory &directory = CL_VirtualDirectory(), + bool make_texture_nearest_power_of_two = true, + CL_GraphicContext context = CL_GraphicContext()); + virtual ~CL_Texture(); //! Attributes: Modified: Development/ClanLib-0.9/Sources/Display/texture.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-17 20:38:03 UTC (rev 1063) +++ Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-17 20:59:27 UTC (rev 1064) @@ -33,6 +33,7 @@ #include "API/Display/pixel_buffer.h" #include "API/Display/pixel_format.h" #include "API/Display/color.h" +#include "API/Display/ImageProviders/provider_factory.h" #include "graphic_context_impl.h" ///////////////////////////////////////////////////////////////////////////// @@ -118,6 +119,29 @@ impl->border = border; } +CL_Texture::CL_Texture( + const CL_StringRef &filename, + const CL_VirtualDirectory &directory, + bool make_texture_nearest_power_of_two, + CL_GraphicContext context) +{ + CL_PixelBuffer pb = CL_ImageProviderFactory::load(filename, CL_String8(), directory); + if (make_texture_nearest_power_of_two) + { + int texture_width = 1; + int texture_height = 1; + while (texture_width < pb.get_width()) texture_width *= 2; + while (texture_height < pb.get_height()) texture_height *= 2; + + *this = CL_Texture(texture_width, texture_height, 1, 0, context); + } + else + { + *this = CL_Texture(pb.get_width(), pb.get_height(), 1, 0, context); + } + set_subimage(CL_Point(0, 0), pb, 0); +} + CL_Texture::~CL_Texture() { } |
From: Changes to t. C. r. <cla...@li...> - 2006-09-17 20:37:12
|
Author: sphair Date: 2006-09-17 22:38:03 +0200 (Sun, 17 Sep 2006) New Revision: 1063 Modified: Development/ClanLib-0.9/Sources/API/Display/sprite_description.h Development/ClanLib-0.9/Sources/API/Display/texture.h Development/ClanLib-0.9/Sources/Display/sprite.cpp Development/ClanLib-0.9/Sources/Display/sprite_description.cpp Development/ClanLib-0.9/Sources/Display/sprite_description_impl.h Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp Development/ClanLib-0.9/Sources/Display/texture.cpp Log: - Added support for creating sprites based on pre-packed textures Modified: Development/ClanLib-0.9/Sources/API/Display/sprite_description.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/sprite_description.h 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/API/Display/sprite_description.h 2006-09-17 20:38:03 UTC (rev 1063) @@ -35,13 +35,33 @@ #include "api_display.h" #include "../Core/Text/string_types.h" #include "graphic_context.h" +#include "pixel_buffer.h" +#include "texture.h" #include <list> class CL_SpriteDescription_Impl; -class CL_PixelBuffer; class CL_Rect; class CL_ResourceManager; +class CL_SpriteDescriptionFrame +{ +public: + enum FrameType + { + type_pixelbuffer, + type_texture + }; + +public: + CL_SpriteDescriptionFrame(CL_PixelBuffer pixelbuffer, CL_Rect rect) : pixelbuffer(pixelbuffer), rect(rect), type(type_pixelbuffer) {}; + CL_SpriteDescriptionFrame(CL_Texture texture, CL_Rect rect) : texture(texture), rect(rect), type(type_texture) {}; + + CL_PixelBuffer pixelbuffer; + CL_Texture texture; + CL_Rect rect; + FrameType type; +}; + //: This class contains everything to construct a sprite - its data, default settings etc. //- !group=Display/Sprites! //- !header=display.h! @@ -68,10 +88,10 @@ //! Attributes: public: //: CL_PixelBuffer provider, CL_Rect position. - typedef std::pair<CL_PixelBuffer, CL_Rect> PixelBufferFrame; +// typedef std::pair<CL_PixelBuffer, CL_Rect> PixelBufferFrame; //: Returns a list over all available frames. - const std::list<PixelBufferFrame> &get_frames() const; + const std::list<CL_SpriteDescriptionFrame> &get_frames() const; //! Operations: public: @@ -79,40 +99,53 @@ CL_SpriteDescription &operator =(const CL_SpriteDescription ©); //: Adds a single image. - //param provider: Image source. + //param pixelbuffer: Image source. //param filename: Filename of image. //param vfs: Virtual File System to load image from. - void add_frame(const CL_PixelBuffer &provider); + void add_frame(const CL_PixelBuffer &pixelbuffer); + void add_frame(const CL_Texture &texture); + void add_frame(const CL_StringRef &filename, CL_VirtualDirectory dir = CL_VirtualDirectory()); + void add_frames(const CL_Texture &texture, CL_Rect *frames, int num_frames); + //: Adds images formed in a grid. //- <p>This function will cut out a grid of frames from one image.</p> - //param provider: Image source. + //param pixelbuffer: Image source. + //param texture: Image source. //param xpos, ypos: Position of where image grid starts. //param width, height: Size of a frame in the grid. //param xarray, yarray: Number of columns and rows in grid. //param array_skipframes: Number of frames to skip at last gridline. //param xspacing, yspacing: Pixel interspacing between grid frames. void add_gridclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos, int ypos, int width, int height, int xarray = 1, int yarray = 1, int array_skipframes = 0, int xspacing = 0, int yspacing = 0); + void add_gridclipped_frames( + const CL_Texture &texture, + int xpos, int ypos, + int width, int height, + int xarray = 1, int yarray = 1, + int array_skipframes = 0, + int xspacing = 0, int yspacing = 0); + //: Adds images separated with pure alpha (within trans_limit). //- <p>The alpha clipper will cut out frames from an image based on //- the transparency in the picture. It first determines the height //- of a row by searching for the first line that it considers //- completely transparent. Then it finds the width of each frame on //- this line by looking for columns that are completely transparency.</p> - //param provider: Image source. + //param pixelbuffer: Image source. //param xpos, ypos: Upper left position where alpha cutting should begin. //param trans_limit: Amount of non-transparent alpha allowed before a pixel is not considered transparent. void add_alphaclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos = 0, int ypos = 0, double trans_limit = 0.05f); @@ -121,19 +154,19 @@ //- the transparency in the picture. It scans the lines horizontally //- from top to bottom. As soon as a non-transarent pixel is discovered, //- the clipper finds the bounding box for that region and then moves on.</p> - //param provider: Image source. + //param pixelbuffer: Image source. //param xpos, ypos: Upper left position where alpha cutting should begin. //param trans_limit: Amount of non-transparent alpha allowed before a pixel is not considered transparent. void add_alphaclipped_frames_free( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos = 0, int ypos = 0, double trans_limit = 0.05f); //: Adds images separated with palette-colours defining the boundaries. - //param provider: Image source. + //param pixelbuffer: Image source. //param xpos, ypos: Upper left position where cutting should begin. void add_paletteclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos = 0, int ypos = 0); //! Implementation: Modified: Development/ClanLib-0.9/Sources/API/Display/texture.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/API/Display/texture.h 2006-09-17 20:38:03 UTC (rev 1063) @@ -116,17 +116,17 @@ //: Get the texture width. //param level: Mipmap level to get width for. - int get_width(int level); + int get_width(int level = 0) const; //: Get the texture height. //param level: Mipmap level to get height for. - int get_height(int level); + int get_height(int level = 0) const; //: Get the texture depth. - int get_depth(); + int get_depth() const; //: Get the texture border size. - int get_border(); + int get_border() const; //: Retrieve image data from texture. CL_PixelBuffer get_pixeldata(int level = 0); Modified: Development/ClanLib-0.9/Sources/Display/sprite.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/Display/sprite.cpp 2006-09-17 20:38:03 UTC (rev 1063) @@ -394,7 +394,7 @@ double y, CL_GraphicContext gc) { - if(impl->finished == false || impl->show_on_finish != show_blank) + if((impl->finished == false || impl->show_on_finish != show_blank) && impl->frames.size() > 0) { CL_Sprite_Impl::SpriteFrame &frame = impl->frames[impl->current_frame]; @@ -483,7 +483,7 @@ const CL_Rectd &dest, CL_GraphicContext gc) { - if(impl->finished == false || impl->show_on_finish != show_blank) + if((impl->finished == false || impl->show_on_finish != show_blank) && impl->frames.size() > 0) { CL_Sprite_Impl::SpriteFrame &frame = impl->frames[impl->current_frame]; Modified: Development/ClanLib-0.9/Sources/Display/sprite_description.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_description.cpp 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/Display/sprite_description.cpp 2006-09-17 20:38:03 UTC (rev 1063) @@ -36,7 +36,6 @@ #include "API/Core/XML/dom_node.h" #include "API/Core/XML/dom_element.h" #include "API/Display/sprite_description.h" -#include "API/Display/pixel_buffer.h" #include "API/Display/pixel_format.h" #include "API/Display/ImageProviders/provider_factory.h" #include "sprite_description_impl.h" @@ -236,7 +235,7 @@ ///////////////////////////////////////////////////////////////////////////// // CL_SpriteDescription attributes: -const std::list<CL_SpriteDescription::PixelBufferFrame> &CL_SpriteDescription::get_frames() const +const std::list<CL_SpriteDescriptionFrame> &CL_SpriteDescription::get_frames() const { return impl->frames; } @@ -250,19 +249,30 @@ return *this; } -void CL_SpriteDescription::add_frame(const CL_PixelBuffer &provider) +void CL_SpriteDescription::add_frame(const CL_PixelBuffer &pixelbuffer) { - impl->frames.push_back(PixelBufferFrame(provider, CL_Rect(0, 0, provider.get_width(), provider.get_height()))); + impl->frames.push_back(CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(0, 0, pixelbuffer.get_width(), pixelbuffer.get_height()))); } +void CL_SpriteDescription::add_frame(const CL_Texture &texture) +{ + impl->frames.push_back(CL_SpriteDescriptionFrame(texture, CL_Rect(0, 0, texture.get_width(), texture.get_height()))); +} + void CL_SpriteDescription::add_frame(const CL_StringRef &filename, CL_VirtualDirectory dir) { CL_PixelBuffer image = CL_ImageProviderFactory::load(filename, "", dir); add_frame(image); } +void CL_SpriteDescription::add_frames(const CL_Texture &texture, CL_Rect *frames, int num_frames) +{ + for(int i=0; i<num_frames; ++i) + impl->frames.push_back(CL_SpriteDescriptionFrame(texture, frames[i])); +} + void CL_SpriteDescription::add_gridclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos, int ypos, int width, int height, int xarray, int yarray, @@ -278,18 +288,45 @@ if (y == yarray -1 && x >= xarray - array_skipframes) break; - if(xstart + width > provider.get_width() || ystart + height > provider.get_height()) + if(xstart + width > pixelbuffer.get_width() || ystart + height > pixelbuffer.get_height()) throw CL_Exception("add_gridclipped_frames: Outside pixelbuffer bounds"); - impl->frames.push_back(PixelBufferFrame(provider, CL_Rect(xstart, ystart, xstart + width, ystart + height))); + impl->frames.push_back(CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(xstart, ystart, xstart + width, ystart + height))); xstart += width + xspace; } ystart += height + yspace; } } +void CL_SpriteDescription::add_gridclipped_frames( + const CL_Texture &texture, + int xpos, int ypos, + int width, int height, + int xarray, int yarray, + int array_skipframes, + int xspace, int yspace) +{ + int ystart = ypos; + for(int y = 0; y < yarray; y++) + { + int xstart = xpos; + for(int x = 0; x < xarray; x++) + { + if (y == yarray -1 && x >= xarray - array_skipframes) + break; + + if(xstart + width > texture.get_width() || ystart + height > texture.get_height()) + throw CL_Exception("add_gridclipped_frames: Outside texture bounds"); + + impl->frames.push_back(CL_SpriteDescriptionFrame(texture, CL_Rect(xstart, ystart, xstart + width, ystart + height))); + xstart += width + xspace; + } + ystart += height + yspace; + } +} + void CL_SpriteDescription::add_alphaclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos, int ypos, double trans_limit) { @@ -301,7 +338,7 @@ format.set_depth(32); format.enable_colorkey(false); - CL_PixelBuffer alpha_buffer = provider.to_format(format); + CL_PixelBuffer alpha_buffer = pixelbuffer.to_format(format); int begin = 0; bool prev_trans = true; @@ -363,7 +400,7 @@ else if (!opaque_row[x] && !prev_trans) { impl->frames.push_back( - PixelBufferFrame(provider, CL_Rect(begin, cut_top, x+1, cut_bottom))); + CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(begin, cut_top, x+1, cut_bottom))); prev_trans = true; } @@ -372,14 +409,14 @@ if (!prev_trans) { impl->frames.push_back( - PixelBufferFrame(provider, CL_Rect(begin, cut_top, alpha_width, cut_bottom))); + CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(begin, cut_top, alpha_width, cut_bottom))); } delete[] opaque_row; } void CL_SpriteDescription::add_alphaclipped_frames_free( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos, int ypos, double trans_limit) { @@ -391,7 +428,7 @@ format.set_depth(32); format.enable_colorkey(false); - CL_PixelBuffer alpha_buffer = provider.to_format(format); + CL_PixelBuffer alpha_buffer = pixelbuffer.to_format(format); int width = alpha_buffer.get_width(); int height = alpha_buffer.get_height(); @@ -458,8 +495,8 @@ x1 = x1 - 1; } } - } // end scanning left&right - } // end while (more) + } + } // Mark all pixels in the bounding box as being explored for (int i = x1; i <= x2; i++) @@ -470,27 +507,27 @@ } } - impl->frames.push_back(PixelBufferFrame(provider, CL_Rect(x1, y1, x2, y2))); - } // end for (int x=xpos; x < width; x++) - } // end for (int y=ypos; y < height; y++) + impl->frames.push_back(CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(x1, y1, x2, y2))); + } + } delete[] explored; } void CL_SpriteDescription::add_paletteclipped_frames( - const CL_PixelBuffer &provider, + const CL_PixelBuffer &pixelbuffer, int xpos, int ypos) { - if (provider.get_format().get_depth() != 8) + if (pixelbuffer.get_format().get_depth() != 8) throw CL_Exception("add_paletteclipped_frames: Only supported on PAL8 (256 colours) images."); - unsigned char *surface_data = (unsigned char *) provider.get_data(); + unsigned char *surface_data = (unsigned char *) pixelbuffer.get_data(); // Find height int height; - for (height = ypos; height < provider.get_height(); height++) + for (height = ypos; height < pixelbuffer.get_height(); height++) { - if (surface_data[height * provider.get_pitch() + xpos] == 255) + if (surface_data[height * pixelbuffer.get_pitch() + xpos] == 255) { height -= ypos; break; @@ -505,18 +542,18 @@ { // Find width int width; - int provider_width = provider.get_width(); + int pixelbuffer_width = pixelbuffer.get_width(); found = false; - for (width = xpos; width < provider_width; width++) + for (width = xpos; width < pixelbuffer_width; width++) { - if (surface_data[ypos * provider.get_pitch() + width] == 254) + if (surface_data[ypos * pixelbuffer.get_pitch() + width] == 254) { found = true; width -= xpos; break; } - else if (surface_data[ypos * provider.get_pitch() + width] == 253) + else if (surface_data[ypos * pixelbuffer.get_pitch() + width] == 253) { found = true; width -= xpos; @@ -528,7 +565,7 @@ // Cut frame if found if(found) { - impl->frames.push_back(PixelBufferFrame(provider, CL_Rect(xpos, ypos, xpos + width, ypos + height))); + impl->frames.push_back(CL_SpriteDescriptionFrame(pixelbuffer, CL_Rect(xpos, ypos, xpos + width, ypos + height))); xpos += width + 1; Modified: Development/ClanLib-0.9/Sources/Display/sprite_description_impl.h =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_description_impl.h 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/Display/sprite_description_impl.h 2006-09-17 20:38:03 UTC (rev 1063) @@ -44,7 +44,7 @@ //! Attributes: public: - std::list<CL_SpriteDescription::PixelBufferFrame> frames; + std::list<CL_SpriteDescriptionFrame> frames; }; #endif Modified: Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/Display/sprite_impl.cpp 2006-09-17 20:38:03 UTC (rev 1063) @@ -140,32 +140,56 @@ void CL_Sprite_Impl::create_textures(const CL_SpriteDescription &description) { // Fetch frames - const std::list<CL_SpriteDescription::PixelBufferFrame> &description_frames = description.get_frames(); - std::list<CL_SpriteDescription::PixelBufferFrame>::const_iterator it_frames; + const std::list<CL_SpriteDescriptionFrame> &description_frames = description.get_frames(); + std::list<CL_SpriteDescriptionFrame>::const_iterator it_frames; for (it_frames = description_frames.begin(); it_frames != description_frames.end(); ++it_frames) { - CL_PixelBuffer image = (*it_frames).first; - CL_Rect rect = (*it_frames).second; + CL_SpriteDescriptionFrame description_frame = (*it_frames); - int width = rect.get_width(); - int height = rect.get_height(); + if(description_frame.type == CL_SpriteDescriptionFrame::type_pixelbuffer) + { + CL_PixelBuffer image = description_frame.pixelbuffer; + CL_Rect rect = description_frame.rect; - int texture_width = 1; - int texture_height = 1; - while (texture_width < width) texture_width *= 2; - while (texture_height < height) texture_height *= 2; +/* int width = rect.get_width(); + int height = rect.get_height(); + + int texture_width = 1; + int texture_height = 1; + while (texture_width < width) texture_width *= 2; + while (texture_height < height) texture_height *= 2; +*/ + int texture_width = 1; + int texture_height = 1; + while (texture_width < image.get_width()) texture_width *= 2; + while (texture_height < image.get_height()) texture_height *= 2; - CL_Texture texture(texture_width, texture_height, 1, 0, gc); - texture.set_image(image); + CL_Texture texture(texture_width, texture_height, 1, 0, gc); + texture.set_image(image); - SpriteFrame frame; - frame.position = rect; - frame.texture = texture; - frame.delay = 0.1f; - frame.offset = CL_Point(0, 0); + SpriteFrame frame; + frame.position = rect; + // frame.position = CL_Rect(0, 0, width, height); + frame.texture = texture; + frame.delay = 0.1f; + frame.offset = CL_Point(0, 0); - frames.push_back(frame); + frames.push_back(frame); + } + else if(description_frame.type == CL_SpriteDescriptionFrame::type_texture) + { + int width = description_frame.rect.get_width(); + int height = description_frame.rect.get_height(); + + SpriteFrame frame; + frame.position = description_frame.rect; + frame.texture = description_frame.texture; + frame.delay = 0.1f; + frame.offset = CL_Point(0, 0); + + frames.push_back(frame); + } } /* if (pack_texture && CL_DisplayTarget::current()->enable_packer()) Modified: Development/ClanLib-0.9/Sources/Display/texture.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-13 19:43:52 UTC (rev 1062) +++ Development/ClanLib-0.9/Sources/Display/texture.cpp 2006-09-17 20:38:03 UTC (rev 1063) @@ -130,22 +130,22 @@ return impl.is_null(); } -int CL_Texture::get_width(int level) +int CL_Texture::get_width(int level) const { return impl->width; } -int CL_Texture::get_height(int level) +int CL_Texture::get_height(int level) const { return impl->height; } -int CL_Texture::get_depth() +int CL_Texture::get_depth() const { return impl->depth; } -int CL_Texture::get_border() +int CL_Texture::get_border() const { return impl->border; } @@ -153,7 +153,7 @@ CL_PixelBuffer CL_Texture::get_pixeldata(int level) { // todo: pixel format rgba8888? - return impl->provider->get_pixeldata( CL_PixelFormat::rgba8888, level); + return impl->provider->get_pixeldata(CL_PixelFormat::rgba8888, level); } CL_PixelBuffer CL_Texture::get_pixeldata(CL_PixelFormat &format, int level) |
From: Changes to t. C. r. <cla...@li...> - 2006-09-14 12:00:49
|
Dear Webmaster, My name is Oscar and I have just gone through your site, and visited many pages. It would be better if we link to each other as reciprocal link place an important role in a search engine ranking algorithm. I have already placed a link to your site on the following webpage:- http://www.eleapsoftware.com/resources/web-based-training-tools.html Your link details are here:- <a href="http://www.clanlib.org/" target="_blank"class="l2">ClanLib </a> - A multi-platform game development library. Currently is works on Linux and Win32. I humbly request you to link back to us with the following details: Title: Learning Management System Description: We are leading provider of learning content management (LMS/ LCMS) system and on demand e-learning software support. URL: http://www.eleapsoftware.com/ Or Below is Our Link Code: <a href="http://www.eleapsoftware.com/" target="_blank">Learning Management System </a> - We are leading provider of learning content management (LMS/ LCMS) system and on demand e-learning software support. If you wish to have your details changed, we would be interested in modification as per you requirements. Please note that the link to your site will be active for 10 business days. Once you add our link, your link details will be permanent on our site. Thanks -- Best regards, Oscar Link Manager eBrandz.com, Search Engine Marketing Company Email:- osc...@ho... Visit us at http://www.ebrandz.com _________________________________________________________________ One and only Ash. Find out all about her. Only on MSN Search http://server1.msn.co.in/profile/aishwarya.asp |
From: Changes to t. C. r. <cla...@li...> - 2006-09-13 19:43:16
|
Author: mbn Date: 2006-09-13 21:43:52 +0200 (Wed, 13 Sep 2006) New Revision: 1062 Modified: Development/ClanLib-0.9/Sources/API/Core/System/datetime.h Development/ClanLib-0.9/Sources/Core/CSS/css_document_impl.cpp Development/ClanLib-0.9/Sources/Core/IOData/directory.cpp Development/ClanLib-0.9/Sources/Core/System/Win32/init_win32.cpp Development/ClanLib-0.9/Sources/Core/System/console_window_generic.cpp Development/ClanLib-0.9/Sources/Core/System/datetime.cpp Development/ClanLib-0.9/Sources/Core/Text/string_help.cpp Development/ClanLib-0.9/Sources/Display/ImageProviders/jpeg_provider.cpp Development/ClanLib-0.9/Sources/Display/ImageProviders/png_provider.cpp Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp Development/ClanLib-0.9/Sources/GUI/gui_manager_impl.cpp Log: - Got rid of various MSVC80 warnings. Modified: Development/ClanLib-0.9/Sources/API/Core/System/datetime.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Core/System/datetime.h 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/API/Core/System/datetime.h 2006-09-13 19:43:52 UTC (rev 1062) @@ -170,8 +170,10 @@ mutable struct tm *tm_utc; #ifdef WIN32 +#ifndef _CRT_INSECURE_DEPRECATE static CL_Mutex mutex; #endif +#endif }; #endif Modified: Development/ClanLib-0.9/Sources/Core/CSS/css_document_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/CSS/css_document_impl.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/CSS/css_document_impl.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -214,7 +214,7 @@ if (pos+keyword_len > length) throw CL_Exception(cl_format("Expected %1 at position %2", keyword, pos)); CL_String8 s((char *) data+pos, keyword_len); - if (stricmp(keyword, s.c_str()) != 0) + if (CL_StringHelp::compare(keyword, s, true) == false) throw CL_Exception(cl_format("Expected %1 at position %2", keyword, pos)); return pos + keyword_len; } Modified: Development/ClanLib-0.9/Sources/Core/IOData/directory.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/IOData/directory.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/IOData/directory.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -199,13 +199,22 @@ bool CL_Directory::set_current(const CL_String &dir_name) { +#ifdef WIN32 + return SetCurrentDirectory(dir_name.c_str()) == TRUE; +#else return chdir(dir_name.c_str()) == 0; +#endif } CL_String CL_Directory::get_current() { char cwd_buffer[MAX_PATH]; +#ifdef _CRT_INSECURE_DEPRECATE + if (_getcwd(cwd_buffer, MAX_PATH) == NULL) + throw CL_Exception(cl_text("Working dir is more than legal length !")); +#else if (getcwd(cwd_buffer, MAX_PATH) == NULL) throw CL_Exception(cl_text("Working dir is more than legal length !")); +#endif return cwd_buffer; } Modified: Development/ClanLib-0.9/Sources/Core/System/Win32/init_win32.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/System/Win32/init_win32.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/System/Win32/init_win32.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -139,7 +139,11 @@ TCHAR szFilename[256]; TCHAR szExt[256]; GetModuleFileName(0, szDllName, _MAX_PATH); +#ifdef _CRT_INSECURE_DEPRECATE + _splitpath_s(szDllName, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, 256, szExt, 256); +#else _splitpath(szDllName, szDrive, szDir, szFilename, szExt); +#endif return CL_String(szDrive) + CL_String(szDir); } Modified: Development/ClanLib-0.9/Sources/Core/System/console_window_generic.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/System/console_window_generic.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/System/console_window_generic.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -91,17 +91,29 @@ SetStdHandle(STD_OUTPUT_HANDLE, scrbuf); SetStdHandle(STD_ERROR_HANDLE, scrbuf); SetStdHandle(STD_INPUT_HANDLE, scrbuf); + +#ifdef _CRT_INSECURE_DEPRECATE + freopen_s(&fstdin, "CONIN$", "rt", stdin); + freopen_s(&fstderr, "CONOUT$", "wt", stderr); + freopen_s(&fstdout, "CONOUT$", "wt", stdout); +#else fstdin = freopen("CONIN$","rt",stdin); fstderr = freopen("CONOUT$", "wt", stderr); fstdout = freopen("CONOUT$", "wt", stdout); #endif +#endif } void CL_ConsoleWindow_Generic::redirect_stdio(const CL_StringRef &file) { close_file_handles(); +#ifdef _CRT_INSECURE_DEPRECATE + freopen_s(&fstdout, file.c_str(), "wt", stdout); + freopen_s(&fstderr, file.c_str(), "wt", stderr); +#else fstdout = freopen(file.c_str(), "wt", stdout); fstderr = freopen(file.c_str(), "wt", stderr); +#endif } void CL_ConsoleWindow_Generic::wait_for_key() @@ -109,12 +121,16 @@ #ifdef WIN32 // If your application crashes here, you are linking with a single threaded // libc in your application! -- mbn 13. Jan 2001. - #ifdef __BORLANDC__ - std::string foo; - cin >> foo; - #else - while (!kbhit()) Sleep(250); - #endif + #ifdef __BORLANDC__ + std::string foo; + cin >> foo; + #else + #ifdef _CRT_INSECURE_DEPRECATE + while (!_kbhit()) Sleep(250); + #else + while (!kbhit()) Sleep(250); + #endif + #endif #endif } Modified: Development/ClanLib-0.9/Sources/Core/System/datetime.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/System/datetime.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/System/datetime.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -286,8 +286,10 @@ // CL_DateTime Implementation: #ifdef WIN32 +#ifndef _CRT_INSECURE_DEPRECATE CL_Mutex CL_DateTime::mutex; #endif +#endif void CL_DateTime::load_local() const { @@ -295,6 +297,17 @@ return; #ifdef WIN32 +#ifdef _CRT_INSECURE_DEPRECATE + tm_local = new tm; + memset(tm_local, 0, sizeof(tm)); + errno_t result = localtime_s(tm_local, &unix_time); + if (result != 0) + { + delete tm_local; + tm_local = 0; + throw CL_Exception(cl_text("localtime_s failed")); + } +#else CL_MutexSection mutexLock(&mutex); tm_local = new tm; memset(tm_local, 0, sizeof(tm)); @@ -309,6 +322,7 @@ { memcpy(tm_local, result, sizeof(tm)); } +#endif #else tm_local = new tm; memset(tm_local, 0, sizeof(tm)); @@ -328,6 +342,17 @@ return; #ifdef WIN32 +#ifdef _CRT_INSECURE_DEPRECATE + tm_utc = new tm; + memset(tm_utc, 0, sizeof(tm)); + errno_t result = gmtime_s(tm_utc, &unix_time); + if (result != 0) + { + delete tm_utc; + tm_utc = 0; + throw CL_Exception(cl_text("gmtime_s failed")); + } +#else CL_MutexSection mutexLock(&mutex); tm_utc = new tm; memset(tm_utc, 0, sizeof(tm)); @@ -342,6 +367,7 @@ { memcpy(tm_utc, result, sizeof(tm)); } +#endif #else tm_utc = new tm; memset(tm_utc, 0, sizeof(tm)); @@ -354,4 +380,3 @@ } #endif } - Modified: Development/ClanLib-0.9/Sources/Core/Text/string_help.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Core/Text/string_help.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Core/Text/string_help.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -38,6 +38,13 @@ #include <tchar.h> #endif +// This function or variable may be unsafe. Consider using xxxx instead. +// To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details. +#pragma warning(disable: 4996) +// We disable this warning because the usage patterns we use here are safe, +// and although we could switch to newer more 'safe' versions, this may break +// compilation in earlier versions of Visual Studio. -- mbn 13. sep 2006 + ///////////////////////////////////////////////////////////////////////////// // CL_StringHelp Operations: Modified: Development/ClanLib-0.9/Sources/Display/ImageProviders/jpeg_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/ImageProviders/jpeg_provider.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Display/ImageProviders/jpeg_provider.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -84,9 +84,17 @@ * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that * requires it in order to write binary files. */ - if ((outfile = fopen(filename.c_str(), "wb")) == NULL) { + +#ifdef _CRT_INSECURE_DEPRECATE + errno_t result = fopen_s(&outfile, filename.c_str(), "wb"); + if (result == 0) throw CL_Exception("can't open " + filename); +#else + if ((outfile = fopen(filename.c_str(), "wb")) == NULL) + { + throw CL_Exception("can't open " + filename); } +#endif jpeg_stdio_dest(&cinfo, outfile); /* Step 3: set parameters for compression */ Modified: Development/ClanLib-0.9/Sources/Display/ImageProviders/png_provider.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/ImageProviders/png_provider.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/Display/ImageProviders/png_provider.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -61,10 +61,20 @@ buffer = newbuf; } - FILE* fp; - fp = fopen(filename.c_str (), "wb"); + FILE *fp = 0; +#ifdef _CRT_INSECURE_DEPRECATE + errno_t result = fopen_s(&fp, filename.c_str(), "wb"); + if (result == 0) + { + char buffer[128]; + strerror_s(buffer, 128, result); + throw CL_Exception(buffer); + } +#else + fp = fopen(filename.c_str(), "wb"); if (fp == NULL) throw CL_Exception(strerror(errno)); +#endif png_structp png_ptr; png_infop info_ptr; Modified: Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/GUI/Components/lineedit.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -260,7 +260,7 @@ CL_GUIMessage_Input input_msg = msg; CL_InputEvent e = input_msg.get_event(); - if (e.device.get_type() == CL_InputDevice::Type::keyboard) + if (e.device.get_type() == CL_InputDevice::keyboard) { if (e.type == CL_InputEvent::pressed || e.repeat_count > 1) { @@ -287,7 +287,7 @@ } } } - else if (e.device.get_type() == CL_InputDevice::Type::mouse) + else if (e.device.get_type() == CL_InputDevice::mouse) { if (e.type == CL_InputEvent::released && e.id == CL_MOUSE_LEFT) { Modified: Development/ClanLib-0.9/Sources/GUI/gui_manager_impl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GUI/gui_manager_impl.cpp 2006-09-13 18:56:56 UTC (rev 1061) +++ Development/ClanLib-0.9/Sources/GUI/gui_manager_impl.cpp 2006-09-13 19:43:52 UTC (rev 1062) @@ -176,7 +176,7 @@ CL_InputEvent::Type type = im.get_event().type; if (type == CL_InputEvent::pressed || type == CL_InputEvent::released) { - if (im.get_event().device.get_type() == CL_InputDevice::Type::keyboard) + if (im.get_event().device.get_type() == CL_InputDevice::keyboard) { m.set_target(get_focus_component()); } |
From: Changes to t. C. r. <cla...@li...> - 2006-09-13 18:56:25
|
Author: mbn Date: 2006-09-13 20:56:56 +0200 (Wed, 13 Sep 2006) New Revision: 1061 Modified: Development/ClanLib-0.9/Setup/Generic/project.cpp Development/ClanLib-0.9/Setup/Win32/precomp.h Log: - Added vc80 warning pragmas to configure program. Modified: Development/ClanLib-0.9/Setup/Generic/project.cpp =================================================================== --- Development/ClanLib-0.9/Setup/Generic/project.cpp 2006-09-12 19:40:42 UTC (rev 1060) +++ Development/ClanLib-0.9/Setup/Generic/project.cpp 2006-09-13 18:56:56 UTC (rev 1061) @@ -31,6 +31,11 @@ #include <windows.h> #endif +#if defined(_MSC_VER) +// deprecated API and security warnings (configure has to be backwards compatible to older msvcs) +#pragma warning(disable: 4996) +#endif + #include "project.h" ///////////////////////////////////////////////////////////////////////////// Modified: Development/ClanLib-0.9/Setup/Win32/precomp.h =================================================================== --- Development/ClanLib-0.9/Setup/Win32/precomp.h 2006-09-12 19:40:42 UTC (rev 1060) +++ Development/ClanLib-0.9/Setup/Win32/precomp.h 2006-09-13 18:56:56 UTC (rev 1061) @@ -43,6 +43,9 @@ // disable debug info truncation warnings caused by STL #if defined(_MSC_VER) #pragma warning(disable: 4786) + +// deprecated API and security warnings (configure has to be backwards compatible to older msvcs) +#pragma warning(disable: 4996) #endif #endif |
From: Changes to t. C. r. <cla...@li...> - 2006-09-12 19:40:11
|
Author: mbn Date: 2006-09-12 21:40:42 +0200 (Tue, 12 Sep 2006) New Revision: 1060 Modified: Development/ClanLib-0.9/Sources/API/Display/display_window_description.h Development/ClanLib-0.9/Sources/Display/display_window_description.cpp Development/ClanLib-0.9/Sources/Display/display_window_description_impl.h Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.h Log: - Added window creation from a HWND. Modified: Development/ClanLib-0.9/Sources/API/Display/display_window_description.h =================================================================== --- Development/ClanLib-0.9/Sources/API/Display/display_window_description.h 2006-09-03 17:34:05 UTC (rev 1059) +++ Development/ClanLib-0.9/Sources/API/Display/display_window_description.h 2006-09-12 19:40:42 UTC (rev 1060) @@ -90,6 +90,9 @@ #ifdef WIN32 //: Windows 2000/XP only. Returns true if window is layered. bool is_layered() const; + + //: Windows only. Returns the window handle to be used for the window. + HWND get_handle() const; #endif //: Returns true if a title bar is shown. @@ -132,6 +135,9 @@ #ifdef WIN32 //: Windows 2000/XP only. Creates a layered window (complex shaped window). void set_layered(bool layered); + + //: Windows only. Use an existing window handle for the window. + void set_handle(HWND handle); #endif //! Implementation: Modified: Development/ClanLib-0.9/Sources/Display/display_window_description.cpp =================================================================== --- Development/ClanLib-0.9/Sources/Display/display_window_description.cpp 2006-09-03 17:34:05 UTC (rev 1059) +++ Development/ClanLib-0.9/Sources/Display/display_window_description.cpp 2006-09-12 19:40:42 UTC (rev 1060) @@ -83,6 +83,11 @@ { return impl->layered; } + +HWND CL_DisplayWindowDescription::get_handle() const +{ + return impl->handle; +} #endif int CL_DisplayWindowDescription::get_bpp() const @@ -159,6 +164,11 @@ { impl->layered = layered; } + +void CL_DisplayWindowDescription::set_handle(HWND handle) +{ + impl->handle = handle; +} #endif ///////////////////////////////////////////////////////////////////////////// Modified: Development/ClanLib-0.9/Sources/Display/display_window_description_impl.h =================================================================== --- Development/ClanLib-0.9/Sources/Display/display_window_description_impl.h 2006-09-03 17:34:05 UTC (rev 1059) +++ Development/ClanLib-0.9/Sources/Display/display_window_description_impl.h 2006-09-12 19:40:42 UTC (rev 1060) @@ -52,6 +52,7 @@ bpp = 0; #ifdef WIN32 layered = false; + handle = 0; #endif } @@ -77,6 +78,8 @@ #ifdef WIN32 bool layered; + + HWND handle; #endif }; Modified: Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp =================================================================== --- Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp 2006-09-03 17:34:05 UTC (rev 1059) +++ Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.cpp 2006-09-12 19:40:42 UTC (rev 1060) @@ -76,7 +76,7 @@ // CL_OpenGLWindowProvider_WGL Construction: CL_OpenGLWindowProvider_WGL::CL_OpenGLWindowProvider_WGL() -: hwnd(0), fullscreen(false), allow_resize(false), layered(false), bpp(0), +: hwnd(0), destroy_hwnd(true), fullscreen(false), allow_resize(false), layered(false), bpp(0), saved_position(0, 0, 0, 0), mouse_pos(-1,-1), directinput(0), opengl_context(0), device_context(0), layered_dc(0), layered_bitmap(0), layered_orig_bitmap(0), user32_dll(0), ptr_UpdateLayeredWindow(0), keyboard(0), mouse(0), tablet(0), site(0) @@ -153,7 +153,10 @@ fullscreen = false; layered = false; ic.clear(); - DestroyWindow(hwnd); + if (destroy_hwnd) + DestroyWindow(hwnd); + else + SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR) old_wndproc); hwnd = 0; } @@ -429,105 +432,116 @@ layered_position = desc.get_position(); allow_resize = desc.get_allow_resize(); - WNDCLASS wndclass; - memset(&wndclass, 0, sizeof(WNDCLASS)); - wndclass.style = CS_DBLCLKS; - wndclass.lpfnWndProc = (WNDPROC) CL_OpenGLWindowProvider_WGL::message_handler; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = (HINSTANCE) GetModuleHandle(0); - wndclass.hIcon = NULL; - wndclass.hCursor = LoadCursor (NULL,IDC_ARROW); - wndclass.hbrBackground = 0; - wndclass.lpszMenuName = TEXT("ClanApplication"); - wndclass.lpszClassName = TEXT("ClanApplication"); - RegisterClass(&wndclass); - - int x = 0; - int y = 0; - int width = desc.get_size().width; - int height = desc.get_size().height; - - if (desc.is_fullscreen()) + if (desc.get_handle()) { - width = GetSystemMetrics(SM_CXSCREEN); - height = GetSystemMetrics(SM_CYSCREEN); + hwnd = desc.get_handle(); + destroy_hwnd = false; + window_map[hwnd] = this; // register window in "hwnd to window" hash table + old_wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWL_WNDPROC); + SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR) CL_OpenGLWindowProvider_WGL::message_handler); } else { - int scr_width = GetSystemMetrics(SM_CXSCREEN); - int scr_height = GetSystemMetrics(SM_CYSCREEN); + WNDCLASS wndclass; + memset(&wndclass, 0, sizeof(WNDCLASS)); + wndclass.style = CS_DBLCLKS; + wndclass.lpfnWndProc = (WNDPROC) CL_OpenGLWindowProvider_WGL::message_handler; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = (HINSTANCE) GetModuleHandle(0); + wndclass.hIcon = NULL; + wndclass.hCursor = LoadCursor (NULL,IDC_ARROW); + wndclass.hbrBackground = 0; + wndclass.lpszMenuName = TEXT("ClanApplication"); + wndclass.lpszClassName = TEXT("ClanApplication"); + RegisterClass(&wndclass); - x = scr_width/2 - width/2; - y = scr_height/2 - height/2; - } + int x = 0; + int y = 0; + int width = desc.get_size().width; + int height = desc.get_size().height; - if (width == 0 && height == 0) - { - x = saved_position.left; - y = saved_position.top; - width = saved_position.get_width(); - height = saved_position.get_height(); - clientSize = false; - } + if (desc.is_fullscreen()) + { + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + } + else + { + int scr_width = GetSystemMetrics(SM_CXSCREEN); + int scr_height = GetSystemMetrics(SM_CYSCREEN); - int style; - if (desc.is_fullscreen()) - { - style = WS_POPUP; - } - else if (allow_resize) - { - style = WS_POPUP | WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; - if (desc.has_caption()) - style |= WS_CAPTION; - } - else - { - style = WS_POPUPWINDOW | WS_MINIMIZEBOX; - if (desc.has_caption()) - style |= WS_CAPTION; - } + x = scr_width/2 - width/2; + y = scr_height/2 - height/2; + } - int ex_style = 0; - if (desc.is_layered()) - { - ex_style = WS_EX_LAYERED; - } + if (width == 0 && height == 0) + { + x = saved_position.left; + y = saved_position.top; + width = saved_position.get_width(); + height = saved_position.get_height(); + clientSize = false; + } - // get size of window with decorations to pass to CreateWindow - RECT window_rect = { x, y, x+width, y+height }; - if (clientSize) - AdjustWindowRectEx( &window_rect, style, FALSE, ex_style ); + int style; + if (desc.is_fullscreen()) + { + style = WS_POPUP; + } + else if (allow_resize) + { + style = WS_POPUP | WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; + if (desc.has_caption()) + style |= WS_CAPTION; + } + else + { + style = WS_POPUPWINDOW | WS_MINIMIZEBOX; + if (desc.has_caption()) + style |= WS_CAPTION; + } - hwnd = CreateWindowEx( - ex_style, - TEXT("ClanApplication"), - title.c_str(), - style, - window_rect.left, - window_rect.top, - window_rect.right - window_rect.left, - window_rect.bottom - window_rect.top, - NULL, - NULL, - (HINSTANCE) GetModuleHandle(0), - NULL); + int ex_style = 0; + if (desc.is_layered()) + { + ex_style = WS_EX_LAYERED; + } - if (hwnd == 0) - throw CL_Exception("Unable to create window"); + // get size of window with decorations to pass to CreateWindow + RECT window_rect = { x, y, x+width, y+height }; + if (clientSize) + AdjustWindowRectEx( &window_rect, style, FALSE, ex_style ); - window_map[hwnd] = this; // register window in "hwnd to window" hash table + hwnd = CreateWindowEx( + ex_style, + TEXT("ClanApplication"), + title.c_str(), + style, + window_rect.left, + window_rect.top, + window_rect.right - window_rect.left, + window_rect.bottom - window_rect.top, + NULL, + NULL, + (HINSTANCE) GetModuleHandle(0), + NULL); - if (desc.is_fullscreen()) - { - // Make always on top - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, width, height, 0); + if (hwnd == 0) + throw CL_Exception("Unable to create window"); + + window_map[hwnd] = this; // register window in "hwnd to window" hash table + + if (desc.is_fullscreen()) + { + // Make always on top + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, width, height, 0); + } + + ShowWindow(hwnd, SW_SHOW); + UpdateWindow(hwnd); } - ShowWindow(hwnd, SW_SHOW); - UpdateWindow(hwnd); - // Connect input context to new window: ic.clear(); Modified: Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.h =================================================================== --- Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.h 2006-09-03 17:34:05 UTC (rev 1059) +++ Development/ClanLib-0.9/Sources/GL/WGL/opengl_window_provider_wgl.h 2006-09-12 19:40:42 UTC (rev 1060) @@ -147,6 +147,10 @@ //: Window handle. HWND hwnd; + bool destroy_hwnd; + + WNDPROC old_wndproc; + CL_String title; bool fullscreen; |