Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/canvas-generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ CanvasGeneric::resize_no_viewport(int width, int height)
}

native_window_ = native_state_.window(cur_properties);
window_initialized_ = true;

width_ = cur_properties.width;
height_ = cur_properties.height;
Expand All @@ -274,6 +275,12 @@ CanvasGeneric::resize_no_viewport(int width, int height)
bool
CanvasGeneric::do_make_current()
{
if(!window_initialized_)
{
Log::error("glwindow has never been initialized, check native-state code\n"
"it should not return a valid window until create_window() is called\n");
return false;
}
gl_state_.init_surface(native_window_);

if (!gl_state_.valid()) {
Expand Down
6 changes: 4 additions & 2 deletions src/canvas-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class CanvasGeneric : public Canvas
CanvasGeneric(NativeState& native_state, GLState& gl_state,
int width, int height)
: Canvas(width, height),
native_state_(native_state), gl_state_(gl_state),
native_state_(native_state), gl_state_(gl_state),native_window_(0),
gl_color_format_(0), gl_depth_format_(0),
color_renderbuffer_(0), depth_renderbuffer_(0), fbo_(0) {}
color_renderbuffer_(0), depth_renderbuffer_(0), fbo_(0),
window_initialized_(false) {}

bool init();
bool reset();
Expand Down Expand Up @@ -70,6 +71,7 @@ class CanvasGeneric : public Canvas
GLuint color_renderbuffer_;
GLuint depth_renderbuffer_;
GLuint fbo_;
bool window_initialized_;
};

#endif /* GLMARK2_CANVAS_GENERIC_H_ */
10 changes: 10 additions & 0 deletions src/gl-headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ struct GLExtensions {
static GLboolean (GLAD_API_PTR *UnmapBuffer) (GLenum target);
};

#define CHECK_GL_ERRORS \
do{ \
const char *fname = __FILE__; \
int lineno = __LINE__; \
GLuint error = glGetError(); \
if(error != GL_NONE) \
Log::error("GL error %d 0x%x %s:%d\n",error,error,fname,lineno); \
} \
while (0)

#endif
176 changes: 0 additions & 176 deletions src/glad/include/EGL/eglplatform.h

This file was deleted.

4 changes: 4 additions & 0 deletions src/glad/include/glad/egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro

#endif /* GLAD_PLATFORM_H_ */

#ifndef EGL_CAST
#define EGL_CAST(a,b) ((a)b)
#endif

#define EGL_ALPHA_FORMAT 0x3088
#define EGL_ALPHA_FORMAT_NONPRE 0x308B
#define EGL_ALPHA_FORMAT_PRE 0x308C
Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "native-state-dispmanx.h"
#elif GLMARK2_USE_WIN32
#include "native-state-win32.h"
#elif GLMARK2_USE_FB
#include "native-state-fb.h"
#endif

#if GLMARK2_USE_EGL
Expand Down Expand Up @@ -177,6 +179,8 @@ main(int argc, char *argv[])
NativeStateDispmanx native_state;
#elif GLMARK2_USE_WIN32
NativeStateWin32 native_state;
#elif GLMARK2_USE_FB
NativeStateFb native_state;
#endif

#if GLMARK2_USE_EGL
Expand Down
74 changes: 74 additions & 0 deletions src/native-state-fb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright © 2010-2011 Linaro Limited
* Copyright © 2013 Canonical Ltd
*
* This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
*
* glmark2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* glmark2. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Federico Giovanardi
*/
#include "native-state-fb.h"
#include <EGL/eglvivante.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <iostream>
#include "log.h"

bool NativeStateFb::init_display()
{
theNativeDisplay = fbGetDisplayByIndex(0);
if( !theNativeDisplay )
return false;
fbGetDisplayGeometry((EGLNativeDisplayType)theNativeDisplay,&width,&height);
theNativeWindow = fbCreateWindow((EGLNativeDisplayType)theNativeDisplay, 0, 1, width, height);
return true;
}
void* NativeStateFb::display()
{
return theNativeDisplay;
}
bool NativeStateFb::create_window(WindowProperties const& )
{
/*NOTE we must do this trick otherwise the projection matrix wont'be initialized*/
win_created = 1;
return true;
}
void* NativeStateFb::window(WindowProperties& properties)
{
/*NOTE we must do this trick otherwise the projection matrix wont'be initialized*/
if(!win_created)
return 0;
properties.width = width;
properties.height = height;
properties.fullscreen = true;
properties.visual_id = 0;
return theNativeWindow;
}
void NativeStateFb::visible(bool )
{
}
bool NativeStateFb::should_quit()
{
return false;
}
void NativeStateFb::flip()
{
}
void NativeStateFb::cleanup()
{
fbDestroyWindow((EGLNativeWindowType)theNativeWindow); theNativeWindow = 0;
fbDestroyDisplay((EGLNativeDisplayType)theNativeDisplay); theNativeDisplay = 0;
}
57 changes: 57 additions & 0 deletions src/native-state-fb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright © 2019 Linaro
*
* This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
*
* glmark2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* glmark2. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Federico Giovanardi
*/
#ifndef GLMARK2_NATIVE_STATE_FB_H_
#define GLMARK2_NATIVE_STATE_FB_H_

#include "native-state.h"
#include <csignal>
#include <cstring>
#include <stdio.h>

class NativeStateFb : public NativeState
{
public:
NativeStateFb() :
theNativeWindow(0),
theNativeDisplay(0),
win_created(0)
{
}
~NativeStateFb() { cleanup(); }

bool init_display();
void* display();
bool create_window(WindowProperties const& properties);
void* window(WindowProperties& properties);
void visible(bool v);
bool should_quit();
void flip();

private:
void * theNativeWindow;
void * theNativeDisplay;
int width,height;
bool win_created;
void cleanup();
};

#endif /* GLMARK2_NATIVE_STATE_FB_H_ */
Loading