diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-08-20 01:36:33 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-08-20 01:36:33 +1000 |
commit | 3b21507274aa4f98644382903ae529c1fc2c7bd4 (patch) | |
tree | bd977e47129c44adb20f0f72c891fa960c827d73 /3rdparty/tinygl-0.4-ugfx/BeOS | |
parent | 301f134b9034170e6e26aa307e5ede741db1cf70 (diff) | |
download | uGFX-3b21507274aa4f98644382903ae529c1fc2c7bd4.tar.gz uGFX-3b21507274aa4f98644382903ae529c1fc2c7bd4.tar.bz2 uGFX-3b21507274aa4f98644382903ae529c1fc2c7bd4.zip |
GL3D GWIN window + demo
Diffstat (limited to '3rdparty/tinygl-0.4-ugfx/BeOS')
-rw-r--r-- | 3rdparty/tinygl-0.4-ugfx/BeOS/GLView.cpp | 205 | ||||
-rw-r--r-- | 3rdparty/tinygl-0.4-ugfx/BeOS/GLView.h | 72 | ||||
-rw-r--r-- | 3rdparty/tinygl-0.4-ugfx/BeOS/Makefile | 16 |
3 files changed, 293 insertions, 0 deletions
diff --git a/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.cpp b/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.cpp new file mode 100644 index 00000000..778107e6 --- /dev/null +++ b/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.cpp @@ -0,0 +1,205 @@ +#include "GLView.h" +#include <stdio.h> +#include <interface/Bitmap.h> + +BLocker BGLView::locker; + +BGLView::BGLView(BRect rect, char *name, + ulong resizingMode, ulong mode, + ulong options) + : BView(rect, name, resizingMode, mode|B_FRAME_EVENTS|B_WILL_DRAW) +{ +#ifdef __INTEL__ + color_space cs = B_RGB16_LITTLE; +#else + color_space cs = B_RGB16_BIG; +#endif + this->bitmaps[0] = new BBitmap(rect, cs, false, true); + this->bitmaps[1] = new BBitmap(rect, cs, false, true); + + this->currBitmap = 0; + int w = this->bitmaps[0]->BytesPerRow() / 2; + int h = rect.Height() + 1; + void *buffers[2]; + buffers[0] = this->bitmaps[0]->Bits(); + buffers[1] = this->bitmaps[1]->Bits(); + this->context = ostgl_create_context(w, h, 16, buffers, 2); + ostgl_make_current(this->context, 0); +} + +BGLView::~BGLView() +{ + ostgl_delete_context(this->context); + delete this->bitmaps[0]; + delete this->bitmaps[1]; +} + +void +BGLView::LockGL() +{ + BGLView::locker.Lock(); + ostgl_make_current(this->context, this->currBitmap); +} + +void +BGLView::UnlockGL() +{ + BGLView::locker.Unlock(); +} + +void +BGLView::SwapBuffers() +{ + if (Window()->Lock()) { + DrawBitmap(this->bitmaps[this->currBitmap]); + Window()->Unlock(); + this->currBitmap ^= 1; + } +} + +/* +BView * +BGLView::EmbeddedView() +{ + return NULL; +} + +status_t +BGLView::CopyPixelsOut(BPoint source, BBitmap *dest) +{ + assert(0); + return 0; +} + +status_t +BGLView::CopyPixelsIn(BBitmap *source, BPoint dest) +{ + assert(0); + return 0; +} +*/ + +void +BGLView::ErrorCallback(GLenum /*errorCode*/) +{ +} + +void +BGLView::Draw(BRect rect) +{ + //fprintf(stderr, "GLView::Draw()"); + DrawBitmap(this->bitmaps[this->currBitmap^1], rect, rect); +} + +void +BGLView::AttachedToWindow() +{ +} + +void +BGLView::AllAttached() +{ +} + +void +BGLView::DetachedFromWindow() +{ +} + +void +BGLView::AllDetached() +{ +} + +void +BGLView::FrameResized(float w, float h) +{ + delete this->bitmaps[0]; + delete this->bitmaps[1]; +#ifdef __INTEL__ + color_space cs = B_RGB16_LITTLE; +#else + color_space cs = B_RGB16_BIG; +#endif + this->bitmaps[0] = new BBitmap(BRect(0,0, w-1, h-1), + cs, false, true); + this->bitmaps[1] = new BBitmap(BRect(0,0, w-1, h-1), + cs, false, true); + int w2 = this->bitmaps[0]->BytesPerRow() / 2; + void *buffers[2]; + buffers[0] = this->bitmaps[0]->Bits(); + buffers[1] = this->bitmaps[1]->Bits(); + ostgl_resize(this->context, w2, h, buffers); +} + +/* +status_t +BGLView::Perform(perform_code d, void *arg) +{ + +} +*/ + +// +// the rest are pass-through functions +// + +status_t +BGLView::Archive(BMessage *data, bool deep) const +{ + return BView::Archive(data, deep); +} + +void +BGLView::MessageReceived(BMessage *msg) +{ + BView::MessageReceived(msg); +} + +void +BGLView::SetResizingMode(uint32 mode) +{ + BView::SetResizingMode(mode); +} + +void +BGLView::Show() +{ + BView::Show(); +} + +void +BGLView::Hide() +{ + BView::Hide(); +} + +BHandler * +BGLView::ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property) +{ + return BView::ResolveSpecifier(msg, index, specifier, form, property); +} + +status_t +BGLView::GetSupportedSuites(BMessage *data) +{ + return BView::GetSupportedSuites(data); +} + +/* +void +BGLView::DirectConnected( direct_buffer_info *info ) +{ + BView::DirectConnected(info); +} +*/ + +/* +void +BGLView::EnableDirectMode( bool enabled ) +{ + BView::EnableDirectMode(enabled); +} +*/ diff --git a/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.h b/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.h new file mode 100644 index 00000000..6791e5aa --- /dev/null +++ b/3rdparty/tinygl-0.4-ugfx/BeOS/GLView.h @@ -0,0 +1,72 @@ +#ifndef _glview_h_ +#define _glview_h_ + +#define BGL_RGB 0 +#define BGL_INDEX 1 +#define BGL_SINGLE 0 +#define BGL_DOUBLE 2 +#define BGL_DIRECT 0 +#define BGL_INDIRECT 4 +#define BGL_ACCUM 8 +#define BGL_ALPHA 16 +#define BGL_DEPTH 32 +#define BGL_OVERLAY 64 +#define BGL_UNDERLAY 128 +#define BGL_STENCIL 512 + +#include <interface/View.h> +#include <support/Locker.h> +#include <GL/gl.h> +#include <GL/oscontext.h> +#include <game/WindowScreen.h> +#include <game/DirectWindow.h> + +class BGLView : public BView { +public: + BGLView(BRect rect, char *name, + ulong resizingMode, ulong mode, + ulong options); + virtual ~BGLView(); + + void LockGL(); + void UnlockGL(); + void SwapBuffers(); +// BView *EmbeddedView(); +// status_t CopyPixelsOut(BPoint source, BBitmap *dest); +// status_t CopyPixelsIn(BBitmap *source, BPoint dest); + + virtual void ErrorCallback(GLenum errorCode); + virtual void Draw(BRect updateRect); + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void DetachedFromWindow(); + virtual void AllDetached(); + virtual void FrameResized(float width, float height); +// virtual status_t Perform(perform_code d, void *arg); + + // + // Methods below are pass-throughs to BView for the moment. + // + + virtual status_t Archive(BMessage *data, bool deep = true) const; + virtual void MessageReceived(BMessage *msg); + virtual void SetResizingMode(uint32 mode); + + virtual void Show(); + virtual void Hide(); + + virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property); + virtual status_t GetSupportedSuites(BMessage *data); + //void DirectConnected( direct_buffer_info *info ); + //void EnableDirectMode( bool enabled ); + +private: + ostgl_context *context; + BBitmap *bitmaps[2]; + int currBitmap; + static BLocker locker; +}; + +#endif // _glview_h_ diff --git a/3rdparty/tinygl-0.4-ugfx/BeOS/Makefile b/3rdparty/tinygl-0.4-ugfx/BeOS/Makefile new file mode 100644 index 00000000..0113b3f6 --- /dev/null +++ b/3rdparty/tinygl-0.4-ugfx/BeOS/Makefile @@ -0,0 +1,16 @@ +OBJS=GLView.o +INCLUDES = -I../include +LIB = libGLView.a + +all: $(LIB) + +$(LIB): $(OBJS) + rm -f $(LIB) + ar rcs $(LIB) $(OBJS) + cp $(LIB) ../lib + +clean: + rm -f *~ *.o *.a + +GLView.o: GLView.cpp GLView.h + $(CC) $(CFLAGS) $(INCLUDES) -c GLView.cpp |