//================================================================
// Xe UI toolkit
//
// OpenGL-specific functionality
//
// AUTHOR:  Gabor Nagy
// DATE:    2025-May-12 18:12:58
//
// Copyright (C) 2014-2026 by Gabor Nagy. All rights reserved.
//================================================================
#ifndef _XeGL_h
#define _XeGL_h

#include <Xe/XeTypes.h>
#include <Image/GL/EpGL.h>


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif

struct XeWidgetGLData_S
{
	GLuint      TextureID;    // OpenGL texture for drawing the Widget in the GL viewport. May only exist for the Shell (all descendants will draw in this)
	EFloat32_3  Vertices[4];

	EFloat32_3  DropShadow_Vertices[16];
};

// OpenGL-specific data for an XeFontSize (GPUData field)
typedef struct
{
	EObjectCore(EObject);

	int   FirstGlyphGLID;  // Used if UnicodeToGlyphGLCode is NULL
} XeGLFontSizeData;


struct XeStringDrawContextGLData_S
{
	GLuint  GL_TargetTexture;
};


struct XeDropShadowGL_S
{
	XeDropShadowCore;

#ifdef XeOpenGL
	GLuint    GLTextureID;
#endif
};


#define XeMAX_PRINTF_BUFFER_SIZE  4096


extern const EObjectClass  XeGLFontSizeData_class[];

extern XeVisual*  XeGL_VisualNew(XeDisplay* PDisplay, const int PScreenNumber, const int* PGLVisualAttributes);
extern void       XeGL_FontSizeLoadGlyph(XeFontSize* PFontSize,  const int PGlyphIndex, const int PBase);
extern void       XeGL_UseXeFontSize(XeFontSize* PFontSize, const int PCodeMax,  const int PBase);
extern int        XeGL_LoadFontSize(XeFontSize* PFontSize);

extern void       XeGL_printff(const XeFontSize* PFontSize,  const float PX, const float PY, const float PZ,  const float PLineSpacing, const char* PText, ...);
extern void       XeGL_printfMLf(const XeFontSize* PFontSize,  const float PX, const float PY, const float PZ,  const float PStartX, const float PStartLine, const float PLineSpacing, const char* PText, ...);
extern void       XeGL_printfd(const XeFontSize* PFontSize,  const double PX, const double PY, const double PZ,  const double PLineSpacing, const char* PText, ...);
extern void       XeGL_printfMLd(const XeFontSize* PFontSize,  const double PX, const double PY, const double PZ,  const double PStartX, const double PStartLine, const double PLineSpacing, const char* PText, ...);
extern void       XeGL_wprintff(const XeFontSize* PFontSize,  const float PX, const float PY, const float PZ,  const float PLineSpacing, const wchar_t* PText);
extern void       XeGL_wprintfd(const XeFontSize* PFontSize,  const double PX, const double PY, const double PZ,  const double PLineSpacing, const wchar_t* PText);

extern void       XeGL_WidgetDraw(XeWidget PW, const float PPixelsToUnits, const EBool PForPicking);

extern GLenum     XeGL_CheckStatus(const char* PFunction, const char* PFile, const int PLine, const EBool PShowNoError, const EBool PPrint, const EBool PLog,  const char* PPrefix, const char* PMessage);
#define XeGLM_CheckStatusNL(pShowNoError)  XeGL_CheckStatus(__FUNCTION__, __FILE__, __LINE__, pShowNoError, TRUE, FALSE,  "", "\n")

extern ELogFunc  XeGL_LogFunc;


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}  // Close scope of 'extern "C"' declaration
#endif

#endif // _XeGL_h
