forked from KolibriOS/kolibrios
switch build system to Tup
git-svn-id: svn://kolibrios.org@5098 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
205
programs/develop/libraries/TinyGL/BeOS/GLView.cpp
Normal file
205
programs/develop/libraries/TinyGL/BeOS/GLView.cpp
Normal file
@@ -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);
|
||||
}
|
||||
*/
|
72
programs/develop/libraries/TinyGL/BeOS/GLView.h
Normal file
72
programs/develop/libraries/TinyGL/BeOS/GLView.h
Normal file
@@ -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_
|
16
programs/develop/libraries/TinyGL/BeOS/Makefile
Normal file
16
programs/develop/libraries/TinyGL/BeOS/Makefile
Normal file
@@ -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
|
Reference in New Issue
Block a user