forked from KolibriOS/kolibrios
gl-render: still knocking on
git-svn-id: svn://kolibrios.org@4473 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
cfb22e3303
commit
cf77f6abc4
@ -14,8 +14,8 @@
|
||||
#include <kos32sys.h>
|
||||
#include <pixlib2.h>
|
||||
|
||||
static EGLImageKHR px_create_image(EGLDisplay display, EGLContext context,
|
||||
int width, int height, int stride, int name, int depth);
|
||||
EGLImageKHR px_create_image(EGLDisplay display, EGLContext context,
|
||||
int width, int height, int stride, int name);
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -33,7 +33,8 @@ int main()
|
||||
EGLint config_attribs[32];
|
||||
EGLint num_configs, i;
|
||||
GLint list;
|
||||
GLuint *texture;
|
||||
GLuint texture, buffer;
|
||||
|
||||
|
||||
int fd;
|
||||
|
||||
@ -81,7 +82,7 @@ int main()
|
||||
if (!context)
|
||||
printf("failed to create context");
|
||||
|
||||
gs = gbm_surface_create(gbm, 400, 300, GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING);
|
||||
gs = gbm_surface_create(gbm, 1024, 768, GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING);
|
||||
|
||||
|
||||
BeginDraw();
|
||||
@ -101,34 +102,74 @@ int main()
|
||||
if(fd)
|
||||
{
|
||||
int ret;
|
||||
GLenum status;
|
||||
struct drm_i915_fb_info fb;
|
||||
struct drm_gem_open open_arg;
|
||||
|
||||
memset(&fb, 0, sizeof(fb));
|
||||
ret = drmIoctl(fd, SRV_FBINFO, &fb);
|
||||
if( ret != 0 )
|
||||
printf("failed to get framebuffer info\n");
|
||||
|
||||
memset(&open_arg,0,sizeof(open_arg));
|
||||
open_arg.name = fb.name;
|
||||
ret = drmIoctl(fd,DRM_IOCTL_GEM_OPEN,&open_arg);
|
||||
if (ret != 0) {
|
||||
printf("Couldn't reference framebuffer handle 0x%08x\n", fb.name);
|
||||
}
|
||||
fb_image = px_create_image(dpy,context,fb.width,fb.height,
|
||||
fb.pitch,fb.name);
|
||||
|
||||
printf("fb_image %p\n", fb_image);
|
||||
|
||||
asm volatile ("int3");
|
||||
|
||||
fb_image = px_create_image(dpy,context,fb.width,fb.height,
|
||||
fb.pitch,open_arg.handle,32);
|
||||
|
||||
glGenTextures(1, texture);
|
||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,fb_image);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glGenFramebuffers(1, &buffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, texture,0);
|
||||
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
const char *str;
|
||||
switch (status)
|
||||
{
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
str = "incomplete attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
||||
str = "incomplete/missing attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||
str = "incomplete draw buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||
str = "incomplete read buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
||||
str = "unsupported";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
||||
str = "incomplete multiple";
|
||||
break;
|
||||
default:
|
||||
str = "unknown error";
|
||||
break;
|
||||
}
|
||||
|
||||
printf("destination is framebuffer incomplete: %s [%#x]\n",
|
||||
str, status);
|
||||
}
|
||||
|
||||
glViewport(0, 0,fb.width, fb.height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 100.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
glClearColor( 0, 0, 0, 1);
|
||||
@ -167,13 +208,6 @@ int main()
|
||||
|
||||
glDrawBuffer(GL_BACK);
|
||||
|
||||
glViewport(0, 0, (GLint)400, (GLint)300);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 100.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
@ -187,12 +221,12 @@ int main()
|
||||
glFlush();
|
||||
|
||||
|
||||
eglSwapBuffers(dpy, surface);
|
||||
// eglSwapBuffers(dpy, surface);
|
||||
|
||||
glFinish();
|
||||
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroySurface(dpy, surface);
|
||||
gbm_surface_destroy(gs);
|
||||
// eglDestroySurface(dpy, surface);
|
||||
// gbm_surface_destroy(gs);
|
||||
eglDestroyContext(dpy, context);
|
||||
eglTerminate(dpy);
|
||||
|
||||
@ -218,8 +252,8 @@ int drmIoctl(int fd, unsigned long request, void *arg)
|
||||
return call_service(&io);
|
||||
}
|
||||
|
||||
static EGLImageKHR px_create_image(EGLDisplay display, EGLContext context,
|
||||
int width, int height, int stride, int name, int depth)
|
||||
EGLImageKHR px_create_image(EGLDisplay display, EGLContext context,
|
||||
int width, int height, int stride, int name)
|
||||
{
|
||||
EGLImageKHR image;
|
||||
EGLint attribs[] = {
|
||||
@ -236,12 +270,12 @@ static EGLImageKHR px_create_image(EGLDisplay display, EGLContext context,
|
||||
attribs[1] = width;
|
||||
attribs[3] = height;
|
||||
attribs[5] = stride;
|
||||
if (depth != 32 && depth != 24)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
|
||||
printf("%s w:%d :%d pitch:%d handle %d\n", __FUNCTION__,
|
||||
width, height, stride, name);
|
||||
|
||||
image = eglCreateImageKHR(display, context, EGL_DRM_BUFFER_MESA,
|
||||
(void *) (uintptr_t)name, attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user