Commit 76f6b237 authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

make it working with glClearColor(red)

parent 1ad59337
......@@ -27,9 +27,8 @@ project.xcworkspace
node_modules/
npm-debug.log
# android
#
android/build/
android/.gradle/
android/.idea/
......
......@@ -28,3 +28,14 @@ DerivedData
#
node_modules/
npm-debug.log
# android
#
android/build/
android/.gradle/
android/.idea/
android/android.iml
android/gradle/
android/gradlew
android/gradlew.bat
android/local.properties
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.projectseptember.RNGL">
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
</manifest>
package com.projectseptember.RNGL;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.opengl.GLSurfaceView;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
public class GLCanvasManager extends SimpleViewManager<GLCanvasView> {
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class GLCanvasManager extends SimpleViewManager<GLSurfaceView> {
public static final String REACT_CLASS = "GLCanvas";
......@@ -23,14 +22,32 @@ public class GLCanvasManager extends SimpleViewManager<GLCanvasView> {
}
@Override
public GLCanvasView createViewInstance(ThemedReactContext context) {
return new GLCanvasView(context, Fresco.newDraweeControllerBuilder(), mCallerContext);
public GLSurfaceView createViewInstance(ThemedReactContext context) {
GLSurfaceView view = new GLSurfaceView(context);
view.setRenderer(new GLSurfaceView.Renderer() {
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
}
@Override
public void onDrawFrame(GL10 gl) {
gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
});
return view;
}
@Override
public void updateView(final ReactImageView view, final CatalystStylesDiffMap props) {
public void updateView(final GLSurfaceView view, final CatalystStylesDiffMap props) {
super.updateView(view, props);
// TODO... call setters with props
view.maybeUpdateView();
// view.requestRender();
}
}
package com.projectseptember.RNGL;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
public class RNGLContext extends ReactContextBaseJavaModule {
public RNGLContext (ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "RNGLContext";
}
@ReactMethod
public void addShader (Integer id, ReadableMap config) {
String frag = config.getString("frag");
String name = config.getString("name");
System.out.println("TODO... addShader: "+id+" "+name);
}
}
......@@ -11,7 +11,19 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
public class GLCanvas implements ReactPackage {
public class RNGLPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RNGLContext(reactApplicationContext));
return modules;
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
......
const Shaders = require("./src/Shaders");
const View = require("./src/View");
const Uniform = require("./src/Uniform");
const Component = require("./src/ComponentDeprecated");
const createComponent = require("./src/createComponent");
throw new Error("Android version is not yet implemented");
module.exports = {
Shaders,
View,
Uniform,
Component,
createComponent
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment