First small step toward OpenGL renderers interface.
Our libGL.so GLView is still a stub, drawing "No OpenGL renderer available!" instead ;-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17406 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
925479d7b3
commit
3f70d609a9
@ -79,23 +79,23 @@ extern "C" {
|
||||
|
||||
#include "GLDispatcher.h"
|
||||
|
||||
GLDispatcher::GLDispatcher()
|
||||
BGLDispatcher::BGLDispatcher()
|
||||
{
|
||||
}
|
||||
|
||||
GLDispatcher::~GLDispatcher()
|
||||
BGLDispatcher::~BGLDispatcher()
|
||||
{
|
||||
}
|
||||
|
||||
status_t
|
||||
GLDispatcher::CheckTable(const struct _glapi_table *table)
|
||||
BGLDispatcher::CheckTable(const struct _glapi_table *table)
|
||||
{
|
||||
_glapi_check_table(table ? table : _glapi_get_dispatch());
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
GLDispatcher::SetTable(struct _glapi_table *table)
|
||||
BGLDispatcher::SetTable(struct _glapi_table *table)
|
||||
{
|
||||
_glapi_set_dispatch(table);
|
||||
return B_OK;
|
||||
|
@ -9,15 +9,15 @@ extern "C" {
|
||||
#include "glapi.h"
|
||||
}
|
||||
|
||||
class GLDispatcher
|
||||
class BGLDispatcher
|
||||
{
|
||||
// Private unimplemented copy constructors
|
||||
GLDispatcher(const GLDispatcher &);
|
||||
GLDispatcher & operator=(const GLDispatcher &);
|
||||
BGLDispatcher(const BGLDispatcher &);
|
||||
BGLDispatcher & operator=(const BGLDispatcher &);
|
||||
|
||||
public:
|
||||
GLDispatcher();
|
||||
~GLDispatcher();
|
||||
BGLDispatcher();
|
||||
~BGLDispatcher();
|
||||
|
||||
const char * Version();
|
||||
|
||||
@ -36,49 +36,49 @@ class GLDispatcher
|
||||
};
|
||||
|
||||
// Inlines methods
|
||||
inline const char * GLDispatcher::Version()
|
||||
inline const char * BGLDispatcher::Version()
|
||||
{
|
||||
return _glapi_get_version();
|
||||
}
|
||||
|
||||
|
||||
inline void GLDispatcher::SetCurrentContext(void * context)
|
||||
inline void BGLDispatcher::SetCurrentContext(void * context)
|
||||
{
|
||||
_glapi_set_context(context);
|
||||
}
|
||||
|
||||
|
||||
inline void * GLDispatcher::CurrentContext()
|
||||
inline void * BGLDispatcher::CurrentContext()
|
||||
{
|
||||
return _glapi_get_context();
|
||||
}
|
||||
|
||||
|
||||
inline struct _glapi_table * GLDispatcher::Table()
|
||||
inline struct _glapi_table * BGLDispatcher::Table()
|
||||
{
|
||||
return _glapi_get_dispatch();
|
||||
}
|
||||
|
||||
|
||||
inline uint32 GLDispatcher::TableSize()
|
||||
inline uint32 BGLDispatcher::TableSize()
|
||||
{
|
||||
return _glapi_get_dispatch_table_size();
|
||||
}
|
||||
|
||||
|
||||
inline const _glapi_proc GLDispatcher::operator[](const char *function_name)
|
||||
inline const _glapi_proc BGLDispatcher::operator[](const char *function_name)
|
||||
{
|
||||
return _glapi_get_proc_address(function_name);
|
||||
}
|
||||
|
||||
|
||||
inline const char * GLDispatcher::operator[](uint32 offset)
|
||||
inline const char * BGLDispatcher::operator[](uint32 offset)
|
||||
{
|
||||
return _glapi_get_proc_name((GLuint) offset);
|
||||
}
|
||||
|
||||
|
||||
inline uint32 GLDispatcher::OffsetOf(const char *function_name)
|
||||
inline uint32 BGLDispatcher::OffsetOf(const char *function_name)
|
||||
{
|
||||
return (uint32) _glapi_get_proc_offset(function_name);
|
||||
}
|
||||
|
18
src/kits/opengl/GLRenderer.cpp
Normal file
18
src/kits/opengl/GLRenderer.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "GLRenderer.h"
|
||||
|
||||
void BGLRenderer::LockGL()
|
||||
{
|
||||
}
|
||||
|
||||
void BGLRenderer::UnlockGL()
|
||||
{
|
||||
}
|
||||
|
||||
void BGLRenderer::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
}
|
||||
|
||||
void BGLRenderer::EnableDirectMode(bool enabled)
|
||||
{
|
||||
}
|
||||
|
@ -2,161 +2,48 @@
|
||||
#define GLRENDERER_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <GLView.h>
|
||||
|
||||
class GLDispatcher;
|
||||
class BGLDispatcher;
|
||||
|
||||
class GLRenderer
|
||||
class BGLRenderer
|
||||
{
|
||||
|
||||
// Private unimplemented copy constructors
|
||||
GLRenderer(const GLRenderer &);
|
||||
GLRenderer & operator=(const GLRenderer &);
|
||||
BGLRenderer(const BGLRenderer &);
|
||||
BGLRenderer & operator=(const BGLRenderer &);
|
||||
|
||||
public:
|
||||
GLRenderer();
|
||||
~GLRenderer();
|
||||
BGLRenderer(BGLView *view, BGLDispatcher *dispatcher);
|
||||
virtual ~BGLRenderer();
|
||||
|
||||
void Init(BGLView * bglview, GLcontext * c, GLvisual * v, GLframebuffer * b);
|
||||
status_t Acquire();
|
||||
status_t Release();
|
||||
|
||||
void LockGL();
|
||||
void UnlockGL();
|
||||
void SwapBuffers(bool VSync = false) const;
|
||||
void Draw(BRect updateRect) const;
|
||||
void LockGL();
|
||||
void UnlockGL();
|
||||
|
||||
virtual void SwapBuffers(bool VSync = false) const;
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
||||
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
||||
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
void DirectConnected( direct_buffer_info *info );
|
||||
void EnableDirectMode( bool enabled );
|
||||
|
||||
private:
|
||||
MesaDriver(const MesaDriver &rhs); // copy constructor illegal
|
||||
MesaDriver &operator=(const MesaDriver &rhs); // assignment oper. illegal
|
||||
|
||||
GLcontext * m_glcontext;
|
||||
GLvisual * m_glvisual;
|
||||
GLframebuffer * m_glframebuffer;
|
||||
|
||||
BGLView * m_bglview;
|
||||
BBitmap * m_bitmap;
|
||||
|
||||
GLchan m_clear_color[4]; // buffer clear color
|
||||
GLuint m_clear_index; // buffer clear color index
|
||||
GLint m_bottom; // used for flipping Y coords
|
||||
GLuint m_width;
|
||||
GLuint m_height;
|
||||
|
||||
// Mesa Device Driver functions
|
||||
static void UpdateState(GLcontext *ctx, GLuint new_state);
|
||||
static void ClearIndex(GLcontext *ctx, GLuint index);
|
||||
static void ClearColor(GLcontext *ctx, const GLfloat color[4]);
|
||||
static void Clear(GLcontext *ctx, GLbitfield mask,
|
||||
GLboolean all, GLint x, GLint y,
|
||||
GLint width, GLint height);
|
||||
static void ClearFront(GLcontext *ctx, GLboolean all, GLint x, GLint y,
|
||||
GLint width, GLint height);
|
||||
static void ClearBack(GLcontext *ctx, GLboolean all, GLint x, GLint y,
|
||||
GLint width, GLint height);
|
||||
static void Index(GLcontext *ctx, GLuint index);
|
||||
static void Color(GLcontext *ctx, GLubyte r, GLubyte g,
|
||||
GLubyte b, GLubyte a);
|
||||
static void SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
|
||||
GLenum mode);
|
||||
static void GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
|
||||
GLuint *height);
|
||||
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
|
||||
|
||||
// Front-buffer functions
|
||||
static void WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
CONST GLubyte rgba[][4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBSpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
CONST GLubyte rgba[][3],
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBASpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLchan color[4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBAPixelsFront(const GLcontext *ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
CONST GLubyte rgba[][4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBAPixelsFront(const GLcontext *ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const GLchan color[4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteCI32SpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteCI8SpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLubyte index[], const GLubyte mask[]);
|
||||
static void WriteMonoCISpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLuint colorIndex, const GLubyte mask[]);
|
||||
static void WriteCI32PixelsFront(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteMonoCIPixelsFront(const GLcontext *ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
GLuint colorIndex, const GLubyte mask[]);
|
||||
static void ReadCI32SpanFront(const GLcontext *ctx,
|
||||
GLuint n, GLint x, GLint y, GLuint index[]);
|
||||
static void ReadRGBASpanFront(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLubyte rgba[][4]);
|
||||
static void ReadCI32PixelsFront(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLuint indx[], const GLubyte mask[]);
|
||||
static void ReadRGBAPixelsFront(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLubyte rgba[][4], const GLubyte mask[]);
|
||||
|
||||
// Back buffer functions
|
||||
static void WriteRGBASpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
CONST GLubyte rgba[][4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBSpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
CONST GLubyte rgba[][3],
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBASpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLchan color[4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBAPixelsBack(const GLcontext *ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
CONST GLubyte rgba[][4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBAPixelsBack(const GLcontext *ctx, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const GLchan color[4],
|
||||
const GLubyte mask[]);
|
||||
static void WriteCI32SpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteCI8SpanBack(const GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||
const GLubyte index[], const GLubyte mask[]);
|
||||
static void WriteMonoCISpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y, GLuint colorIndex,
|
||||
const GLubyte mask[]);
|
||||
static void WriteCI32PixelsBack(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteMonoCIPixelsBack(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLuint colorIndex, const GLubyte mask[]);
|
||||
static void ReadCI32SpanBack(const GLcontext *ctx,
|
||||
GLuint n, GLint x, GLint y, GLuint index[]);
|
||||
static void ReadRGBASpanBack(const GLcontext *ctx, GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLubyte rgba[][4]);
|
||||
static void ReadCI32PixelsBack(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLuint indx[], const GLubyte mask[]);
|
||||
static void ReadRGBAPixelsBack(const GLcontext *ctx,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLubyte rgba[][4], const GLubyte mask[]);
|
||||
|
||||
uint32 fRefCount;
|
||||
};
|
||||
|
||||
extern "C" _EXPORT GLRenderer * instanciate_gl_renderer(BGLView *view, GLDispatcher *dispatcher);
|
||||
extern "C" _EXPORT BGLRenderer * instanciate_gl_renderer(BGLView *view, BGLDispatcher *dispatcher);
|
||||
|
||||
|
||||
#endif // GLRENDERER_H
|
||||
|
@ -27,33 +27,31 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <GLView.h>
|
||||
#include "GLRenderersManager.h"
|
||||
#include "GLRenderer.h"
|
||||
|
||||
//
|
||||
// Input: rect - initial rectangle
|
||||
// name - window name
|
||||
// resizingMode - example: B_FOLLOW_NONE
|
||||
// mode - usually 0 ?
|
||||
// options - Bitwise-OR of BGL_* tokens
|
||||
//
|
||||
|
||||
BGLView::BGLView(BRect rect, char *name,
|
||||
ulong resizingMode, ulong mode,
|
||||
ulong options)
|
||||
: BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS) // | B_FULL_UPDATE_ON_RESIZE)
|
||||
BGLView::BGLView(BRect rect, char *name, ulong resizingMode, ulong mode, ulong options)
|
||||
: BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), // | B_FULL_UPDATE_ON_RESIZE)
|
||||
fRenderer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BGLView::~BGLView()
|
||||
{
|
||||
delete fRenderer;
|
||||
}
|
||||
|
||||
void BGLView::LockGL()
|
||||
{
|
||||
if (fRenderer)
|
||||
fRenderer->LockGL();
|
||||
}
|
||||
|
||||
void BGLView::UnlockGL()
|
||||
{
|
||||
if (fRenderer)
|
||||
fRenderer->UnlockGL();
|
||||
}
|
||||
|
||||
void BGLView::SwapBuffers()
|
||||
@ -63,6 +61,8 @@ void BGLView::SwapBuffers()
|
||||
|
||||
void BGLView::SwapBuffers(bool vSync)
|
||||
{
|
||||
if (fRenderer)
|
||||
fRenderer->SwapBuffers(vSync);
|
||||
}
|
||||
|
||||
BView * BGLView::EmbeddedView()
|
||||
@ -75,6 +75,9 @@ status_t BGLView::CopyPixelsOut(BPoint source, BBitmap *dest)
|
||||
if (! dest || ! dest->Bounds().IsValid())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (fRenderer)
|
||||
return fRenderer->CopyPixelsOut(source, dest);
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@ -83,6 +86,9 @@ status_t BGLView::CopyPixelsIn(BBitmap *source, BPoint dest)
|
||||
if (! source || ! source->Bounds().IsValid())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (fRenderer)
|
||||
return fRenderer->CopyPixelsIn(source, dest);
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@ -98,81 +104,100 @@ void BGLView::ErrorCallback(unsigned long errorCode) // Mesa's GLenum is not ulo
|
||||
|
||||
void BGLView::Draw(BRect updateRect)
|
||||
{
|
||||
if (fRenderer)
|
||||
return fRenderer->Draw(updateRect);
|
||||
|
||||
// TODO: auto-size and center the string
|
||||
MovePenTo(8, 32);
|
||||
DrawString("No OpenGL renderer available!");
|
||||
}
|
||||
|
||||
void BGLView::AttachedToWindow()
|
||||
{
|
||||
BView::AttachedToWindow();
|
||||
BView::AttachedToWindow();
|
||||
|
||||
// don't paint window background white when resized
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
if (fRenderer) {
|
||||
// Don't paint white window background when resized
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
return fRenderer->AttachedToWindow();
|
||||
}
|
||||
|
||||
// No Renderer, no rendering. Setup a minimal "No Renderer" string drawing context
|
||||
SetFont(be_bold_font);
|
||||
// SetFontSize(16);
|
||||
}
|
||||
|
||||
void BGLView::AllAttached()
|
||||
{
|
||||
BView::AllAttached();
|
||||
BView::AllAttached();
|
||||
}
|
||||
|
||||
void BGLView::DetachedFromWindow()
|
||||
{
|
||||
BView::DetachedFromWindow();
|
||||
BView::DetachedFromWindow();
|
||||
}
|
||||
|
||||
void BGLView::AllDetached()
|
||||
{
|
||||
BView::AllDetached();
|
||||
BView::AllDetached();
|
||||
}
|
||||
|
||||
void BGLView::FrameResized(float width, float height)
|
||||
{
|
||||
return BView::FrameResized(width, height);
|
||||
return BView::FrameResized(width, height);
|
||||
}
|
||||
|
||||
status_t BGLView::Perform(perform_code d, void *arg)
|
||||
{
|
||||
return BView::Perform(d, arg);
|
||||
return BView::Perform(d, arg);
|
||||
}
|
||||
|
||||
|
||||
status_t BGLView::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
return BView::Archive(data, deep);
|
||||
return BView::Archive(data, deep);
|
||||
}
|
||||
|
||||
void BGLView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
BView::MessageReceived(msg);
|
||||
BView::MessageReceived(msg);
|
||||
}
|
||||
|
||||
void BGLView::SetResizingMode(uint32 mode)
|
||||
{
|
||||
BView::SetResizingMode(mode);
|
||||
BView::SetResizingMode(mode);
|
||||
}
|
||||
|
||||
void BGLView::Show()
|
||||
{
|
||||
BView::Show();
|
||||
BView::Show();
|
||||
}
|
||||
|
||||
void BGLView::Hide()
|
||||
{
|
||||
BView::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);
|
||||
return BView::ResolveSpecifier(msg, index, specifier, form, property);
|
||||
}
|
||||
|
||||
status_t BGLView::GetSupportedSuites(BMessage *data)
|
||||
{
|
||||
return BView::GetSupportedSuites(data);
|
||||
return BView::GetSupportedSuites(data);
|
||||
}
|
||||
|
||||
void BGLView::DirectConnected( direct_buffer_info *info )
|
||||
{
|
||||
/* TODO:
|
||||
- update local copy of caller's BDirectWindow's direct_buffer_info
|
||||
- clip it against BGLView's visible region
|
||||
- pass the view's clipped direct_buffer_info to renderer's DirectConnect()
|
||||
*/
|
||||
|
||||
#if 0
|
||||
if (! m_direct_connected && m_direct_connection_disabled)
|
||||
return;
|
||||
@ -202,10 +227,15 @@ void BGLView::DirectConnected( direct_buffer_info *info )
|
||||
}
|
||||
direct_info_locker->Unlock();
|
||||
#endif
|
||||
|
||||
if (fRenderer)
|
||||
return fRenderer->DirectConnected(info);
|
||||
}
|
||||
|
||||
void BGLView::EnableDirectMode( bool enabled )
|
||||
{
|
||||
if (fRenderer)
|
||||
return fRenderer->EnableDirectMode(enabled);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) mesa $(TARGET_ARCH) ] ;
|
||||
SharedLibrary libGL.so :
|
||||
GLView.cpp
|
||||
GLDispatcher.cpp
|
||||
GLRenderer.cpp
|
||||
|
||||
# mesa/$(TARGET_ARCH)
|
||||
glapi_$(TARGET_ARCH).S
|
||||
|
Loading…
Reference in New Issue
Block a user